OpenVDB 14.0.0
Loading...
Searching...
No Matches
LeafNodeBool.h
Go to the documentation of this file.
1// Copyright Contributors to the OpenVDB Project
2// SPDX-License-Identifier: Apache-2.0
3
4#ifndef OPENVDB_TREE_LEAF_NODE_BOOL_HAS_BEEN_INCLUDED
5#define OPENVDB_TREE_LEAF_NODE_BOOL_HAS_BEEN_INCLUDED
6
7#include <openvdb/Types.h>
8#include <openvdb/io/Compression.h> // for io::readData(), etc.
10#include <openvdb/math/Math.h> // for math::isZero()
12#include "LeafNode.h"
13#include "Iterator.h"
14#include <iostream>
15#include <sstream>
16#include <string>
17#include <type_traits>
18#include <vector>
19
20
21namespace openvdb {
23namespace OPENVDB_VERSION_NAME {
24namespace tree {
25
26/// @brief LeafNode specialization for values of type bool that stores both
27/// the active states and the values of (2^Log2Dim)^3 voxels as bit masks
28template<Index Log2Dim>
29class LeafNode<bool, Log2Dim>
30{
31public:
32 using LeafNodeType = LeafNode<bool, Log2Dim>;
33 using BuildType = bool;
34 using ValueType = bool;
35 using Buffer = LeafBuffer<ValueType, Log2Dim>;
36 using NodeMaskType = util::NodeMask<Log2Dim>;
37 using Ptr = SharedPtr<LeafNodeType>;
38
39 // These static declarations must be on separate lines to avoid VC9 compiler errors.
40 static const Index LOG2DIM = Log2Dim; // needed by parent nodes
41 static const Index TOTAL = Log2Dim; // needed by parent nodes
42 static const Index DIM = 1 << TOTAL; // dimension along one coordinate direction
43 static const Index NUM_VALUES = 1 << 3 * Log2Dim;
44 static const Index NUM_VOXELS = NUM_VALUES; // total number of voxels represented by this node
45 static const Index SIZE = NUM_VALUES;
46 static const Index LEVEL = 0; // level 0 = leaf
47
48 /// @brief ValueConverter<T>::Type is the type of a LeafNode having the same
49 /// dimensions as this node but a different value type, T.
50 template<typename ValueType>
51 struct ValueConverter { using Type = LeafNode<ValueType, Log2Dim>; };
52
53 /// @brief SameConfiguration<OtherNodeType>::value is @c true if and only if
54 /// OtherNodeType is the type of a LeafNode with the same dimensions as this node.
55 template<typename OtherNodeType>
59
60
61 /// Default constructor
62 LeafNode();
63
64 /// Constructor
65 /// @param xyz the coordinates of a voxel that lies within the node
66 /// @param value the initial value for all of this node's voxels
67 /// @param active the active state to which to initialize all voxels
68 explicit LeafNode(const Coord& xyz, bool value = false, bool active = false);
69
70 /// "Partial creation" constructor used during file input
71 LeafNode(PartialCreate, const Coord& xyz, bool value = false, bool active = false);
72
73 /// Deep copy constructor
74 LeafNode(const LeafNode&);
75
76 /// Deep assignment operator
77 LeafNode& operator=(const LeafNode&) = default;
78
79 /// Value conversion copy constructor
80 template<typename OtherValueType>
81 explicit LeafNode(const LeafNode<OtherValueType, Log2Dim>& other);
82
83 /// @brief Construct a LeafNodeBool with its individual components
84 /// @param xyz Leaf origin
85 /// @param mask The ValueMask to copy
86 /// @param buff The LeafBuffer to copy (also constructable from a ValueMask)
87 /// @param trans Transient data (ignored until ABI 9)
88 LeafNode(const Coord& xyz,
89 const NodeMaskType& mask,
90 const Buffer& buff,
91 const Index32 trans = 0);
92
93 //@{
94 /// @brief Topology copy constructors
95 template<typename ValueType>
96 LeafNode(const LeafNode<ValueType, Log2Dim>& other, bool offValue, bool onValue, TopologyCopy);
97 template<typename ValueType>
98 LeafNode(const LeafNode<ValueType, Log2Dim>& other, bool background, TopologyCopy);
99 //@}
100
101 /// Destructor
102 ~LeafNode();
103
104 //
105 // Statistics
106 //
107 /// Return log2 of the size of the buffer storage.
108 static Index log2dim() { return Log2Dim; }
109 /// Return the number of voxels in each dimension.
110 static Index dim() { return DIM; }
111 static Index size() { return SIZE; }
112 static Index numValues() { return SIZE; }
113 static Index getLevel() { return LEVEL; }
114 static void getNodeLog2Dims(std::vector<Index>& dims) { dims.push_back(Log2Dim); }
115 static Index getChildDim() { return 1; }
116
117 static Index64 leafCount() { return 1; }
118 /// no-op
119 void nodeCount(std::vector<Index64> &) const {}
120 static Index64 nonLeafCount() { return 0; }
121
122 /// Return the number of active voxels.
123 Index64 onVoxelCount() const { return mValueMask.countOn(); }
124 /// Return the number of inactive voxels.
125 Index64 offVoxelCount() const { return mValueMask.countOff(); }
126 Index64 onLeafVoxelCount() const { return onVoxelCount(); }
127 Index64 offLeafVoxelCount() const { return offVoxelCount(); }
128 static Index64 onTileCount() { return 0; }
129 static Index64 offTileCount() { return 0; }
130
131 /// Return @c true if this node has no active voxels.
132 bool isEmpty() const { return mValueMask.isOff(); }
133 /// Return @c true if this node only contains active voxels.
134 bool isDense() const { return mValueMask.isOn(); }
135 /// @brief Return @c true if memory for this node's buffer has been allocated.
136 /// @details Currently, boolean leaf nodes don't support partial creation,
137 /// so this always returns @c true.
138 bool isAllocated() const { return true; }
139 /// @brief Allocate memory for this node's buffer if it has not already been allocated.
140 /// @details Currently, boolean leaf nodes don't support partial creation,
141 /// so this has no effect.
142 bool allocate() { return true; }
143
144 /// Return the memory in bytes occupied by this node.
145 Index64 memUsage() const;
146
147 /// Expand the given bounding box so that it includes this leaf node's active voxels.
148 /// If visitVoxels is false this LeafNode will be approximated as dense, i.e. with all
149 /// voxels active. Else the individual active voxels are visited to produce a tight bbox.
150 void evalActiveBoundingBox(CoordBBox& bbox, bool visitVoxels = true) const;
151
152 /// @brief Return the bounding box of this node, i.e., the full index space
153 /// spanned by this leaf node.
154 CoordBBox getNodeBoundingBox() const { return CoordBBox::createCube(mOrigin, DIM); }
155
156 /// Set the grid index coordinates of this node's local origin.
157 void setOrigin(const Coord& origin) { mOrigin = origin; }
158 //@{
159 /// Return the grid index coordinates of this node's local origin.
160 const Coord& origin() const { return mOrigin; }
161 void getOrigin(Coord& origin) const { origin = mOrigin; }
162 void getOrigin(Int32& x, Int32& y, Int32& z) const { mOrigin.asXYZ(x, y, z); }
163 //@}
164
165 /// Return the linear table offset of the given global or local coordinates.
166 static Index coordToOffset(const Coord& xyz);
167 /// @brief Return the local coordinates for a linear table offset,
168 /// where offset 0 has coordinates (0, 0, 0).
169 static Coord offsetToLocalCoord(Index n);
170 /// Return the global coordinates for a linear table offset.
171 Coord offsetToGlobalCoord(Index n) const;
172
173 /// Return the transient data value.
174 Index32 transientData() const { return mTransientData; }
175 /// Set the transient data value.
176 void setTransientData(Index32 transientData) { mTransientData = transientData; }
177
178 /// Return a string representation of this node.
179 std::string str() const;
180
181 /// @brief Return @c true if the given node (which may have a different @c ValueType
182 /// than this node) has the same active value topology as this node.
183 template<typename OtherType, Index OtherLog2Dim>
184 bool hasSameTopology(const LeafNode<OtherType, OtherLog2Dim>* other) const;
185
186 /// Check for buffer equivalence by value.
187 bool operator==(const LeafNode&) const;
188 bool operator!=(const LeafNode&) const;
189
190 //
191 // Buffer management
192 //
193 /// @brief Exchange this node's data buffer with the given data buffer
194 /// without changing the active states of the values.
195 void swap(Buffer& other) { mBuffer.swap(other); }
196 const Buffer& buffer() const { return mBuffer; }
197 Buffer& buffer() { return mBuffer; }
198
199#if OPENVDB_ABI_VERSION_NUMBER < 14
200 //
201 // I/O methods
202 //
203 /// Read in just the topology.
204 void readTopology(std::istream&, bool fromHalf = false);
205 /// Write out just the topology.
206 void writeTopology(std::ostream&, bool toHalf = false) const;
207
208 /// Read in the topology and the origin.
209 void readBuffers(std::istream&, bool fromHalf = false);
210 void readBuffers(std::istream& is, const CoordBBox&, bool fromHalf = false);
211 /// Write out the topology and the origin.
212 void writeBuffers(std::ostream&, bool toHalf = false) const;
213#endif // OPENVDB_ABI_VERSION_NUMBER < 14
214
215 //
216 // Accessor methods
217 //
218 /// Return the value of the voxel at the given coordinates.
219 const bool& getValue(const Coord& xyz) const;
220 /// Return the value of the voxel at the given offset.
221 const bool& getValue(Index offset) const;
222
223 /// @brief Return @c true if the voxel at the given coordinates is active.
224 /// @param xyz the coordinates of the voxel to be probed
225 /// @param[out] val the value of the voxel at the given coordinates
226 bool probeValue(const Coord& xyz, bool& val) const;
227 /// @brief Return @c true if the voxel at the given offset is active.
228 /// @param offset the linear offset of the voxel to be probed
229 /// @param[out] val the value of the voxel at the given coordinates
230 bool probeValue(Index offset, bool& val) const;
231
232 /// Return the level (0) at which leaf node values reside.
233 static Index getValueLevel(const Coord&) { return LEVEL; }
234
235 /// Set the active state of the voxel at the given coordinates but don't change its value.
236 void setActiveState(const Coord& xyz, bool on);
237 /// Set the active state of the voxel at the given offset but don't change its value.
238 void setActiveState(Index offset, bool on) { OPENVDB_ASSERT(offset<SIZE); mValueMask.set(offset, on); }
239
240 /// Set the value of the voxel at the given coordinates but don't change its active state.
241 void setValueOnly(const Coord& xyz, bool val);
242 /// Set the value of the voxel at the given offset but don't change its active state.
243 void setValueOnly(Index offset, bool val) { OPENVDB_ASSERT(offset<SIZE); mBuffer.setValue(offset,val); }
244
245 /// Mark the voxel at the given coordinates as inactive but don't change its value.
246 void setValueOff(const Coord& xyz) { mValueMask.setOff(this->coordToOffset(xyz)); }
247 /// Mark the voxel at the given offset as inactive but don't change its value.
248 void setValueOff(Index offset) { OPENVDB_ASSERT(offset < SIZE); mValueMask.setOff(offset); }
249
250 /// Set the value of the voxel at the given coordinates and mark the voxel as inactive.
251 void setValueOff(const Coord& xyz, bool val);
252 /// Set the value of the voxel at the given offset and mark the voxel as inactive.
253 void setValueOff(Index offset, bool val);
254
255 /// Mark the voxel at the given coordinates as active but don't change its value.
256 void setValueOn(const Coord& xyz) { mValueMask.setOn(this->coordToOffset(xyz)); }
257 /// Mark the voxel at the given offset as active but don't change its value.
258 void setValueOn(Index offset) { OPENVDB_ASSERT(offset < SIZE); mValueMask.setOn(offset); }
259
260 /// Set the value of the voxel at the given coordinates and mark the voxel as active.
261 void setValueOn(const Coord& xyz, bool val);
262 /// Set the value of the voxel at the given coordinates and mark the voxel as active.
263 void setValue(const Coord& xyz, bool val) { this->setValueOn(xyz, val); }
264 /// Set the value of the voxel at the given offset and mark the voxel as active.
265 void setValueOn(Index offset, bool val);
266
267 /// @brief Apply a functor to the value of the voxel at the given offset
268 /// and mark the voxel as active.
269 template<typename ModifyOp>
270 void modifyValue(Index offset, const ModifyOp& op);
271 /// @brief Apply a functor to the value of the voxel at the given coordinates
272 /// and mark the voxel as active.
273 template<typename ModifyOp>
274 void modifyValue(const Coord& xyz, const ModifyOp& op);
275
276 /// Apply a functor to the voxel at the given coordinates.
277 template<typename ModifyOp>
278 void modifyValueAndActiveState(const Coord& xyz, const ModifyOp& op);
279
280 /// Mark all voxels as active but don't change their values.
281 void setValuesOn() { mValueMask.setOn(); }
282 /// Mark all voxels as inactive but don't change their values.
283 void setValuesOff() { mValueMask.setOff(); }
284
285 /// Return @c true if the voxel at the given coordinates is active.
286 bool isValueOn(const Coord& xyz) const { return this->isValueOn(this->coordToOffset(xyz)); }
287 /// Return @c true if the voxel at the given offset is active.
288 bool isValueOn(Index offset) const { OPENVDB_ASSERT(offset < SIZE); return mValueMask.isOn(offset); }
289 /// Return @c true if the voxel at the given coordinates is inactive.
290 bool isValueOff(const Coord& xyz) const { return this->isValueOff(this->coordToOffset(xyz)); }
291 /// Return @c true if the voxel at the given offset is inactive.
292 bool isValueOff(Index offset) const { OPENVDB_ASSERT(offset < SIZE); return mValueMask.isOff(offset); }
293
294 /// Return @c false since leaf nodes never contain tiles.
295 static bool hasActiveTiles() { return false; }
296
297 /// Set all voxels that lie outside the given axis-aligned box to the background.
298 void clip(const CoordBBox&, bool background);
299
300 /// Set all voxels within an axis-aligned box to the specified value and active state.
301 void fill(const CoordBBox& bbox, bool value, bool active = true);
302 /// Set all voxels within an axis-aligned box to the specified value and active state.
303 void denseFill(const CoordBBox& bbox, bool val, bool on = true) { this->fill(bbox, val, on); }
304
305 /// Set all voxels to the specified value but don't change their active states.
306 void fill(const bool& value);
307 /// Set all voxels to the specified value and active state.
308 void fill(const bool& value, bool active);
309
310 /// @brief Copy into a dense grid the values of the voxels that lie within
311 /// a given bounding box.
312 ///
313 /// @param bbox inclusive bounding box of the voxels to be copied into the dense grid
314 /// @param dense dense grid with a stride in @e z of one (see tools::Dense
315 /// in tools/Dense.h for the required API)
316 ///
317 /// @note @a bbox is assumed to be identical to or contained in the coordinate domains
318 /// of both the dense grid and this node, i.e., no bounds checking is performed.
319 /// @note Consider using tools::CopyToDense in tools/Dense.h
320 /// instead of calling this method directly.
321 template<typename DenseT>
322 void copyToDense(const CoordBBox& bbox, DenseT& dense) const;
323
324 /// @brief Copy from a dense grid into this node the values of the voxels
325 /// that lie within a given bounding box.
326 /// @details Only values that are different (by more than the given tolerance)
327 /// from the background value will be active. Other values are inactive
328 /// and truncated to the background value.
329 ///
330 /// @param bbox inclusive bounding box of the voxels to be copied into this node
331 /// @param dense dense grid with a stride in @e z of one (see tools::Dense
332 /// in tools/Dense.h for the required API)
333 /// @param background background value of the tree that this node belongs to
334 /// @param tolerance tolerance within which a value equals the background value
335 ///
336 /// @note @a bbox is assumed to be identical to or contained in the coordinate domains
337 /// of both the dense grid and this node, i.e., no bounds checking is performed.
338 /// @note Consider using tools::CopyFromDense in tools/Dense.h
339 /// instead of calling this method directly.
340 template<typename DenseT>
341 void copyFromDense(const CoordBBox& bbox, const DenseT& dense, bool background, bool tolerance);
342
343 /// @brief Return the value of the voxel at the given coordinates.
344 /// @note Used internally by ValueAccessor.
345 template<typename AccessorT>
346 const bool& getValueAndCache(const Coord& xyz, AccessorT&) const {return this->getValue(xyz);}
347
348 /// @brief Return @c true if the voxel at the given coordinates is active.
349 /// @note Used internally by ValueAccessor.
350 template<typename AccessorT>
351 bool isValueOnAndCache(const Coord& xyz, AccessorT&) const { return this->isValueOn(xyz); }
352
353 /// @brief Change the value of the voxel at the given coordinates and mark it as active.
354 /// @note Used internally by ValueAccessor.
355 template<typename AccessorT>
356 void setValueAndCache(const Coord& xyz, bool val, AccessorT&) { this->setValueOn(xyz, val); }
357
358 /// @brief Change the value of the voxel at the given coordinates
359 /// but preserve its state.
360 /// @note Used internally by ValueAccessor.
361 template<typename AccessorT>
362 void setValueOnlyAndCache(const Coord& xyz, bool val, AccessorT&) {this->setValueOnly(xyz,val);}
363
364 /// @brief Change the value of the voxel at the given coordinates and mark it as inactive.
365 /// @note Used internally by ValueAccessor.
366 template<typename AccessorT>
367 void setValueOffAndCache(const Coord& xyz, bool value, AccessorT&)
368 {
369 this->setValueOff(xyz, value);
370 }
371
372 /// @brief Apply a functor to the value of the voxel at the given coordinates
373 /// and mark the voxel as active.
374 /// @note Used internally by ValueAccessor.
375 template<typename ModifyOp, typename AccessorT>
376 void modifyValueAndCache(const Coord& xyz, const ModifyOp& op, AccessorT&)
377 {
378 this->modifyValue(xyz, op);
379 }
380
381 /// Apply a functor to the voxel at the given coordinates.
382 /// @note Used internally by ValueAccessor.
383 template<typename ModifyOp, typename AccessorT>
384 void modifyValueAndActiveStateAndCache(const Coord& xyz, const ModifyOp& op, AccessorT&)
385 {
386 this->modifyValueAndActiveState(xyz, op);
387 }
388
389 /// @brief Set the active state of the voxel at the given coordinates
390 /// without changing its value.
391 /// @note Used internally by ValueAccessor.
392 template<typename AccessorT>
393 void setActiveStateAndCache(const Coord& xyz, bool on, AccessorT&)
394 {
395 this->setActiveState(xyz, on);
396 }
397
398 /// @brief Return @c true if the voxel at the given coordinates is active
399 /// and return the voxel value in @a val.
400 /// @note Used internally by ValueAccessor.
401 template<typename AccessorT>
402 bool probeValueAndCache(const Coord& xyz, bool& val, AccessorT&) const
403 {
404 return this->probeValue(xyz, val);
405 }
406
407 /// @brief Return the LEVEL (=0) at which leaf node values reside.
408 /// @note Used internally by ValueAccessor.
409 template<typename AccessorT>
410 static Index getValueLevelAndCache(const Coord&, AccessorT&) { return LEVEL; }
411
412 /// @brief Return a const reference to the first entry in the buffer.
413 /// @note Since it's actually a reference to a static data member
414 /// it should not be converted to a non-const pointer!
415 const bool& getFirstValue() const { if (mValueMask.isOn(0)) return Buffer::sOn; else return Buffer::sOff; }
416 /// @brief Return a const reference to the last entry in the buffer.
417 /// @note Since it's actually a reference to a static data member
418 /// it should not be converted to a non-const pointer!
419 const bool& getLastValue() const { if (mValueMask.isOn(SIZE-1)) return Buffer::sOn; else return Buffer::sOff; }
420
421 /// @brief Return @c true if all of this node's voxels have the same active state
422 /// and are equal to within the given tolerance, and return the value in
423 /// @a constValue and the active state in @a state.
424 bool isConstant(bool& constValue, bool& state, bool tolerance = 0) const;
425
426 /// @brief Computes the median value of all the active and inactive voxels in this node.
427 /// @return The median value.
428 ///
429 /// @details The median for boolean values is defined as the mode
430 /// of the values, i.e. the value that occurs most often.
431 bool medianAll() const;
432
433 /// @brief Computes the median value of all the active voxels in this node.
434 /// @return The number of active voxels.
435 /// @param value Updated with the median value of all the active voxels.
436 ///
437 /// @details The median for boolean values is defined as the mode
438 /// of the values, i.e. the value that occurs most often.
439 Index medianOn(ValueType &value) const;
440
441 /// @brief Computes the median value of all the inactive voxels in this node.
442 /// @return The number of inactive voxels.
443 /// @param value Updated with the median value of all the inactive voxels.
444 ///
445 /// @details The median for boolean values is defined as the mode
446 /// of the values, i.e. the value that occurs most often.
447 Index medianOff(ValueType &value) const;
448
449 /// Return @c true if all of this node's values are inactive.
450 bool isInactive() const { return mValueMask.isOff(); }
451
452 //
453 // Unsafe methods
454 //
455 // These methods are not in fact unsafe, but are only offered so that
456 // the same methods can be called on both internal nodes and leaf nodes.
457
458 /// Return the value of the voxel at the given offset.
459 const bool& getValueUnsafe(Index offset) const { return this->getValue(offset); }
460 /// Return true if the voxel at the given offset is active and set value.
461 bool getValueUnsafe(Index offset, bool& value) const { return this->probeValue(offset, value); }
462 /// Set the active state of the voxel at the given offset but don't change its value.
463 void setActiveStateUnsafe(Index offset, bool on) { this->setActiveState(offset, on); }
464 /// Set the value of the voxel at the given coordinates but don't change its active state.
465 void setValueOnlyUnsafe(Index offset, const bool& value) { return this->setValueOnly(offset, value); }
466 /// Mark the voxel at the given offset as active but don't change its value.
467 void setValueOnUnsafe(Index offset) { this->setValueOn(offset); }
468 /// Set the value of the voxel at the given coordinates and mark the voxel as active.
469 void setValueOnUnsafe(Index offset, const bool& value) { this->setValueOn(offset, value); }
470 /// Mark the voxel at the given offset as inactive but don't change its value.
471 void setValueOffUnsafe(Index offset) { this->setValueOff(offset); }
472 /// Set the value of the voxel at the given coordinates and mark the voxel as active.
473 void setValueOffUnsafe(Index offset, const bool& value) { this->setValueOff(offset, value); }
474
475 void resetBackground(bool oldBackground, bool newBackground);
476
477 void negate() { mBuffer.mData.toggle(); }
478
479 template<MergePolicy Policy>
480 void merge(const LeafNode& other, bool bg = false, bool otherBG = false);
481 template<MergePolicy Policy> void merge(bool tileValue, bool tileActive);
482
483 /// @brief No-op
484 /// @details This function exists only to enable template instantiation.
485 void voxelizeActiveTiles(bool = true) {}
486
487 /// @brief Union this node's set of active values with the active values
488 /// of the other node, whose @c ValueType may be different. So a
489 /// resulting voxel will be active if either of the original voxels
490 /// were active.
491 ///
492 /// @note This operation modifies only active states, not values.
493 template<typename OtherType>
494 void topologyUnion(const LeafNode<OtherType, Log2Dim>& other, const bool preserveTiles = false);
495
496 /// @brief Intersect this node's set of active values with the active values
497 /// of the other node, whose @c ValueType may be different. So a
498 /// resulting voxel will be active only if both of the original voxels
499 /// were active.
500 ///
501 /// @details The last dummy argument is required to match the signature
502 /// for InternalNode::topologyIntersection.
503 ///
504 /// @note This operation modifies only active states, not
505 /// values. Also note that this operation can result in all voxels
506 /// being inactive so consider subsequently calling prune.
507 template<typename OtherType>
508 void topologyIntersection(const LeafNode<OtherType, Log2Dim>& other, const bool&);
509
510 /// @brief Difference this node's set of active values with the active values
511 /// of the other node, whose @c ValueType may be different. So a
512 /// resulting voxel will be active only if the original voxel is
513 /// active in this LeafNode and inactive in the other LeafNode.
514 ///
515 /// @details The last dummy argument is required to match the signature
516 /// for InternalNode::topologyDifference.
517 ///
518 /// @note This operation modifies only active states, not values.
519 /// Also, because it can deactivate all of this node's voxels,
520 /// consider subsequently calling prune.
521 template<typename OtherType>
522 void topologyDifference(const LeafNode<OtherType, Log2Dim>& other, const bool&);
523
524 template<typename CombineOp>
525 void combine(const LeafNode& other, CombineOp& op);
526 template<typename CombineOp>
527 void combine(bool, bool valueIsActive, CombineOp& op);
528
529 template<typename CombineOp, typename OtherType /*= bool*/>
530 void combine2(const LeafNode& other, const OtherType&, bool valueIsActive, CombineOp&);
531 template<typename CombineOp, typename OtherNodeT /*= LeafNode*/>
532 void combine2(bool, const OtherNodeT& other, bool valueIsActive, CombineOp&);
533 template<typename CombineOp, typename OtherNodeT /*= LeafNode*/>
534 void combine2(const LeafNode& b0, const OtherNodeT& b1, CombineOp&);
535
536 //@{
537 /// This function exists only to enable template instantiation.
538 void prune(const ValueType& /*tolerance*/ = zeroVal<ValueType>()) {}
539 void addLeaf(LeafNode*) {}
540 template<typename AccessorT>
541 void addLeafAndCache(LeafNode*, AccessorT&) {}
542 template<typename NodeT>
543 NodeT* stealNode(const Coord&, const ValueType&, bool) { return nullptr; }
544 template<typename NodeT>
545 NodeT* probeNode(const Coord&) { return nullptr; }
546 template<typename NodeT>
547 const NodeT* probeConstNode(const Coord&) const { return nullptr; }
548 template<typename ArrayT> void getNodes(ArrayT&) const {}
549 template<typename ArrayT> void stealNodes(ArrayT&, const ValueType&, bool) {}
550 //@}
551
552 void addTile(Index level, const Coord&, bool val, bool active);
553 void addTile(Index offset, bool val, bool active);
554 template<typename AccessorT>
555 void addTileAndCache(Index level, const Coord&, bool val, bool active, AccessorT&);
556
557 //@{
558 /// @brief Return a pointer to this node.
559 LeafNode* touchLeaf(const Coord&) { return this; }
560 template<typename AccessorT>
561 LeafNode* touchLeafAndCache(const Coord&, AccessorT&) { return this; }
562 LeafNode* probeLeaf(const Coord&) { return this; }
563 template<typename AccessorT>
564 LeafNode* probeLeafAndCache(const Coord&, AccessorT&) { return this; }
565 template<typename NodeT, typename AccessorT>
566 NodeT* probeNodeAndCache(const Coord&, AccessorT&)
567 {
569 if (!(std::is_same<NodeT, LeafNode>::value)) return nullptr;
570 return reinterpret_cast<NodeT*>(this);
572 }
573 //@}
574 //@{
575 /// @brief Return a @const pointer to this node.
576 const LeafNode* probeLeaf(const Coord&) const { return this; }
577 template<typename AccessorT>
578 const LeafNode* probeLeafAndCache(const Coord&, AccessorT&) const { return this; }
579 const LeafNode* probeConstLeaf(const Coord&) const { return this; }
580 template<typename AccessorT>
581 const LeafNode* probeConstLeafAndCache(const Coord&, AccessorT&) const { return this; }
582 template<typename NodeT, typename AccessorT>
583 const NodeT* probeConstNodeAndCache(const Coord&, AccessorT&) const
584 {
586 if (!(std::is_same<NodeT, LeafNode>::value)) return nullptr;
587 return reinterpret_cast<const NodeT*>(this);
589 }
590 //@}
591
592 //
593 // Iterators
594 //
595protected:
596 using MaskOnIter = typename NodeMaskType::OnIterator;
597 using MaskOffIter = typename NodeMaskType::OffIterator;
598 using MaskDenseIter = typename NodeMaskType::DenseIterator;
599
600 template<typename MaskIterT, typename NodeT, typename ValueT>
601 struct ValueIter:
602 // Derives from SparseIteratorBase, but can also be used as a dense iterator,
603 // if MaskIterT is a dense mask iterator type.
604 public SparseIteratorBase<MaskIterT, ValueIter<MaskIterT, NodeT, ValueT>, NodeT, ValueT>
605 {
607
609 ValueIter(const MaskIterT& iter, NodeT* parent): BaseT(iter, parent) {}
610
611 const bool& getItem(Index pos) const { return this->parent().getValue(pos); }
612 const bool& getValue() const { return this->getItem(this->pos()); }
613
614 // Note: setItem() can't be called on const iterators.
615 void setItem(Index pos, bool value) const { this->parent().setValueOnly(pos, value); }
616 // Note: setValue() can't be called on const iterators.
617 void setValue(bool value) const { this->setItem(this->pos(), value); }
618
619 // Note: modifyItem() can't be called on const iterators.
620 template<typename ModifyOp>
621 void modifyItem(Index n, const ModifyOp& op) const { this->parent().modifyValue(n, op); }
622 // Note: modifyValue() can't be called on const iterators.
623 template<typename ModifyOp>
624 void modifyValue(const ModifyOp& op) const { this->modifyItem(this->pos(), op); }
625 };
626
627 /// Leaf nodes have no children, so their child iterators have no get/set accessors.
628 template<typename MaskIterT, typename NodeT>
629 struct ChildIter:
630 public SparseIteratorBase<MaskIterT, ChildIter<MaskIterT, NodeT>, NodeT, bool>
631 {
633 ChildIter(const MaskIterT& iter, NodeT* parent): SparseIteratorBase<
634 MaskIterT, ChildIter<MaskIterT, NodeT>, NodeT, bool>(iter, parent) {}
635 };
636
637 template<typename NodeT, typename ValueT>
639 MaskDenseIter, DenseIter<NodeT, ValueT>, NodeT, /*ChildT=*/void, ValueT>
640 {
643
645 DenseIter(const MaskDenseIter& iter, NodeT* parent): BaseT(iter, parent) {}
646
647 bool getItem(Index pos, void*& child, NonConstValueT& value) const
648 {
649 value = this->parent().getValue(pos);
650 child = nullptr;
651 return false; // no child
652 }
653
654 // Note: setItem() can't be called on const iterators.
655 //void setItem(Index pos, void* child) const {}
656
657 // Note: unsetItem() can't be called on const iterators.
658 void unsetItem(Index pos, const ValueT& val) const {this->parent().setValueOnly(pos, val);}
659 };
660
661public:
662 using ValueOnIter = ValueIter<MaskOnIter, LeafNode, const bool>;
663 using ValueOnCIter = ValueIter<MaskOnIter, const LeafNode, const bool>;
664 using ValueOffIter = ValueIter<MaskOffIter, LeafNode, const bool>;
665 using ValueOffCIter = ValueIter<MaskOffIter, const LeafNode, const bool>;
666 using ValueAllIter = ValueIter<MaskDenseIter, LeafNode, const bool>;
667 using ValueAllCIter = ValueIter<MaskDenseIter, const LeafNode, const bool>;
668 using ChildOnIter = ChildIter<MaskOnIter, LeafNode>;
669 using ChildOnCIter = ChildIter<MaskOnIter, const LeafNode>;
670 using ChildOffIter = ChildIter<MaskOffIter, LeafNode>;
671 using ChildOffCIter = ChildIter<MaskOffIter, const LeafNode>;
672 using ChildAllIter = DenseIter<LeafNode, bool>;
673 using ChildAllCIter = DenseIter<const LeafNode, const bool>;
674
675 ValueOnCIter cbeginValueOn() const { return ValueOnCIter(mValueMask.beginOn(), this); }
676 ValueOnCIter beginValueOn() const { return ValueOnCIter(mValueMask.beginOn(), this); }
677 ValueOnIter beginValueOn() { return ValueOnIter(mValueMask.beginOn(), this); }
678 ValueOffCIter cbeginValueOff() const { return ValueOffCIter(mValueMask.beginOff(), this); }
679 ValueOffCIter beginValueOff() const { return ValueOffCIter(mValueMask.beginOff(), this); }
680 ValueOffIter beginValueOff() { return ValueOffIter(mValueMask.beginOff(), this); }
681 ValueAllCIter cbeginValueAll() const { return ValueAllCIter(mValueMask.beginDense(), this); }
682 ValueAllCIter beginValueAll() const { return ValueAllCIter(mValueMask.beginDense(), this); }
683 ValueAllIter beginValueAll() { return ValueAllIter(mValueMask.beginDense(), this); }
684
685 ValueOnCIter cendValueOn() const { return ValueOnCIter(mValueMask.endOn(), this); }
686 ValueOnCIter endValueOn() const { return ValueOnCIter(mValueMask.endOn(), this); }
687 ValueOnIter endValueOn() { return ValueOnIter(mValueMask.endOn(), this); }
688 ValueOffCIter cendValueOff() const { return ValueOffCIter(mValueMask.endOff(), this); }
689 ValueOffCIter endValueOff() const { return ValueOffCIter(mValueMask.endOff(), this); }
690 ValueOffIter endValueOff() { return ValueOffIter(mValueMask.endOff(), this); }
691 ValueAllCIter cendValueAll() const { return ValueAllCIter(mValueMask.endDense(), this); }
692 ValueAllCIter endValueAll() const { return ValueAllCIter(mValueMask.endDense(), this); }
693 ValueAllIter endValueAll() { return ValueAllIter(mValueMask.endDense(), this); }
694
695 // Note that [c]beginChildOn() and [c]beginChildOff() actually return end iterators,
696 // because leaf nodes have no children.
697 ChildOnCIter cbeginChildOn() const { return ChildOnCIter(mValueMask.endOn(), this); }
698 ChildOnCIter beginChildOn() const { return ChildOnCIter(mValueMask.endOn(), this); }
699 ChildOnIter beginChildOn() { return ChildOnIter(mValueMask.endOn(), this); }
700 ChildOffCIter cbeginChildOff() const { return ChildOffCIter(mValueMask.endOff(), this); }
701 ChildOffCIter beginChildOff() const { return ChildOffCIter(mValueMask.endOff(), this); }
702 ChildOffIter beginChildOff() { return ChildOffIter(mValueMask.endOff(), this); }
703 ChildAllCIter cbeginChildAll() const { return ChildAllCIter(mValueMask.beginDense(), this); }
704 ChildAllCIter beginChildAll() const { return ChildAllCIter(mValueMask.beginDense(), this); }
705 ChildAllIter beginChildAll() { return ChildAllIter(mValueMask.beginDense(), this); }
706
707 ChildOnCIter cendChildOn() const { return ChildOnCIter(mValueMask.endOn(), this); }
708 ChildOnCIter endChildOn() const { return ChildOnCIter(mValueMask.endOn(), this); }
709 ChildOnIter endChildOn() { return ChildOnIter(mValueMask.endOn(), this); }
710 ChildOffCIter cendChildOff() const { return ChildOffCIter(mValueMask.endOff(), this); }
711 ChildOffCIter endChildOff() const { return ChildOffCIter(mValueMask.endOff(), this); }
712 ChildOffIter endChildOff() { return ChildOffIter(mValueMask.endOff(), this); }
713 ChildAllCIter cendChildAll() const { return ChildAllCIter(mValueMask.endDense(), this); }
714 ChildAllCIter endChildAll() const { return ChildAllCIter(mValueMask.endDense(), this); }
715 ChildAllIter endChildAll() { return ChildAllIter(mValueMask.endDense(), this); }
716
717 //
718 // Mask accessors
719 //
720 bool isValueMaskOn(Index n) const { return mValueMask.isOn(n); }
721 bool isValueMaskOn() const { return mValueMask.isOn(); }
722 bool isValueMaskOff(Index n) const { return mValueMask.isOff(n); }
723 bool isValueMaskOff() const { return mValueMask.isOff(); }
724 const NodeMaskType& getValueMask() const { return mValueMask; }
725 const NodeMaskType& valueMask() const { return mValueMask; }
726 NodeMaskType& getValueMask() { return mValueMask; }
727 void setValueMask(const NodeMaskType& mask) { mValueMask = mask; }
728 bool isChildMaskOn(Index) const { return false; } // leaf nodes have no children
729 bool isChildMaskOff(Index) const { return true; }
730 bool isChildMaskOff() const { return true; }
731protected:
732 void setValueMask(Index n, bool on) { mValueMask.set(n, on); }
733 void setValueMaskOn(Index n) { mValueMask.setOn(n); }
734 void setValueMaskOff(Index n) { mValueMask.setOff(n); }
735
736 /// Compute the origin of the leaf node that contains the voxel with the given coordinates.
737 static void evalNodeOrigin(Coord& xyz) { xyz &= ~(DIM - 1); }
738
739 /// Bitmask that determines which voxels are active
740 NodeMaskType mValueMask;
741 /// Bitmask representing the values of voxels
742 Buffer mBuffer;
743 /// Global grid index coordinates (x,y,z) of the local origin of this node
744 Coord mOrigin;
745 /// Transient data (not serialized)
746 Index32 mTransientData = 0;
747
748private:
749 /// @brief During topology-only construction, access is needed
750 /// to protected/private members of other template instances.
751 template<typename, Index> friend class LeafNode;
752
753 friend struct ValueIter<MaskOnIter, LeafNode, bool>;
754 friend struct ValueIter<MaskOffIter, LeafNode, bool>;
755 friend struct ValueIter<MaskDenseIter, LeafNode, bool>;
756 friend struct ValueIter<MaskOnIter, const LeafNode, bool>;
757 friend struct ValueIter<MaskOffIter, const LeafNode, bool>;
758 friend struct ValueIter<MaskDenseIter, const LeafNode, bool>;
759
760 //@{
761 /// Allow iterators to call mask accessor methods (see below).
762 /// @todo Make mask accessors public?
763 friend class IteratorBase<MaskOnIter, LeafNode>;
764 friend class IteratorBase<MaskOffIter, LeafNode>;
765 friend class IteratorBase<MaskDenseIter, LeafNode>;
766 //@}
767
768}; // class LeafNode<bool>
769
770
771////////////////////////////////////////
772
773/// @cond OPENVDB_DOCS_INTERNAL
774
775template<Index Log2Dim>
776inline
777LeafNode<bool, Log2Dim>::LeafNode()
778 : mOrigin(0, 0, 0)
779{
780}
781
782
783template<Index Log2Dim>
784inline
785LeafNode<bool, Log2Dim>::LeafNode(const Coord& xyz, bool value, bool active)
786 : mValueMask(active)
787 , mBuffer(value)
788 , mOrigin(xyz & (~(DIM - 1)))
789{
790}
791
792
793template<Index Log2Dim>
794inline
795LeafNode<bool, Log2Dim>::LeafNode(PartialCreate, const Coord& xyz, bool value, bool active)
796 : mValueMask(active)
797 , mBuffer(value)
798 , mOrigin(xyz & (~(DIM - 1)))
799{
800 /// @todo For now, this is identical to the non-PartialCreate constructor.
801 /// Consider modifying the Buffer class to allow it to be constructed
802 /// without allocating a bitmask.
803}
804
805
806template<Index Log2Dim>
807inline
809 : mValueMask(other.valueMask())
810 , mBuffer(other.mBuffer)
811 , mOrigin(other.mOrigin)
812 , mTransientData(other.mTransientData)
813{
814}
815
816
817// Copy-construct from a leaf node with the same configuration but a different ValueType.
818template<Index Log2Dim>
819template<typename ValueT>
820inline
822 : mValueMask(other.valueMask())
823 , mOrigin(other.origin())
824 , mTransientData(other.mTransientData)
825{
826 struct Local {
827 /// @todo Consider using a value conversion functor passed as an argument instead.
828 static inline bool convertValue(const ValueT& val) { return bool(val); }
829 };
830
831 for (Index i = 0; i < SIZE; ++i) {
832 mBuffer.setValue(i, Local::convertValue(other.mBuffer[i]));
833 }
834}
835
836
837template<Index Log2Dim>
838template<typename ValueT>
839inline
841 bool background, TopologyCopy)
842 : mValueMask(other.valueMask())
843 , mBuffer(background)
844 , mOrigin(other.origin())
845 , mTransientData(other.mTransientData)
846{
847}
848
849
850template<Index Log2Dim>
851inline
852LeafNode<bool, Log2Dim>::LeafNode(const Coord& xyz,
853 const NodeMaskType& mask,
854 const Buffer& buff,
855 const Index32 trans)
856 : mValueMask(mask)
857 , mBuffer(buff)
858 , mOrigin(xyz & (~(DIM - 1)))
859 , mTransientData(trans)
860{
861}
862
863template<Index Log2Dim>
864template<typename ValueT>
865inline
867 bool offValue, bool onValue, TopologyCopy)
868 : mValueMask(other.valueMask())
869 , mBuffer(offValue)
870 , mOrigin(other.origin())
871 , mTransientData(other.mTransientData)
872{
873 for (Index i = 0; i < SIZE; ++i) {
874 if (mValueMask.isOn(i)) {
875 mBuffer.setValue(i, onValue);
876 }
877 }
878}
879
880
881template<Index Log2Dim>
882inline
884{
885}
886
887
888////////////////////////////////////////
889
890
891template<Index Log2Dim>
892inline Index64
894{
895 // Use sizeof(*this) to capture alignment-related padding
896 return sizeof(*this);
897}
898
899
900template<Index Log2Dim>
901inline void
902LeafNode<bool, Log2Dim>::evalActiveBoundingBox(CoordBBox& bbox, bool visitVoxels) const
903{
904 CoordBBox this_bbox = this->getNodeBoundingBox();
905 if (bbox.isInside(this_bbox)) return;//this LeafNode is already enclosed in the bbox
906 if (ValueOnCIter iter = this->cbeginValueOn()) {//any active values?
907 if (visitVoxels) {//use voxel granularity?
908 this_bbox.reset();
909 for(; iter; ++iter) this_bbox.expand(this->offsetToLocalCoord(iter.pos()));
910 this_bbox.translate(this->origin());
911 }
912 bbox.expand(this_bbox);
913 }
914}
915
916
917template<Index Log2Dim>
918template<typename OtherType, Index OtherLog2Dim>
919inline bool
921{
922 OPENVDB_ASSERT(other);
923 return (Log2Dim == OtherLog2Dim && mValueMask == other->getValueMask());
924}
925
926
927template<Index Log2Dim>
928inline std::string
930{
931 std::ostringstream ostr;
932 ostr << "LeafNode @" << mOrigin << ": ";
933 for (Index32 n = 0; n < SIZE; ++n) ostr << (mValueMask.isOn(n) ? '#' : '.');
934 return ostr.str();
935}
936
937
938////////////////////////////////////////
939
940
941template<Index Log2Dim>
942inline Index
944{
945 OPENVDB_ASSERT((xyz[0] & (DIM-1u)) < DIM && (xyz[1] & (DIM-1u)) < DIM && (xyz[2] & (DIM-1u)) < DIM);
946 return ((xyz[0] & (DIM-1u)) << 2*Log2Dim)
947 + ((xyz[1] & (DIM-1u)) << Log2Dim)
948 + (xyz[2] & (DIM-1u));
949}
950
951
952template<Index Log2Dim>
953inline Coord
955{
956 OPENVDB_ASSERT(n < (1 << 3*Log2Dim));
957 Coord xyz;
958 xyz.setX(n >> 2*Log2Dim);
959 n &= ((1 << 2*Log2Dim) - 1);
960 xyz.setY(n >> Log2Dim);
961 xyz.setZ(n & ((1 << Log2Dim) - 1));
962 return xyz;
963}
964
965
966template<Index Log2Dim>
967inline Coord
969{
970 return (this->offsetToLocalCoord(n) + this->origin());
971}
972
973
974////////////////////////////////////////
975
976
977#if OPENVDB_ABI_VERSION_NUMBER < 14
978
979template<Index Log2Dim>
980inline void
981LeafNode<bool, Log2Dim>::readTopology(std::istream& is, bool /*fromHalf*/)
982{
983 mValueMask.load(is);
984}
985
986
987template<Index Log2Dim>
988inline void
989LeafNode<bool, Log2Dim>::writeTopology(std::ostream& os, bool /*toHalf*/) const
990{
991 mValueMask.save(os);
992}
993
994
995template<Index Log2Dim>
996inline void
997LeafNode<bool, Log2Dim>::readBuffers(std::istream& is, const CoordBBox& clipBBox, bool fromHalf)
998{
999 // Boolean LeafNodes don't currently implement lazy loading.
1000 // Instead, load the full buffer, then clip it.
1001
1002 this->readBuffers(is, fromHalf);
1003
1004 // Get this tree's background value.
1005 bool background = false;
1006 if (const void* bgPtr = io::getGridBackgroundValuePtr(is)) {
1007 background = *static_cast<const bool*>(bgPtr);
1008 }
1009 this->clip(clipBBox, background);
1010}
1011
1012
1013template<Index Log2Dim>
1014inline void
1015LeafNode<bool, Log2Dim>::readBuffers(std::istream& is, bool /*fromHalf*/)
1016{
1018
1019 // Read in the value mask.
1020 mValueMask.load(is);
1021 // Read in the origin.
1022 is.read(reinterpret_cast<char*>(&mOrigin), sizeof(Coord::ValueType) * 3);
1023
1024 // Read in the mask for the voxel values.
1025 mBuffer.mData.load(is);
1026}
1027
1028
1029template<Index Log2Dim>
1030inline void
1031LeafNode<bool, Log2Dim>::writeBuffers(std::ostream& os, bool /*toHalf*/) const
1032{
1033 // Write out the value mask.
1034 mValueMask.save(os);
1035 // Write out the origin.
1036 os.write(reinterpret_cast<const char*>(&mOrigin), sizeof(Coord::ValueType) * 3);
1037 // Write out the voxel values.
1038 mBuffer.mData.save(os);
1039}
1040
1041#endif // OPENVDB_ABI_VERSION_NUMBER < 14
1042
1043
1044////////////////////////////////////////
1045
1046
1047template<Index Log2Dim>
1048inline bool
1050{
1051 return mOrigin == other.mOrigin &&
1052 mValueMask == other.valueMask() &&
1053 mBuffer == other.mBuffer;
1054}
1055
1056
1057template<Index Log2Dim>
1058inline bool
1060{
1061 return !(this->operator==(other));
1062}
1063
1064
1065////////////////////////////////////////
1066
1067template<Index Log2Dim>
1068inline bool
1069LeafNode<bool, Log2Dim>::isConstant(bool& constValue, bool& state, bool tolerance) const
1070{
1071 if (!mValueMask.isConstant(state)) return false;
1072
1073 // Note: if tolerance is true (i.e., 1), then all boolean values compare equal.
1074 if (!tolerance && !(mBuffer.mData.isOn() || mBuffer.mData.isOff())) return false;
1075
1076 constValue = mBuffer.mData.isOn();
1077 return true;
1078}
1079
1080////////////////////////////////////////
1081
1082template<Index Log2Dim>
1083inline bool
1085{
1086 const Index countTrue = mBuffer.mData.countOn();
1087 return countTrue > (NUM_VALUES >> 1);
1088}
1089
1090template<Index Log2Dim>
1091inline Index
1092LeafNode<bool, Log2Dim>::medianOn(bool& state) const
1093{
1094 const NodeMaskType tmp = mBuffer.mData & mValueMask;//both true and active
1095 const Index countTrueOn = tmp.countOn(), countOn = mValueMask.countOn();
1096 state = countTrueOn > (NUM_VALUES >> 1);
1097 return countOn;
1098}
1099
1100template<Index Log2Dim>
1101inline Index
1102LeafNode<bool, Log2Dim>::medianOff(bool& state) const
1103{
1104 const NodeMaskType tmp = mBuffer.mData & (!mValueMask);//both true and inactive
1105 const Index countTrueOff = tmp.countOn(), countOff = mValueMask.countOff();
1106 state = countTrueOff > (NUM_VALUES >> 1);
1107 return countOff;
1108}
1109
1110////////////////////////////////////////
1111
1112
1113template<Index Log2Dim>
1114inline void
1115LeafNode<bool, Log2Dim>::addTile(Index /*level*/, const Coord& xyz, bool val, bool active)
1116{
1117 this->addTile(this->coordToOffset(xyz), val, active);
1118}
1119
1120template<Index Log2Dim>
1121inline void
1122LeafNode<bool, Log2Dim>::addTile(Index offset, bool val, bool active)
1123{
1124 OPENVDB_ASSERT(offset < SIZE);
1125 this->setValueOnly(offset, val);
1126 this->setActiveState(offset, active);
1127}
1128
1129template<Index Log2Dim>
1130template<typename AccessorT>
1131inline void
1132LeafNode<bool, Log2Dim>::addTileAndCache(Index level, const Coord& xyz,
1133 bool val, bool active, AccessorT&)
1134{
1135 this->addTile(level, xyz, val, active);
1136}
1137
1138
1139////////////////////////////////////////
1140
1141
1142template<Index Log2Dim>
1143inline const bool&
1144LeafNode<bool, Log2Dim>::getValue(const Coord& xyz) const
1145{
1146 // This *CANNOT* use operator ? because Visual C++
1147 if (mBuffer.mData.isOn(this->coordToOffset(xyz))) return Buffer::sOn; else return Buffer::sOff;
1148}
1149
1150
1151template<Index Log2Dim>
1152inline const bool&
1154{
1155 OPENVDB_ASSERT(offset < SIZE);
1156 // This *CANNOT* use operator ? for Windows
1157 if (mBuffer.mData.isOn(offset)) return Buffer::sOn; else return Buffer::sOff;
1158}
1159
1160
1161template<Index Log2Dim>
1162inline bool
1163LeafNode<bool, Log2Dim>::probeValue(const Coord& xyz, bool& val) const
1164{
1165 return this->probeValue(this->coordToOffset(xyz), val);
1166}
1167
1168template<Index Log2Dim>
1169inline bool
1170LeafNode<bool, Log2Dim>::probeValue(Index offset, bool& val) const
1171{
1172 OPENVDB_ASSERT(offset < SIZE);
1173 val = mBuffer.mData.isOn(offset);
1174 return mValueMask.isOn(offset);
1175}
1176
1177template<Index Log2Dim>
1178inline void
1179LeafNode<bool, Log2Dim>::setValueOn(const Coord& xyz, bool val)
1180{
1181 this->setValueOn(this->coordToOffset(xyz), val);
1182}
1183
1184
1185template<Index Log2Dim>
1186inline void
1188{
1189 OPENVDB_ASSERT(offset < SIZE);
1190 mValueMask.setOn(offset);
1191 mBuffer.mData.set(offset, val);
1192}
1193
1194
1195template<Index Log2Dim>
1196inline void
1197LeafNode<bool, Log2Dim>::setValueOnly(const Coord& xyz, bool val)
1198{
1199 this->setValueOnly(this->coordToOffset(xyz), val);
1200}
1201
1202
1203template<Index Log2Dim>
1204inline void
1205LeafNode<bool, Log2Dim>::setActiveState(const Coord& xyz, bool on)
1206{
1207 mValueMask.set(this->coordToOffset(xyz), on);
1208}
1209
1210
1211template<Index Log2Dim>
1212inline void
1213LeafNode<bool, Log2Dim>::setValueOff(const Coord& xyz, bool val)
1214{
1215 this->setValueOff(this->coordToOffset(xyz), val);
1216}
1217
1218
1219template<Index Log2Dim>
1220inline void
1222{
1223 OPENVDB_ASSERT(offset < SIZE);
1224 mValueMask.setOff(offset);
1225 mBuffer.mData.set(offset, val);
1226}
1227
1228
1229template<Index Log2Dim>
1230template<typename ModifyOp>
1231inline void
1232LeafNode<bool, Log2Dim>::modifyValue(Index offset, const ModifyOp& op)
1233{
1234 bool val = mBuffer.mData.isOn(offset);
1235 op(val);
1236 mBuffer.mData.set(offset, val);
1237 mValueMask.setOn(offset);
1238}
1239
1240
1241template<Index Log2Dim>
1242template<typename ModifyOp>
1243inline void
1244LeafNode<bool, Log2Dim>::modifyValue(const Coord& xyz, const ModifyOp& op)
1245{
1246 this->modifyValue(this->coordToOffset(xyz), op);
1247}
1248
1249
1250template<Index Log2Dim>
1251template<typename ModifyOp>
1252inline void
1253LeafNode<bool, Log2Dim>::modifyValueAndActiveState(const Coord& xyz, const ModifyOp& op)
1254{
1255 const Index offset = this->coordToOffset(xyz);
1256 bool val = mBuffer.mData.isOn(offset), state = mValueMask.isOn(offset);
1257 op(val, state);
1258 mBuffer.mData.set(offset, val);
1259 mValueMask.set(offset, state);
1260}
1261
1262
1263////////////////////////////////////////
1264
1265
1266template<Index Log2Dim>
1267inline void
1268LeafNode<bool, Log2Dim>::resetBackground(bool oldBackground, bool newBackground)
1269{
1270 if (newBackground != oldBackground) {
1271 // Flip mBuffer's background bits and zero its foreground bits.
1272 NodeMaskType bgMask = !(mBuffer.mData | mValueMask);
1273 // Overwrite mBuffer's background bits, leaving its foreground bits intact.
1274 mBuffer.mData = (mBuffer.mData & mValueMask) | bgMask;
1275 }
1276}
1277
1278
1279////////////////////////////////////////
1280
1281
1282template<Index Log2Dim>
1283template<MergePolicy Policy>
1284inline void
1285LeafNode<bool, Log2Dim>::merge(const LeafNode& other, bool /*bg*/, bool /*otherBG*/)
1286{
1288 if (Policy == MERGE_NODES) return;
1289 for (typename NodeMaskType::OnIterator iter = other.valueMask().beginOn(); iter; ++iter) {
1290 const Index n = iter.pos();
1291 if (mValueMask.isOff(n)) {
1292 mBuffer.mData.set(n, other.mBuffer.mData.isOn(n));
1293 mValueMask.setOn(n);
1294 }
1295 }
1297}
1298
1299template<Index Log2Dim>
1300template<MergePolicy Policy>
1301inline void
1302LeafNode<bool, Log2Dim>::merge(bool tileValue, bool tileActive)
1303{
1305 if (Policy != MERGE_ACTIVE_STATES_AND_NODES) return;
1306 if (!tileActive) return;
1307 // Replace all inactive values with the active tile value.
1308 if (tileValue) mBuffer.mData |= !mValueMask; // -0=>1, +0=>0, -1=>1, +1=>1 (-,+ = off,on)
1309 else mBuffer.mData &= mValueMask; // -0=>0, +0=>0, -1=>0, +1=>1
1310 mValueMask.setOn();
1312}
1313
1314
1315////////////////////////////////////////
1316
1317
1318template<Index Log2Dim>
1319template<typename OtherType>
1320inline void
1322{
1323 mValueMask |= other.valueMask();
1324}
1325
1326
1327template<Index Log2Dim>
1328template<typename OtherType>
1329inline void
1331 const bool&)
1332{
1333 mValueMask &= other.valueMask();
1334}
1335
1336
1337template<Index Log2Dim>
1338template<typename OtherType>
1339inline void
1341 const bool&)
1342{
1343 mValueMask &= !other.valueMask();
1344}
1345
1346
1347////////////////////////////////////////
1348
1349
1350template<Index Log2Dim>
1351inline void
1352LeafNode<bool, Log2Dim>::clip(const CoordBBox& clipBBox, bool background)
1353{
1354 CoordBBox nodeBBox = this->getNodeBoundingBox();
1355 if (!clipBBox.hasOverlap(nodeBBox)) {
1356 // This node lies completely outside the clipping region. Fill it with background tiles.
1357 this->fill(nodeBBox, background, /*active=*/false);
1358 } else if (clipBBox.isInside(nodeBBox)) {
1359 // This node lies completely inside the clipping region. Leave it intact.
1360 return;
1361 }
1362
1363 // This node isn't completely contained inside the clipping region.
1364 // Set any voxels that lie outside the region to the background value.
1365
1366 // Construct a boolean mask that is on inside the clipping region and off outside it.
1367 NodeMaskType mask;
1368 nodeBBox.intersect(clipBBox);
1369 Coord xyz;
1370 int &x = xyz.x(), &y = xyz.y(), &z = xyz.z();
1371 for (x = nodeBBox.min().x(); x <= nodeBBox.max().x(); ++x) {
1372 for (y = nodeBBox.min().y(); y <= nodeBBox.max().y(); ++y) {
1373 for (z = nodeBBox.min().z(); z <= nodeBBox.max().z(); ++z) {
1374 mask.setOn(static_cast<Index32>(this->coordToOffset(xyz)));
1375 }
1376 }
1377 }
1378
1379 // Set voxels that lie in the inactive region of the mask (i.e., outside
1380 // the clipping region) to the background value.
1381 for (MaskOffIter maskIter = mask.beginOff(); maskIter; ++maskIter) {
1382 this->setValueOff(maskIter.pos(), background);
1383 }
1384}
1385
1386
1387////////////////////////////////////////
1388
1389
1390template<Index Log2Dim>
1391inline void
1392LeafNode<bool, Log2Dim>::fill(const CoordBBox& bbox, bool value, bool active)
1393{
1394 auto clippedBBox = this->getNodeBoundingBox();
1395 clippedBBox.intersect(bbox);
1396 if (!clippedBBox) return;
1397
1398 for (Int32 x = clippedBBox.min().x(); x <= clippedBBox.max().x(); ++x) {
1399 const Index offsetX = (x & (DIM-1u))<<2*Log2Dim;
1400 for (Int32 y = clippedBBox.min().y(); y <= clippedBBox.max().y(); ++y) {
1401 const Index offsetXY = offsetX + ((y & (DIM-1u))<< Log2Dim);
1402 for (Int32 z = clippedBBox.min().z(); z <= clippedBBox.max().z(); ++z) {
1403 const Index offset = offsetXY + (z & (DIM-1u));
1404 mValueMask.set(offset, active);
1405 mBuffer.mData.set(offset, value);
1406 }
1407 }
1408 }
1409}
1410
1411template<Index Log2Dim>
1412inline void
1413LeafNode<bool, Log2Dim>::fill(const bool& value)
1414{
1415 mBuffer.fill(value);
1416}
1417
1418template<Index Log2Dim>
1419inline void
1420LeafNode<bool, Log2Dim>::fill(const bool& value, bool active)
1421{
1422 mBuffer.fill(value);
1423 mValueMask.set(active);
1424}
1425
1426
1427////////////////////////////////////////
1428
1429
1430template<Index Log2Dim>
1431template<typename DenseT>
1432inline void
1433LeafNode<bool, Log2Dim>::copyToDense(const CoordBBox& bbox, DenseT& dense) const
1434{
1435 using DenseValueType = typename DenseT::ValueType;
1436
1437 const size_t xStride = dense.xStride(), yStride = dense.yStride(), zStride = dense.zStride();
1438 const Coord& min = dense.bbox().min();
1439 DenseValueType* t0 = dense.data() + zStride * (bbox.min()[2] - min[2]); // target array
1440 const Int32 n0 = bbox.min()[2] & (DIM-1u);
1441 for (Int32 x = bbox.min()[0], ex = bbox.max()[0] + 1; x < ex; ++x) {
1442 DenseValueType* t1 = t0 + xStride * (x - min[0]);
1443 const Int32 n1 = n0 + ((x & (DIM-1u)) << 2*LOG2DIM);
1444 for (Int32 y = bbox.min()[1], ey = bbox.max()[1] + 1; y < ey; ++y) {
1445 DenseValueType* t2 = t1 + yStride * (y - min[1]);
1446 Int32 n2 = n1 + ((y & (DIM-1u)) << LOG2DIM);
1447 for (Int32 z = bbox.min()[2], ez = bbox.max()[2] + 1; z < ez; ++z, t2 += zStride) {
1448 *t2 = DenseValueType(mBuffer.mData.isOn(n2++));
1449 }
1450 }
1451 }
1452}
1453
1454
1455template<Index Log2Dim>
1456template<typename DenseT>
1457inline void
1458LeafNode<bool, Log2Dim>::copyFromDense(const CoordBBox& bbox, const DenseT& dense,
1459 bool background, bool tolerance)
1460{
1461 using DenseValueType = typename DenseT::ValueType;
1462 struct Local {
1463 inline static bool toBool(const DenseValueType& v) { return !math::isZero(v); }
1464 };
1465
1466 const size_t xStride = dense.xStride(), yStride = dense.yStride(), zStride = dense.zStride();
1467 const Coord& min = dense.bbox().min();
1468 const DenseValueType* s0 = dense.data() + zStride * (bbox.min()[2] - min[2]); // source
1469 const Int32 n0 = bbox.min()[2] & (DIM-1u);
1470 for (Int32 x = bbox.min()[0], ex = bbox.max()[0] + 1; x < ex; ++x) {
1471 const DenseValueType* s1 = s0 + xStride * (x - min[0]);
1472 const Int32 n1 = n0 + ((x & (DIM-1u)) << 2*LOG2DIM);
1473 for (Int32 y = bbox.min()[1], ey = bbox.max()[1] + 1; y < ey; ++y) {
1474 const DenseValueType* s2 = s1 + yStride * (y - min[1]);
1475 Int32 n2 = n1 + ((y & (DIM-1u)) << LOG2DIM);
1476 for (Int32 z = bbox.min()[2], ez = bbox.max()[2]+1; z < ez; ++z, ++n2, s2 += zStride) {
1477 // Note: if tolerance is true (i.e., 1), then all boolean values compare equal.
1478 if (tolerance || (background == Local::toBool(*s2))) {
1479 mValueMask.setOff(n2);
1480 mBuffer.mData.set(n2, background);
1481 } else {
1482 mValueMask.setOn(n2);
1483 mBuffer.mData.set(n2, Local::toBool(*s2));
1484 }
1485 }
1486 }
1487 }
1488}
1489
1490
1491////////////////////////////////////////
1492
1493
1494template<Index Log2Dim>
1495template<typename CombineOp>
1496inline void
1497LeafNode<bool, Log2Dim>::combine(const LeafNode& other, CombineOp& op)
1498{
1499 CombineArgs<bool> args;
1500 for (Index i = 0; i < SIZE; ++i) {
1501 bool result = false, aVal = mBuffer.mData.isOn(i), bVal = other.mBuffer.mData.isOn(i);
1502 op(args.setARef(aVal)
1503 .setAIsActive(mValueMask.isOn(i))
1504 .setBRef(bVal)
1505 .setBIsActive(other.valueMask().isOn(i))
1506 .setResultRef(result));
1507 mValueMask.set(i, args.resultIsActive());
1508 mBuffer.mData.set(i, result);
1509 }
1510}
1511
1512
1513template<Index Log2Dim>
1514template<typename CombineOp>
1515inline void
1516LeafNode<bool, Log2Dim>::combine(bool value, bool valueIsActive, CombineOp& op)
1517{
1518 CombineArgs<bool> args;
1519 args.setBRef(value).setBIsActive(valueIsActive);
1520 for (Index i = 0; i < SIZE; ++i) {
1521 bool result = false, aVal = mBuffer.mData.isOn(i);
1522 op(args.setARef(aVal)
1523 .setAIsActive(mValueMask.isOn(i))
1524 .setResultRef(result));
1525 mValueMask.set(i, args.resultIsActive());
1526 mBuffer.mData.set(i, result);
1527 }
1528}
1529
1530
1531////////////////////////////////////////
1532
1533
1534template<Index Log2Dim>
1535template<typename CombineOp, typename OtherType>
1536inline void
1537LeafNode<bool, Log2Dim>::combine2(const LeafNode& other, const OtherType& value,
1538 bool valueIsActive, CombineOp& op)
1539{
1540 CombineArgs<bool, OtherType> args;
1541 args.setBRef(value).setBIsActive(valueIsActive);
1542 for (Index i = 0; i < SIZE; ++i) {
1543 bool result = false, aVal = other.mBuffer.mData.isOn(i);
1544 op(args.setARef(aVal)
1545 .setAIsActive(other.valueMask().isOn(i))
1546 .setResultRef(result));
1547 mValueMask.set(i, args.resultIsActive());
1548 mBuffer.mData.set(i, result);
1549 }
1550}
1551
1552
1553template<Index Log2Dim>
1554template<typename CombineOp, typename OtherNodeT>
1555inline void
1556LeafNode<bool, Log2Dim>::combine2(bool value, const OtherNodeT& other,
1557 bool valueIsActive, CombineOp& op)
1558{
1559 CombineArgs<bool, typename OtherNodeT::ValueType> args;
1560 args.setARef(value).setAIsActive(valueIsActive);
1561 for (Index i = 0; i < SIZE; ++i) {
1562 bool result = false, bVal = other.mBuffer.mData.isOn(i);
1563 op(args.setBRef(bVal)
1564 .setBIsActive(other.valueMask().isOn(i))
1565 .setResultRef(result));
1566 mValueMask.set(i, args.resultIsActive());
1567 mBuffer.mData.set(i, result);
1568 }
1569}
1570
1571
1572template<Index Log2Dim>
1573template<typename CombineOp, typename OtherNodeT>
1574inline void
1575LeafNode<bool, Log2Dim>::combine2(const LeafNode& b0, const OtherNodeT& b1, CombineOp& op)
1576{
1577 CombineArgs<bool, typename OtherNodeT::ValueType> args;
1578 for (Index i = 0; i < SIZE; ++i) {
1579 // Default behavior: output voxel is active if either input voxel is active.
1580 mValueMask.set(i, b0.valueMask().isOn(i) || b1.valueMask().isOn(i));
1581
1582 bool result = false, b0Val = b0.mBuffer.mData.isOn(i), b1Val = b1.mBuffer.mData.isOn(i);
1583 op(args.setARef(b0Val)
1584 .setAIsActive(b0.valueMask().isOn(i))
1585 .setBRef(b1Val)
1586 .setBIsActive(b1.valueMask().isOn(i))
1587 .setResultRef(result));
1588 mValueMask.set(i, args.resultIsActive());
1589 mBuffer.mData.set(i, result);
1590 }
1591}
1592
1593/// @endcond
1594
1595
1596} // namespace tree
1597} // namespace OPENVDB_VERSION_NAME
1598} // namespace openvdb
1599
1600#endif // OPENVDB_TREE_LEAF_NODE_BOOL_HAS_BEEN_INCLUDED
#define OPENVDB_ASSERT(X)
Definition Assert.h:41
#define OPENVDB_NO_UNREACHABLE_CODE_WARNING_END
Definition Platform.h:151
#define OPENVDB_NO_UNREACHABLE_CODE_WARNING_BEGIN
Definition Platform.h:150
Int32 ValueType
Definition Coord.h:33
Tag dispatch class that distinguishes constructors during file input.
Definition Types.h:760
Tag dispatch class that distinguishes topology copy constructors from deep copy constructors.
Definition Types.h:754
Signed (x, y, z) 32-bit integer coordinates.
Definition Coord.h:26
Templated block class to hold specific data types and a fixed number of values determined by Log2Dim....
Definition LeafNode.h:39
static Coord offsetToLocalCoord(Index n)
Return the local coordinates for a linear table offset, where offset 0 has coordinates (0,...
Definition LeafNode.h:1086
void copyToDense(const CoordBBox &bbox, DenseT &dense) const
Copy into a dense grid the values of the voxels that lie within a given bounding box.
Definition LeafNode.h:1270
bool operator!=(const LeafNode &other) const
Definition LeafNode.h:204
void copyFromDense(const CoordBBox &bbox, const DenseT &dense, const ValueType &background, const ValueType &tolerance)
Copy from a dense grid into this node the values of the voxels that lie within a given bounding box.
Definition LeafNode.h:1295
const ValueType & getValue(const Coord &xyz) const
Return the value of the voxel at the given coordinates.
Definition LeafNode.h:1111
void setValueOnly(const Coord &xyz, const ValueType &val)
Set the value of the voxel at the given coordinates but don't change its active state.
Definition LeafNode.h:1169
void topologyDifference(const LeafNode< OtherType, Log2Dim > &other, const ValueType &)
Difference this node's set of active values with the active values of the other node,...
Definition LeafNode.h:1727
Index medianOff(ValueType &value, ValueType *tmp=nullptr) const
Computes the median value of all the inactive voxels in this node.
Definition LeafNode.h:1580
ValueType medianAll(ValueType *tmp=nullptr) const
Computes the median value of all the active AND inactive voxels in this node.
Definition LeafNode.h:1532
~LeafNode()
Destructor.
Definition LeafNode.h:1056
Index medianOn(ValueType &value, ValueType *tmp=nullptr) const
Computes the median value of all the active voxels in this node.
Definition LeafNode.h:1553
void addTile(Index level, const Coord &, const ValueType &, bool)
Definition LeafNode.h:1610
void resetBackground(const ValueType &oldBackground, const ValueType &newBackground)
Replace inactive occurrences of oldBackground with newBackground, and inactive occurrences of -oldBac...
Definition LeafNode.h:1639
void modifyValueAndActiveState(const Coord &xyz, const ModifyOp &op)
Apply a functor to the voxel at the given coordinates.
Definition LeafNode.h:489
void topologyIntersection(const LeafNode< OtherType, Log2Dim > &other, const ValueType &)
Intersect this node's set of active values with the active values of the other node,...
Definition LeafNode.h:1718
void clip(const CoordBBox &, const ValueType &background)
Set all voxels that lie outside the given axis-aligned box to the background.
Definition LeafNode.h:1187
void setActiveState(const Coord &xyz, bool on)
Set the active state of the voxel at the given coordinates but don't change its value.
Definition LeafNode.h:1161
void topologyUnion(const LeafNode< OtherType, Log2Dim > &other, const bool preserveTiles=false)
Union this node's set of active values with the active values of the other node, whose ValueType may ...
Definition LeafNode.h:1710
static Index coordToOffset(const Coord &xyz)
Return the linear table offset of the given global or local coordinates.
Definition LeafNode.h:1076
void setValueOff(const Coord &xyz)
Mark the voxel at the given coordinates as inactive but don't change its value.
Definition LeafNode.h:441
bool hasSameTopology(const LeafNode< OtherType, OtherLog2Dim > *other) const
Return true if the given node (which may have a different ValueType than this node) has the same acti...
Definition LeafNode.h:1488
void combine(const LeafNode &other, CombineOp &op)
Definition LeafNode.h:1751
void combine2(const LeafNode &other, const OtherType &, bool valueIsActive, CombineOp &)
Definition LeafNode.h:1791
void fill(const CoordBBox &bbox, const ValueType &, bool active=true)
Set all voxels within an axis-aligned box to the specified value and active state.
Definition LeafNode.h:1227
bool isConstant(ValueType &firstValue, bool &state, const ValueType &tolerance=zeroVal< ValueType >()) const
Definition LeafNode.h:1496
friend class LeafNode
Definition LeafNode.h:892
Coord offsetToGlobalCoord(Index n) const
Return the global coordinates for a linear table offset.
Definition LeafNode.h:1100
bool operator==(const LeafNode &other) const
Check for buffer, state and origin equivalence.
Definition LeafNode.h:1450
static const Index SIZE
Definition LeafNode.h:54
void evalActiveBoundingBox(CoordBBox &bbox, bool visitVoxels=true) const
Definition LeafNode.h:1470
void merge(const LeafNode &)
Definition LeafNode.h:1661
void setValueOn(const Coord &xyz)
Mark the voxel at the given coordinates as active but don't change its value.
Definition LeafNode.h:451
void addTileAndCache(Index, const Coord &, const ValueType &, bool, AccessorT &)
Definition LeafNode.h:1627
void modifyValue(Index offset, const ModifyOp &op)
Apply a functor to the value of the voxel at the given offset and mark the voxel as active.
Definition LeafNode.h:469
Index64 memUsage() const
Return the memory in bytes occupied by this node.
Definition LeafNode.h:1460
std::string str() const
Return a string representation of this node.
Definition LeafNode.h:1063
bool probeValue(const Coord &xyz, ValueType &val) const
Return true if the voxel at the given coordinates is active.
Definition LeafNode.h:1127
uint32_t countOn(uint64_t v)
Definition Util.h:699
math::BBox< Coord > CoordBBox
Definition Math.h:2838
void checkFormatVersion(std::ios_base &)
Throws an IoError if the file format version number is not supported.
const void * getGridBackgroundValuePtr(std::ios_base &)
Return a pointer to the background value of the grid currently being read from or written to the give...
bool operator==(const Vec3< T0 > &v0, const Vec3< T1 > &v1)
Equality operator, does exact floating point comparisons.
Definition Vec3.h:474
bool operator!=(const Vec3< T0 > &v0, const Vec3< T1 > &v1)
Inequality operator, does exact floating point comparisons.
Definition Vec3.h:482
const std::enable_if<!VecTraits< T >::IsVec, T >::type & min(const T &a, const T &b)
Definition Composite.h:106
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:569
void prune(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 nodes whose values are all the same...
Definition Prune.h:337
GridType::Ptr clip(const GridType &grid, const BBoxd &bbox, bool keepInterior=true)
Clip the given grid against a world-space bounding box and return a new grid containing the result.
Definition Clip.h:352
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:422
Index64 memUsage(const TreeT &tree, bool threaded=true)
Return the total amount of memory in bytes occupied by this tree.
Definition Count.h:481
Definition TreeIterator.h:30
Index32 Index
Definition Types.h:34
uint32_t Index32
Definition Types.h:32
int32_t Int32
Definition Types.h:36
uint64_t Index64
Definition Types.h:33
@ MERGE_NODES
Definition Types.h:579
@ MERGE_ACTIVE_STATES_AND_NODES
Definition Types.h:580
ValueType combine(const ValueType &v0, const ValueType &v1, const ValueType &v2, const openvdb::Vec3d &w)
Combine different value types.
Definition AttributeTransferUtil.h:141
Definition Exceptions.h:13
General-purpose arithmetic and comparison routines, most of which accept arbitrary value types (or at...
typename std::remove_const< ValueT >::type NonConstValueType
Definition Iterator.h:184
ChildIter(const MaskIterT &iter, NodeT *parent)
Definition LeafNodeBool.h:633
bool getItem(Index pos, void *&child, NonConstValueT &value) const
Definition LeafNodeBool.h:647
DenseIter(const MaskDenseIter &iter, NodeT *parent)
Definition LeafNodeBool.h:645
typename BaseT::NonConstValueType NonConstValueT
Definition LeafNodeBool.h:642
DenseIteratorBase< MaskDenseIter, DenseIter, NodeT, void, ValueT > BaseT
Definition LeafNodeBool.h:641
void unsetItem(Index pos, const ValueT &val) const
Definition LeafNodeBool.h:658
SameConfiguration<OtherNodeType>::value is true if and only if OtherNodeType is the type of a LeafNod...
Definition LeafNodeBool.h:56
static const bool value
Definition LeafNodeBool.h:57
ValueConverter<T>::Type is the type of a LeafNode having the same dimensions as this node but a diffe...
Definition LeafNodeBool.h:51
LeafNode< ValueType, Log2Dim > Type
Definition LeafNodeBool.h:51
void setItem(Index pos, bool value) const
Definition LeafNodeBool.h:615
void modifyValue(const ModifyOp &op) const
Definition LeafNodeBool.h:624
ValueIter(const MaskIterT &iter, NodeT *parent)
Definition LeafNodeBool.h:609
const bool & getValue() const
Definition LeafNodeBool.h:612
const bool & getItem(Index pos) const
Definition LeafNodeBool.h:611
void setValue(bool value) const
Definition LeafNodeBool.h:617
void modifyItem(Index n, const ModifyOp &op) const
Definition LeafNodeBool.h:621
SparseIteratorBase< MaskIterT, ValueIter, NodeT, ValueT > BaseT
Definition LeafNodeBool.h:606
static const bool value
Definition LeafNode.h:952
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition version.h.in:121
#define OPENVDB_USE_VERSION_NAMESPACE
Definition version.h.in:291