| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // Copyright Contributors to the OpenVDB Project | ||
| 2 | // SPDX-License-Identifier: MPL-2.0 | ||
| 3 | |||
| 4 | #ifndef OPENVDB_TREE_LEAFNODE_HAS_BEEN_INCLUDED | ||
| 5 | #define OPENVDB_TREE_LEAFNODE_HAS_BEEN_INCLUDED | ||
| 6 | |||
| 7 | #include <openvdb/Types.h> | ||
| 8 | #include <openvdb/util/NodeMasks.h> | ||
| 9 | #include <openvdb/io/Compression.h> // for io::readData(), etc. | ||
| 10 | #include "Iterator.h" | ||
| 11 | #include "LeafBuffer.h" | ||
| 12 | #include <algorithm> // for std::nth_element() | ||
| 13 | #include <iostream> | ||
| 14 | #include <memory> | ||
| 15 | #include <sstream> | ||
| 16 | #include <string> | ||
| 17 | #include <type_traits> | ||
| 18 | #include <vector> | ||
| 19 | |||
| 20 | |||
| 21 | class TestLeaf; | ||
| 22 | template<typename> class TestLeafIO; | ||
| 23 | |||
| 24 | namespace openvdb { | ||
| 25 | OPENVDB_USE_VERSION_NAMESPACE | ||
| 26 | namespace OPENVDB_VERSION_NAME { | ||
| 27 | namespace tree { | ||
| 28 | |||
| 29 | template<Index, typename> struct SameLeafConfig; // forward declaration | ||
| 30 | |||
| 31 | |||
| 32 | /// @brief Templated block class to hold specific data types and a fixed | ||
| 33 | /// number of values determined by Log2Dim. The actual coordinate | ||
| 34 | /// dimension of the block is 2^Log2Dim, i.e. Log2Dim=3 corresponds to | ||
| 35 | /// a LeafNode that spans a 8^3 block. | ||
| 36 | template<typename T, Index Log2Dim> | ||
| 37 | 16 | class LeafNode | |
| 38 | { | ||
| 39 | public: | ||
| 40 | using BuildType = T; | ||
| 41 | using ValueType = T; | ||
| 42 | using Buffer = LeafBuffer<ValueType, Log2Dim>; | ||
| 43 | using LeafNodeType = LeafNode<ValueType, Log2Dim>; | ||
| 44 | using NodeMaskType = util::NodeMask<Log2Dim>; | ||
| 45 | using Ptr = SharedPtr<LeafNode>; | ||
| 46 | |||
| 47 | static const Index | ||
| 48 | LOG2DIM = Log2Dim, // needed by parent nodes | ||
| 49 | TOTAL = Log2Dim, // needed by parent nodes | ||
| 50 | DIM = 1 << TOTAL, // dimension along one coordinate direction | ||
| 51 | NUM_VALUES = 1 << 3 * Log2Dim, | ||
| 52 | NUM_VOXELS = NUM_VALUES, // total number of voxels represented by this node | ||
| 53 | SIZE = NUM_VALUES, | ||
| 54 | LEVEL = 0; // level 0 = leaf | ||
| 55 | |||
| 56 | /// @brief ValueConverter<T>::Type is the type of a LeafNode having the same | ||
| 57 | /// dimensions as this node but a different value type, T. | ||
| 58 | template<typename OtherValueType> | ||
| 59 | struct ValueConverter { using Type = LeafNode<OtherValueType, Log2Dim>; }; | ||
| 60 | |||
| 61 | /// @brief SameConfiguration<OtherNodeType>::value is @c true if and only if | ||
| 62 | /// OtherNodeType is the type of a LeafNode with the same dimensions as this node. | ||
| 63 | template<typename OtherNodeType> | ||
| 64 | struct SameConfiguration { | ||
| 65 | static const bool value = SameLeafConfig<LOG2DIM, OtherNodeType>::value; | ||
| 66 | }; | ||
| 67 | |||
| 68 | |||
| 69 | /// Default constructor | ||
| 70 | LeafNode(); | ||
| 71 | |||
| 72 | /// @brief Constructor | ||
| 73 | /// @param coords the grid index coordinates of a voxel | ||
| 74 | /// @param value a value with which to fill the buffer | ||
| 75 | /// @param active the active state to which to initialize all voxels | ||
| 76 | explicit LeafNode(const Coord& coords, | ||
| 77 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | const ValueType& value = zeroVal<ValueType>(), |
| 78 | bool active = false); | ||
| 79 | |||
| 80 | /// @brief "Partial creation" constructor used during file input | ||
| 81 | /// @param coords the grid index coordinates of a voxel | ||
| 82 | /// @param value a value with which to fill the buffer | ||
| 83 | /// @param active the active state to which to initialize all voxels | ||
| 84 | /// @details This constructor does not allocate memory for voxel values. | ||
| 85 | LeafNode(PartialCreate, | ||
| 86 | const Coord& coords, | ||
| 87 | const ValueType& value = zeroVal<ValueType>(), | ||
| 88 | bool active = false); | ||
| 89 | |||
| 90 | /// Deep copy constructor | ||
| 91 | LeafNode(const LeafNode&); | ||
| 92 | |||
| 93 | /// Deep assignment operator | ||
| 94 | LeafNode& operator=(const LeafNode&) = default; | ||
| 95 | |||
| 96 | /// Value conversion copy constructor | ||
| 97 | template<typename OtherValueType> | ||
| 98 | explicit LeafNode(const LeafNode<OtherValueType, Log2Dim>& other); | ||
| 99 | |||
| 100 | /// Topology copy constructor | ||
| 101 | template<typename OtherValueType> | ||
| 102 | LeafNode(const LeafNode<OtherValueType, Log2Dim>& other, | ||
| 103 | const ValueType& offValue, const ValueType& onValue, TopologyCopy); | ||
| 104 | |||
| 105 | /// Topology copy constructor | ||
| 106 | template<typename OtherValueType> | ||
| 107 | LeafNode(const LeafNode<OtherValueType, Log2Dim>& other, | ||
| 108 | const ValueType& background, TopologyCopy); | ||
| 109 | |||
| 110 | /// Destructor. | ||
| 111 | ~LeafNode(); | ||
| 112 | |||
| 113 | // | ||
| 114 | // Statistics | ||
| 115 | // | ||
| 116 | /// Return log2 of the dimension of this LeafNode, e.g. 3 if dimensions are 8^3 | ||
| 117 | static Index log2dim() { return Log2Dim; } | ||
| 118 | /// Return the number of voxels in each coordinate dimension. | ||
| 119 | static Index dim() { return DIM; } | ||
| 120 | /// Return the total number of voxels represented by this LeafNode | ||
| 121 | static Index size() { return SIZE; } | ||
| 122 | /// Return the total number of voxels represented by this LeafNode | ||
| 123 | static Index numValues() { return SIZE; } | ||
| 124 | /// Return the level of this node, which by definition is zero for LeafNodes | ||
| 125 | static Index getLevel() { return LEVEL; } | ||
| 126 | /// Append the Log2Dim of this LeafNode to the specified vector | ||
| 127 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
18792 | static void getNodeLog2Dims(std::vector<Index>& dims) { dims.push_back(Log2Dim); } |
| 128 | /// Return the dimension of child nodes of this LeafNode, which is one for voxels. | ||
| 129 | static Index getChildDim() { return 1; } | ||
| 130 | /// Return the leaf count for this node, which is one. | ||
| 131 | static Index32 leafCount() { return 1; } | ||
| 132 | /// no-op | ||
| 133 | void nodeCount(std::vector<Index32> &) const {} | ||
| 134 | /// Return the non-leaf count for this node, which is zero. | ||
| 135 | static Index32 nonLeafCount() { return 0; } | ||
| 136 | /// Return the child count for this node, which is zero. | ||
| 137 | static Index32 childCount() { return 0; } | ||
| 138 | |||
| 139 | /// Return the number of voxels marked On. | ||
| 140 |
33/60✓ Branch 0 taken 11711 times.
✓ Branch 1 taken 52642 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 21370 times.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 3 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 times.
✓ Branch 10 taken 2 times.
✓ Branch 11 taken 1 times.
✓ Branch 13 taken 2 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 2 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 2701 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 1 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 1 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 1 times.
✗ Branch 29 not taken.
✓ Branch 31 taken 1 times.
✗ Branch 32 not taken.
✓ Branch 34 taken 1 times.
✗ Branch 35 not taken.
✓ Branch 37 taken 1 times.
✗ Branch 38 not taken.
✓ Branch 40 taken 1 times.
✗ Branch 41 not taken.
✓ Branch 43 taken 1 times.
✗ Branch 44 not taken.
✓ Branch 46 taken 1 times.
✗ Branch 47 not taken.
✓ Branch 49 taken 1 times.
✗ Branch 50 not taken.
✓ Branch 52 taken 1 times.
✗ Branch 53 not taken.
✓ Branch 55 taken 1 times.
✗ Branch 56 not taken.
✓ Branch 58 taken 1 times.
✗ Branch 59 not taken.
✓ Branch 61 taken 1 times.
✗ Branch 62 not taken.
✓ Branch 64 taken 1 times.
✗ Branch 65 not taken.
✓ Branch 67 taken 1 times.
✗ Branch 68 not taken.
✓ Branch 70 taken 1 times.
✗ Branch 71 not taken.
✓ Branch 73 taken 1 times.
✗ Branch 74 not taken.
✓ Branch 76 taken 1 times.
✗ Branch 77 not taken.
✓ Branch 79 taken 1 times.
✗ Branch 80 not taken.
✓ Branch 82 taken 1 times.
✗ Branch 83 not taken.
|
112566 | Index64 onVoxelCount() const { return mValueMask.countOn(); } |
| 141 | /// Return the number of voxels marked Off. | ||
| 142 |
1/2✓ Branch 1 taken 20520 times.
✗ Branch 2 not taken.
|
41100 | Index64 offVoxelCount() const { return mValueMask.countOff(); } |
| 143 | Index64 onLeafVoxelCount() const { return onVoxelCount(); } | ||
| 144 | Index64 offLeafVoxelCount() const { return offVoxelCount(); } | ||
| 145 | static Index64 onTileCount() { return 0; } | ||
| 146 | static Index64 offTileCount() { return 0; } | ||
| 147 | /// Return @c true if this node has no active voxels. | ||
| 148 | bool isEmpty() const { return mValueMask.isOff(); } | ||
| 149 | /// Return @c true if this node contains only active voxels. | ||
| 150 | bool isDense() const { return mValueMask.isOn(); } | ||
| 151 | /// Return @c true if memory for this node's buffer has been allocated. | ||
| 152 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
|
8 | bool isAllocated() const { return !mBuffer.isOutOfCore() && !mBuffer.empty(); } |
| 153 | /// Allocate memory for this node's buffer if it has not already been allocated. | ||
| 154 | 106 | bool allocate() { return mBuffer.allocate(); } | |
| 155 | |||
| 156 | /// Return the memory in bytes occupied by this node. | ||
| 157 | Index64 memUsage() const; | ||
| 158 | Index64 memUsageIfLoaded() const; | ||
| 159 | |||
| 160 | /// Expand the given bounding box so that it includes this leaf node's active voxels. | ||
| 161 | /// If visitVoxels is false this LeafNode will be approximated as dense, i.e. with all | ||
| 162 | /// voxels active. Else the individual active voxels are visited to produce a tight bbox. | ||
| 163 | void evalActiveBoundingBox(CoordBBox& bbox, bool visitVoxels = true) const; | ||
| 164 | |||
| 165 | /// @brief Return the bounding box of this node, i.e., the full index space | ||
| 166 | /// spanned by this leaf node. | ||
| 167 | 1314416 | CoordBBox getNodeBoundingBox() const { return CoordBBox::createCube(mOrigin, DIM); } | |
| 168 | |||
| 169 | /// Set the grid index coordinates of this node's local origin. | ||
| 170 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
130719136 | void setOrigin(const Coord& origin) { mOrigin = origin; } |
| 171 | //@{ | ||
| 172 | /// Return the grid index coordinates of this node's local origin. | ||
| 173 |
19/79✓ Branch 1 taken 1419 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 11139 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1895 times.
✓ Branch 6 taken 62 times.
✓ Branch 7 taken 2 times.
✓ Branch 8 taken 4 times.
✓ Branch 9 taken 62 times.
✓ Branch 10 taken 4 times.
✓ Branch 11 taken 60 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 1430 times.
✓ Branch 15 taken 1 times.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✓ Branch 20 taken 9 times.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✓ Branch 26 taken 1 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 1 times.
✓ Branch 29 taken 5 times.
✓ Branch 30 taken 1 times.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✓ Branch 43 taken 45 times.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✗ Branch 46 not taken.
✗ Branch 47 not taken.
✗ Branch 48 not taken.
✗ Branch 49 not taken.
✗ Branch 50 not taken.
✗ Branch 51 not taken.
✗ Branch 52 not taken.
✗ Branch 53 not taken.
✗ Branch 54 not taken.
✗ Branch 55 not taken.
✗ Branch 56 not taken.
✗ Branch 57 not taken.
✗ Branch 58 not taken.
✗ Branch 59 not taken.
✗ Branch 60 not taken.
✗ Branch 61 not taken.
✗ Branch 62 not taken.
✗ Branch 63 not taken.
✗ Branch 64 not taken.
✗ Branch 65 not taken.
✗ Branch 66 not taken.
✗ Branch 67 not taken.
✗ Branch 68 not taken.
✗ Branch 69 not taken.
✗ Branch 70 not taken.
✗ Branch 71 not taken.
✗ Branch 72 not taken.
✗ Branch 73 not taken.
✗ Branch 74 not taken.
✗ Branch 75 not taken.
✗ Branch 76 not taken.
✗ Branch 77 not taken.
✗ Branch 78 not taken.
✗ Branch 79 not taken.
|
273381 | const Coord& origin() const { return mOrigin; } |
| 174 | void getOrigin(Coord& origin) const { origin = mOrigin; } | ||
| 175 | void getOrigin(Int32& x, Int32& y, Int32& z) const { mOrigin.asXYZ(x, y, z); } | ||
| 176 | //@} | ||
| 177 | |||
| 178 | /// Return the linear table offset of the given global or local coordinates. | ||
| 179 | static Index coordToOffset(const Coord& xyz); | ||
| 180 | /// @brief Return the local coordinates for a linear table offset, | ||
| 181 | /// where offset 0 has coordinates (0, 0, 0). | ||
| 182 | static Coord offsetToLocalCoord(Index n); | ||
| 183 | /// Return the global coordinates for a linear table offset. | ||
| 184 | Coord offsetToGlobalCoord(Index n) const; | ||
| 185 | |||
| 186 | #if OPENVDB_ABI_VERSION_NUMBER >= 9 | ||
| 187 | /// Return the transient data value. | ||
| 188 |
3/6✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
|
3 | Index32 transientData() const { return mTransientData; } |
| 189 | /// Set the transient data value. | ||
| 190 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | void setTransientData(Index32 transientData) { mTransientData = transientData; } |
| 191 | #endif | ||
| 192 | |||
| 193 | /// Return a string representation of this node. | ||
| 194 | std::string str() const; | ||
| 195 | |||
| 196 | /// @brief Return @c true if the given node (which may have a different @c ValueType | ||
| 197 | /// than this node) has the same active value topology as this node. | ||
| 198 | template<typename OtherType, Index OtherLog2Dim> | ||
| 199 | bool hasSameTopology(const LeafNode<OtherType, OtherLog2Dim>* other) const; | ||
| 200 | |||
| 201 | /// Check for buffer, state and origin equivalence. | ||
| 202 | bool operator==(const LeafNode& other) const; | ||
| 203 |
4/8✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 times.
|
2 | bool operator!=(const LeafNode& other) const { return !(other == *this); } |
| 204 | |||
| 205 | protected: | ||
| 206 | using MaskOnIterator = typename NodeMaskType::OnIterator; | ||
| 207 | using MaskOffIterator = typename NodeMaskType::OffIterator; | ||
| 208 | using MaskDenseIterator = typename NodeMaskType::DenseIterator; | ||
| 209 | |||
| 210 | // Type tags to disambiguate template instantiations | ||
| 211 | struct ValueOn {}; struct ValueOff {}; struct ValueAll {}; | ||
| 212 | struct ChildOn {}; struct ChildOff {}; struct ChildAll {}; | ||
| 213 | |||
| 214 | template<typename MaskIterT, typename NodeT, typename ValueT, typename TagT> | ||
| 215 | struct ValueIter: | ||
| 216 | // Derives from SparseIteratorBase, but can also be used as a dense iterator, | ||
| 217 | // if MaskIterT is a dense mask iterator type. | ||
| 218 | public SparseIteratorBase< | ||
| 219 | MaskIterT, ValueIter<MaskIterT, NodeT, ValueT, TagT>, NodeT, ValueT> | ||
| 220 | { | ||
| 221 | using BaseT = SparseIteratorBase<MaskIterT, ValueIter, NodeT, ValueT>; | ||
| 222 | |||
| 223 | ✗ | ValueIter() {} | |
| 224 | ValueIter(const MaskIterT& iter, NodeT* parent): BaseT(iter, parent) {} | ||
| 225 | |||
| 226 | 130791909 | ValueT& getItem(Index pos) const { return this->parent().getValue(pos); } | |
| 227 | 422721684 | ValueT& getValue() const { return this->parent().getValue(this->pos()); } | |
| 228 | |||
| 229 | // Note: setItem() can't be called on const iterators. | ||
| 230 | void setItem(Index pos, const ValueT& value) const | ||
| 231 | { | ||
| 232 | this->parent().setValueOnly(pos, value); | ||
| 233 | } | ||
| 234 | // Note: setValue() can't be called on const iterators. | ||
| 235 | 50653358 | void setValue(const ValueT& value) const | |
| 236 | { | ||
| 237 | 50653358 | this->parent().setValueOnly(this->pos(), value); | |
| 238 | 50653358 | } | |
| 239 | |||
| 240 | // Note: modifyItem() can't be called on const iterators. | ||
| 241 | template<typename ModifyOp> | ||
| 242 | void modifyItem(Index n, const ModifyOp& op) const { this->parent().modifyValue(n, op); } | ||
| 243 | // Note: modifyValue() can't be called on const iterators. | ||
| 244 | template<typename ModifyOp> | ||
| 245 | 2754 | void modifyValue(const ModifyOp& op) const { this->parent().modifyValue(this->pos(), op); } | |
| 246 | }; | ||
| 247 | |||
| 248 | /// Leaf nodes have no children, so their child iterators have no get/set accessors. | ||
| 249 | template<typename MaskIterT, typename NodeT, typename TagT> | ||
| 250 | struct ChildIter: | ||
| 251 | public SparseIteratorBase<MaskIterT, ChildIter<MaskIterT, NodeT, TagT>, NodeT, ValueType> | ||
| 252 | { | ||
| 253 | ChildIter() {} | ||
| 254 | ChildIter(const MaskIterT& iter, NodeT* parent): SparseIteratorBase< | ||
| 255 | MaskIterT, ChildIter<MaskIterT, NodeT, TagT>, NodeT, ValueType>(iter, parent) {} | ||
| 256 | }; | ||
| 257 | |||
| 258 | template<typename NodeT, typename ValueT, typename TagT> | ||
| 259 | struct DenseIter: public DenseIteratorBase< | ||
| 260 | MaskDenseIterator, DenseIter<NodeT, ValueT, TagT>, NodeT, /*ChildT=*/void, ValueT> | ||
| 261 | { | ||
| 262 | using BaseT = DenseIteratorBase<MaskDenseIterator, DenseIter, NodeT, void, ValueT>; | ||
| 263 | using NonConstValueT = typename BaseT::NonConstValueType; | ||
| 264 | |||
| 265 | DenseIter() {} | ||
| 266 | DenseIter(const MaskDenseIterator& iter, NodeT* parent): BaseT(iter, parent) {} | ||
| 267 | |||
| 268 | 32768 | bool getItem(Index pos, void*& child, NonConstValueT& value) const | |
| 269 | { | ||
| 270 | 49152 | value = this->parent().getValue(pos); | |
| 271 | 32768 | child = nullptr; | |
| 272 | 32768 | return false; // no child | |
| 273 | } | ||
| 274 | |||
| 275 | // Note: setItem() can't be called on const iterators. | ||
| 276 | //void setItem(Index pos, void* child) const {} | ||
| 277 | |||
| 278 | // Note: unsetItem() can't be called on const iterators. | ||
| 279 | void unsetItem(Index pos, const ValueT& value) const | ||
| 280 | { | ||
| 281 | this->parent().setValueOnly(pos, value); | ||
| 282 | } | ||
| 283 | }; | ||
| 284 | |||
| 285 | public: | ||
| 286 | using ValueOnIter = ValueIter<MaskOnIterator, LeafNode, const ValueType, ValueOn>; | ||
| 287 | using ValueOnCIter = ValueIter<MaskOnIterator, const LeafNode, const ValueType, ValueOn>; | ||
| 288 | using ValueOffIter = ValueIter<MaskOffIterator, LeafNode, const ValueType, ValueOff>; | ||
| 289 | using ValueOffCIter = ValueIter<MaskOffIterator,const LeafNode,const ValueType,ValueOff>; | ||
| 290 | using ValueAllIter = ValueIter<MaskDenseIterator, LeafNode, const ValueType, ValueAll>; | ||
| 291 | using ValueAllCIter = ValueIter<MaskDenseIterator,const LeafNode,const ValueType,ValueAll>; | ||
| 292 | using ChildOnIter = ChildIter<MaskOnIterator, LeafNode, ChildOn>; | ||
| 293 | using ChildOnCIter = ChildIter<MaskOnIterator, const LeafNode, ChildOn>; | ||
| 294 | using ChildOffIter = ChildIter<MaskOffIterator, LeafNode, ChildOff>; | ||
| 295 | using ChildOffCIter = ChildIter<MaskOffIterator, const LeafNode, ChildOff>; | ||
| 296 | using ChildAllIter = DenseIter<LeafNode, ValueType, ChildAll>; | ||
| 297 | using ChildAllCIter = DenseIter<const LeafNode, const ValueType, ChildAll>; | ||
| 298 | |||
| 299 |
45/139✗ Branch 1 not taken.
✓ Branch 2 taken 26 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6391 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 334 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 11877 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 2688 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 564 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 542 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 676 times.
✗ Branch 25 not taken.
✓ Branch 26 taken 592 times.
✗ Branch 28 not taken.
✓ Branch 29 taken 27 times.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✓ Branch 33 taken 566 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 5 times.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 46 not taken.
✗ Branch 47 not taken.
✗ Branch 48 not taken.
✗ Branch 49 not taken.
✗ Branch 50 not taken.
✗ Branch 51 not taken.
✗ Branch 52 not taken.
✗ Branch 53 not taken.
✗ Branch 54 not taken.
✗ Branch 55 not taken.
✗ Branch 56 not taken.
✗ Branch 57 not taken.
✗ Branch 58 not taken.
✗ Branch 59 not taken.
✗ Branch 60 not taken.
✗ Branch 61 not taken.
✗ Branch 62 not taken.
✗ Branch 63 not taken.
✗ Branch 64 not taken.
✗ Branch 65 not taken.
✗ Branch 66 not taken.
✗ Branch 67 not taken.
✗ Branch 68 not taken.
✗ Branch 70 not taken.
✗ Branch 71 not taken.
✗ Branch 73 not taken.
✗ Branch 74 not taken.
✓ Branch 75 taken 1 times.
✗ Branch 76 not taken.
✗ Branch 77 not taken.
✓ Branch 79 taken 1 times.
✗ Branch 80 not taken.
✗ Branch 82 not taken.
✓ Branch 83 taken 1 times.
✗ Branch 84 not taken.
✗ Branch 85 not taken.
✗ Branch 86 not taken.
✓ Branch 87 taken 1 times.
✗ Branch 88 not taken.
✗ Branch 89 not taken.
✓ Branch 91 taken 1 times.
✗ Branch 92 not taken.
✗ Branch 94 not taken.
✓ Branch 95 taken 1 times.
✗ Branch 96 not taken.
✗ Branch 97 not taken.
✗ Branch 98 not taken.
✓ Branch 99 taken 1 times.
✗ Branch 100 not taken.
✗ Branch 101 not taken.
✓ Branch 103 taken 1 times.
✗ Branch 104 not taken.
✗ Branch 106 not taken.
✓ Branch 107 taken 1 times.
✗ Branch 108 not taken.
✗ Branch 109 not taken.
✗ Branch 110 not taken.
✓ Branch 111 taken 1 times.
✗ Branch 112 not taken.
✗ Branch 113 not taken.
✓ Branch 115 taken 1 times.
✗ Branch 116 not taken.
✗ Branch 118 not taken.
✓ Branch 119 taken 1 times.
✗ Branch 120 not taken.
✓ Branch 123 taken 1 times.
✗ Branch 124 not taken.
✓ Branch 127 taken 1 times.
✗ Branch 128 not taken.
✓ Branch 131 taken 1 times.
✗ Branch 132 not taken.
✓ Branch 135 taken 1 times.
✗ Branch 136 not taken.
✓ Branch 139 taken 1 times.
✗ Branch 140 not taken.
✓ Branch 143 taken 1 times.
✗ Branch 144 not taken.
✓ Branch 147 taken 1 times.
✗ Branch 148 not taken.
✓ Branch 151 taken 1 times.
✗ Branch 152 not taken.
✓ Branch 155 taken 1 times.
✗ Branch 156 not taken.
✓ Branch 159 taken 1 times.
✗ Branch 160 not taken.
✓ Branch 163 taken 1 times.
✗ Branch 164 not taken.
✓ Branch 167 taken 1 times.
✗ Branch 168 not taken.
✓ Branch 171 taken 1 times.
✗ Branch 172 not taken.
✓ Branch 175 taken 1 times.
✗ Branch 176 not taken.
✓ Branch 179 taken 1 times.
✗ Branch 180 not taken.
✓ Branch 183 taken 1 times.
✗ Branch 184 not taken.
✓ Branch 187 taken 1 times.
✗ Branch 188 not taken.
✓ Branch 191 taken 1 times.
✗ Branch 192 not taken.
✓ Branch 195 taken 1 times.
✗ Branch 196 not taken.
✓ Branch 199 taken 1 times.
✗ Branch 200 not taken.
✓ Branch 203 taken 1 times.
✗ Branch 204 not taken.
|
2779551 | ValueOnCIter cbeginValueOn() const { return ValueOnCIter(mValueMask.beginOn(), this); } |
| 300 | 20124 | ValueOnCIter beginValueOn() const { return ValueOnCIter(mValueMask.beginOn(), this); } | |
| 301 |
6/14✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 56 times.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
✓ Branch 18 taken 1 times.
✗ Branch 19 not taken.
|
604089 | ValueOnIter beginValueOn() { return ValueOnIter(mValueMask.beginOn(), this); } |
| 302 | 4764 | ValueOffCIter cbeginValueOff() const { return ValueOffCIter(mValueMask.beginOff(), this); } | |
| 303 | ValueOffCIter beginValueOff() const { return ValueOffCIter(mValueMask.beginOff(), this); } | ||
| 304 | 40409 | ValueOffIter beginValueOff() { return ValueOffIter(mValueMask.beginOff(), this); } | |
| 305 | 107698 | ValueAllCIter cbeginValueAll() const { return ValueAllCIter(mValueMask.beginDense(), this); } | |
| 306 | ValueAllCIter beginValueAll() const { return ValueAllCIter(mValueMask.beginDense(), this); } | ||
| 307 | 48092 | ValueAllIter beginValueAll() { return ValueAllIter(mValueMask.beginDense(), this); } | |
| 308 | |||
| 309 | ValueOnCIter cendValueOn() const { return ValueOnCIter(mValueMask.endOn(), this); } | ||
| 310 | ValueOnCIter endValueOn() const { return ValueOnCIter(mValueMask.endOn(), this); } | ||
| 311 | ValueOnIter endValueOn() { return ValueOnIter(mValueMask.endOn(), this); } | ||
| 312 | ValueOffCIter cendValueOff() const { return ValueOffCIter(mValueMask.endOff(), this); } | ||
| 313 | ValueOffCIter endValueOff() const { return ValueOffCIter(mValueMask.endOff(), this); } | ||
| 314 | ValueOffIter endValueOff() { return ValueOffIter(mValueMask.endOff(), this); } | ||
| 315 | ValueAllCIter cendValueAll() const { return ValueAllCIter(mValueMask.endDense(), this); } | ||
| 316 | ValueAllCIter endValueAll() const { return ValueAllCIter(mValueMask.endDense(), this); } | ||
| 317 | ValueAllIter endValueAll() { return ValueAllIter(mValueMask.endDense(), this); } | ||
| 318 | |||
| 319 | // Note that [c]beginChildOn() and [c]beginChildOff() actually return end iterators, | ||
| 320 | // because leaf nodes have no children. | ||
| 321 | 4877008 | ChildOnCIter cbeginChildOn() const { return ChildOnCIter(mValueMask.endOn(), this); } | |
| 322 | ChildOnCIter beginChildOn() const { return ChildOnCIter(mValueMask.endOn(), this); } | ||
| 323 | 8426 | ChildOnIter beginChildOn() { return ChildOnIter(mValueMask.endOn(), this); } | |
| 324 | ChildOffCIter cbeginChildOff() const { return ChildOffCIter(mValueMask.endOff(), this); } | ||
| 325 | ChildOffCIter beginChildOff() const { return ChildOffCIter(mValueMask.endOff(), this); } | ||
| 326 | ChildOffIter beginChildOff() { return ChildOffIter(mValueMask.endOff(), this); } | ||
| 327 | ChildAllCIter cbeginChildAll() const { return ChildAllCIter(mValueMask.beginDense(), this); } | ||
| 328 | 64 | ChildAllCIter beginChildAll() const { return ChildAllCIter(mValueMask.beginDense(), this); } | |
| 329 | 198 | ChildAllIter beginChildAll() { return ChildAllIter(mValueMask.beginDense(), this); } | |
| 330 | |||
| 331 | ChildOnCIter cendChildOn() const { return ChildOnCIter(mValueMask.endOn(), this); } | ||
| 332 | ChildOnCIter endChildOn() const { return ChildOnCIter(mValueMask.endOn(), this); } | ||
| 333 | ChildOnIter endChildOn() { return ChildOnIter(mValueMask.endOn(), this); } | ||
| 334 | ChildOffCIter cendChildOff() const { return ChildOffCIter(mValueMask.endOff(), this); } | ||
| 335 | ChildOffCIter endChildOff() const { return ChildOffCIter(mValueMask.endOff(), this); } | ||
| 336 | ChildOffIter endChildOff() { return ChildOffIter(mValueMask.endOff(), this); } | ||
| 337 | ChildAllCIter cendChildAll() const { return ChildAllCIter(mValueMask.endDense(), this); } | ||
| 338 | ChildAllCIter endChildAll() const { return ChildAllCIter(mValueMask.endDense(), this); } | ||
| 339 | ChildAllIter endChildAll() { return ChildAllIter(mValueMask.endDense(), this); } | ||
| 340 | |||
| 341 | // | ||
| 342 | // Buffer management | ||
| 343 | // | ||
| 344 | /// @brief Exchange this node's data buffer with the given data buffer | ||
| 345 | /// without changing the active states of the values. | ||
| 346 | 41621 | void swap(Buffer& other) { mBuffer.swap(other); } | |
| 347 |
9/135✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 126 times.
✓ Branch 7 taken 3959 times.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 252 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 11327 times.
✓ Branch 20 taken 1 times.
✓ Branch 21 taken 1395 times.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✓ Branch 29 taken 8 times.
✗ Branch 30 not taken.
✓ Branch 31 taken 688 times.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✓ Branch 34 taken 824 times.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✗ Branch 46 not taken.
✗ Branch 47 not taken.
✗ Branch 48 not taken.
✗ Branch 49 not taken.
✗ Branch 50 not taken.
✗ Branch 51 not taken.
✗ Branch 52 not taken.
✗ Branch 53 not taken.
✗ Branch 54 not taken.
✗ Branch 55 not taken.
✗ Branch 56 not taken.
✗ Branch 57 not taken.
✗ Branch 58 not taken.
✗ Branch 59 not taken.
✗ Branch 60 not taken.
✗ Branch 61 not taken.
✗ Branch 62 not taken.
✗ Branch 63 not taken.
✗ Branch 64 not taken.
✗ Branch 65 not taken.
✗ Branch 66 not taken.
✗ Branch 67 not taken.
✗ Branch 68 not taken.
✗ Branch 69 not taken.
✗ Branch 70 not taken.
✗ Branch 71 not taken.
✗ Branch 72 not taken.
✗ Branch 73 not taken.
✗ Branch 74 not taken.
✗ Branch 75 not taken.
✗ Branch 76 not taken.
✗ Branch 77 not taken.
✗ Branch 78 not taken.
✗ Branch 79 not taken.
✗ Branch 80 not taken.
✗ Branch 81 not taken.
✗ Branch 82 not taken.
✗ Branch 83 not taken.
✗ Branch 84 not taken.
✗ Branch 85 not taken.
✗ Branch 86 not taken.
✗ Branch 87 not taken.
✗ Branch 88 not taken.
✗ Branch 89 not taken.
✗ Branch 90 not taken.
✗ Branch 91 not taken.
✗ Branch 92 not taken.
✗ Branch 93 not taken.
✗ Branch 94 not taken.
✗ Branch 95 not taken.
✗ Branch 96 not taken.
✗ Branch 97 not taken.
✗ Branch 98 not taken.
✗ Branch 99 not taken.
✗ Branch 100 not taken.
✗ Branch 101 not taken.
✗ Branch 102 not taken.
✗ Branch 103 not taken.
✗ Branch 104 not taken.
✗ Branch 105 not taken.
✗ Branch 106 not taken.
✗ Branch 107 not taken.
✗ Branch 108 not taken.
✗ Branch 109 not taken.
✗ Branch 110 not taken.
✗ Branch 112 not taken.
✗ Branch 113 not taken.
✗ Branch 115 not taken.
✗ Branch 116 not taken.
✗ Branch 118 not taken.
✗ Branch 119 not taken.
✗ Branch 121 not taken.
✗ Branch 122 not taken.
✗ Branch 124 not taken.
✗ Branch 125 not taken.
✗ Branch 127 not taken.
✗ Branch 128 not taken.
✗ Branch 130 not taken.
✗ Branch 131 not taken.
✗ Branch 133 not taken.
✗ Branch 134 not taken.
✗ Branch 136 not taken.
✗ Branch 137 not taken.
✗ Branch 139 not taken.
✗ Branch 140 not taken.
✗ Branch 142 not taken.
✗ Branch 143 not taken.
✗ Branch 145 not taken.
✗ Branch 146 not taken.
✗ Branch 148 not taken.
✗ Branch 149 not taken.
|
1404380 | const Buffer& buffer() const { return mBuffer; } |
| 348 |
79/253✓ Branch 1 taken 2191 times.
✓ Branch 2 taken 1395 times.
✓ Branch 3 taken 1024 times.
✓ Branch 4 taken 135343 times.
✓ Branch 5 taken 8 times.
✓ Branch 6 taken 4096 times.
✓ Branch 7 taken 4025 times.
✓ Branch 8 taken 8 times.
✓ Branch 9 taken 4096 times.
✓ Branch 10 taken 1342 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 4608 times.
✓ Branch 13 taken 115200 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 4119 times.
✓ Branch 16 taken 41 times.
✓ Branch 17 taken 252 times.
✓ Branch 18 taken 5396 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 11579 times.
✓ Branch 21 taken 7168 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 11579 times.
✓ Branch 24 taken 1024 times.
✗ Branch 25 not taken.
✓ Branch 26 taken 1300 times.
✓ Branch 27 taken 4096 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✓ Branch 30 taken 1842688 times.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✓ Branch 33 taken 4096 times.
✓ Branch 34 taken 2080 times.
✓ Branch 35 taken 11327 times.
✓ Branch 36 taken 4096 times.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✓ Branch 42 taken 4096 times.
✓ Branch 43 taken 2671 times.
✗ Branch 44 not taken.
✓ Branch 45 taken 5266 times.
✓ Branch 46 taken 2671 times.
✗ Branch 47 not taken.
✗ Branch 48 not taken.
✓ Branch 49 taken 2671 times.
✗ Branch 50 not taken.
✓ Branch 51 taken 4096 times.
✓ Branch 52 taken 2671 times.
✗ Branch 53 not taken.
✓ Branch 54 taken 19968 times.
✗ Branch 55 not taken.
✗ Branch 56 not taken.
✓ Branch 57 taken 574 times.
✗ Branch 58 not taken.
✗ Branch 59 not taken.
✗ Branch 60 not taken.
✓ Branch 61 taken 4096 times.
✓ Branch 62 taken 1170 times.
✗ Branch 63 not taken.
✗ Branch 64 not taken.
✓ Branch 65 taken 4096 times.
✗ Branch 66 not taken.
✗ Branch 67 not taken.
✗ Branch 68 not taken.
✓ Branch 69 taken 4096 times.
✗ Branch 70 not taken.
✗ Branch 71 not taken.
✗ Branch 72 not taken.
✓ Branch 73 taken 4096 times.
✓ Branch 74 taken 67 times.
✗ Branch 75 not taken.
✗ Branch 76 not taken.
✓ Branch 77 taken 4096 times.
✗ Branch 78 not taken.
✓ Branch 79 taken 1170 times.
✗ Branch 80 not taken.
✓ Branch 81 taken 4096 times.
✗ Branch 82 not taken.
✗ Branch 83 not taken.
✗ Branch 84 not taken.
✓ Branch 85 taken 4096 times.
✗ Branch 86 not taken.
✗ Branch 87 not taken.
✗ Branch 88 not taken.
✓ Branch 89 taken 4096 times.
✗ Branch 90 not taken.
✓ Branch 91 taken 60 times.
✗ Branch 92 not taken.
✓ Branch 93 taken 4627 times.
✗ Branch 94 not taken.
✗ Branch 95 not taken.
✓ Branch 96 taken 1170 times.
✓ Branch 97 taken 6144 times.
✗ Branch 98 not taken.
✗ Branch 99 not taken.
✗ Branch 100 not taken.
✗ Branch 101 not taken.
✗ Branch 102 not taken.
✗ Branch 103 not taken.
✗ Branch 104 not taken.
✗ Branch 105 not taken.
✗ Branch 106 not taken.
✗ Branch 107 not taken.
✓ Branch 108 taken 67 times.
✗ Branch 109 not taken.
✗ Branch 110 not taken.
✗ Branch 112 not taken.
✓ Branch 113 taken 1170 times.
✗ Branch 114 not taken.
✗ Branch 115 not taken.
✗ Branch 116 not taken.
✗ Branch 117 not taken.
✗ Branch 118 not taken.
✗ Branch 119 not taken.
✗ Branch 120 not taken.
✗ Branch 121 not taken.
✗ Branch 122 not taken.
✗ Branch 123 not taken.
✗ Branch 124 not taken.
✓ Branch 125 taken 63 times.
✗ Branch 126 not taken.
✗ Branch 127 not taken.
✗ Branch 128 not taken.
✓ Branch 130 taken 1170 times.
✗ Branch 131 not taken.
✗ Branch 133 not taken.
✗ Branch 134 not taken.
✗ Branch 136 not taken.
✗ Branch 137 not taken.
✗ Branch 139 not taken.
✗ Branch 140 not taken.
✓ Branch 142 taken 64 times.
✗ Branch 143 not taken.
✗ Branch 145 not taken.
✗ Branch 146 not taken.
✓ Branch 147 taken 1560 times.
✗ Branch 148 not taken.
✗ Branch 149 not taken.
✗ Branch 150 not taken.
✗ Branch 151 not taken.
✗ Branch 152 not taken.
✗ Branch 153 not taken.
✗ Branch 154 not taken.
✗ Branch 155 not taken.
✗ Branch 156 not taken.
✗ Branch 157 not taken.
✗ Branch 158 not taken.
✓ Branch 159 taken 67 times.
✗ Branch 160 not taken.
✗ Branch 161 not taken.
✗ Branch 163 not taken.
✓ Branch 164 taken 1560 times.
✗ Branch 165 not taken.
✗ Branch 166 not taken.
✗ Branch 167 not taken.
✗ Branch 168 not taken.
✗ Branch 169 not taken.
✗ Branch 170 not taken.
✗ Branch 171 not taken.
✗ Branch 172 not taken.
✗ Branch 173 not taken.
✗ Branch 174 not taken.
✗ Branch 175 not taken.
✓ Branch 176 taken 71 times.
✗ Branch 177 not taken.
✗ Branch 178 not taken.
✗ Branch 179 not taken.
✓ Branch 181 taken 1560 times.
✗ Branch 182 not taken.
✗ Branch 184 not taken.
✗ Branch 185 not taken.
✗ Branch 187 not taken.
✗ Branch 188 not taken.
✓ Branch 190 taken 112 times.
✗ Branch 191 not taken.
✗ Branch 195 not taken.
✗ Branch 196 not taken.
✗ Branch 198 not taken.
✗ Branch 199 not taken.
✗ Branch 201 not taken.
✗ Branch 202 not taken.
✓ Branch 204 taken 128 times.
✗ Branch 205 not taken.
✓ Branch 209 taken 1040 times.
✗ Branch 210 not taken.
✗ Branch 212 not taken.
✗ Branch 213 not taken.
✗ Branch 215 not taken.
✗ Branch 216 not taken.
✗ Branch 218 not taken.
✗ Branch 219 not taken.
✓ Branch 221 taken 47 times.
✗ Branch 222 not taken.
✓ Branch 224 taken 2080 times.
✗ Branch 225 not taken.
✗ Branch 227 not taken.
✗ Branch 228 not taken.
✗ Branch 230 not taken.
✗ Branch 231 not taken.
✗ Branch 233 not taken.
✗ Branch 234 not taken.
✓ Branch 236 taken 47 times.
✗ Branch 237 not taken.
✓ Branch 241 taken 2080 times.
✗ Branch 242 not taken.
✗ Branch 244 not taken.
✗ Branch 245 not taken.
✓ Branch 247 taken 4097 times.
✗ Branch 248 not taken.
✗ Branch 250 not taken.
✗ Branch 251 not taken.
✓ Branch 253 taken 47 times.
✗ Branch 254 not taken.
✓ Branch 258 taken 4455205 times.
✗ Branch 259 not taken.
✗ Branch 261 not taken.
✗ Branch 262 not taken.
✓ Branch 266 taken 3640 times.
✗ Branch 267 not taken.
✗ Branch 269 not taken.
✗ Branch 270 not taken.
✗ Branch 272 not taken.
✗ Branch 273 not taken.
✓ Branch 275 taken 34 times.
✗ Branch 276 not taken.
✗ Branch 280 not taken.
✗ Branch 281 not taken.
✗ Branch 283 not taken.
✗ Branch 284 not taken.
✓ Branch 286 taken 280 times.
✗ Branch 287 not taken.
✗ Branch 291 not taken.
✗ Branch 292 not taken.
✗ Branch 294 not taken.
✗ Branch 295 not taken.
✓ Branch 297 taken 93 times.
✗ Branch 298 not taken.
✓ Branch 300 taken 1 times.
✗ Branch 301 not taken.
✓ Branch 303 taken 1 times.
✗ Branch 304 not taken.
✓ Branch 306 taken 280 times.
✗ Branch 307 not taken.
✗ Branch 309 not taken.
✗ Branch 310 not taken.
✗ Branch 312 not taken.
✗ Branch 313 not taken.
✓ Branch 315 taken 392 times.
✗ Branch 316 not taken.
|
15415992 | Buffer& buffer() { return mBuffer; } |
| 349 | |||
| 350 | // | ||
| 351 | // I/O methods | ||
| 352 | // | ||
| 353 | /// @brief Read in just the topology. | ||
| 354 | /// @param is the stream from which to read | ||
| 355 | /// @param fromHalf if true, floating-point input values are assumed to be 16-bit | ||
| 356 | void readTopology(std::istream& is, bool fromHalf = false); | ||
| 357 | /// @brief Write out just the topology. | ||
| 358 | /// @param os the stream to which to write | ||
| 359 | /// @param toHalf if true, output floating-point values as 16-bit half floats | ||
| 360 | void writeTopology(std::ostream& os, bool toHalf = false) const; | ||
| 361 | |||
| 362 | /// @brief Read buffers from a stream. | ||
| 363 | /// @param is the stream from which to read | ||
| 364 | /// @param fromHalf if true, floating-point input values are assumed to be 16-bit | ||
| 365 | void readBuffers(std::istream& is, bool fromHalf = false); | ||
| 366 | /// @brief Read buffers that intersect the given bounding box. | ||
| 367 | /// @param is the stream from which to read | ||
| 368 | /// @param bbox an index-space bounding box | ||
| 369 | /// @param fromHalf if true, floating-point input values are assumed to be 16-bit | ||
| 370 | void readBuffers(std::istream& is, const CoordBBox& bbox, bool fromHalf = false); | ||
| 371 | /// @brief Write buffers to a stream. | ||
| 372 | /// @param os the stream to which to write | ||
| 373 | /// @param toHalf if true, output floating-point values as 16-bit half floats | ||
| 374 | void writeBuffers(std::ostream& os, bool toHalf = false) const; | ||
| 375 | |||
| 376 | size_t streamingSize(bool toHalf = false) const; | ||
| 377 | |||
| 378 | // | ||
| 379 | // Accessor methods | ||
| 380 | // | ||
| 381 | /// Return the value of the voxel at the given coordinates. | ||
| 382 | const ValueType& getValue(const Coord& xyz) const; | ||
| 383 | /// Return the value of the voxel at the given linear offset. | ||
| 384 | const ValueType& getValue(Index offset) const; | ||
| 385 | |||
| 386 | /// @brief Return @c true if the voxel at the given coordinates is active. | ||
| 387 | /// @param xyz the coordinates of the voxel to be probed | ||
| 388 | /// @param[out] val the value of the voxel at the given coordinates | ||
| 389 | bool probeValue(const Coord& xyz, ValueType& val) const; | ||
| 390 | /// @brief Return @c true if the voxel at the given offset is active. | ||
| 391 | /// @param offset the linear offset of the voxel to be probed | ||
| 392 | /// @param[out] val the value of the voxel at the given coordinates | ||
| 393 | bool probeValue(Index offset, ValueType& val) const; | ||
| 394 | |||
| 395 | /// Return the level (i.e., 0) at which leaf node values reside. | ||
| 396 | static Index getValueLevel(const Coord&) { return LEVEL; } | ||
| 397 | |||
| 398 | /// Set the active state of the voxel at the given coordinates but don't change its value. | ||
| 399 | void setActiveState(const Coord& xyz, bool on); | ||
| 400 | /// Set the active state of the voxel at the given offset but don't change its value. | ||
| 401 |
3/4✗ Branch 0 not taken.
✓ Branch 1 taken 438757 times.
✓ Branch 3 taken 241316 times.
✓ Branch 4 taken 197441 times.
|
877514 | void setActiveState(Index offset, bool on) { assert(offset<SIZE); mValueMask.set(offset, on); } |
| 402 | |||
| 403 | /// Set the value of the voxel at the given coordinates but don't change its active state. | ||
| 404 | void setValueOnly(const Coord& xyz, const ValueType& val); | ||
| 405 | /// Set the value of the voxel at the given offset but don't change its active state. | ||
| 406 | void setValueOnly(Index offset, const ValueType& val); | ||
| 407 | |||
| 408 | /// Mark the voxel at the given coordinates as inactive but don't change its value. | ||
| 409 | 6240 | void setValueOff(const Coord& xyz) { mValueMask.setOff(LeafNode::coordToOffset(xyz)); } | |
| 410 | /// Mark the voxel at the given offset as inactive but don't change its value. | ||
| 411 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 438345 times.
|
438603 | void setValueOff(Index offset) { assert(offset < SIZE); mValueMask.setOff(offset); } |
| 412 | |||
| 413 | /// Set the value of the voxel at the given coordinates and mark the voxel as inactive. | ||
| 414 | void setValueOff(const Coord& xyz, const ValueType& val); | ||
| 415 | /// Set the value of the voxel at the given offset and mark the voxel as inactive. | ||
| 416 | void setValueOff(Index offset, const ValueType& val); | ||
| 417 | |||
| 418 | /// Mark the voxel at the given coordinates as active but don't change its value. | ||
| 419 | void setValueOn(const Coord& xyz) { mValueMask.setOn(LeafNode::coordToOffset(xyz)); } | ||
| 420 | /// Mark the voxel at the given offset as active but don't change its value. | ||
| 421 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 9461142 times.
|
18922294 | void setValueOn(Index offset) { assert(offset < SIZE); mValueMask.setOn(offset); } |
| 422 | /// Set the value of the voxel at the given coordinates and mark the voxel as active. | ||
| 423 | 155689312 | void setValueOn(const Coord& xyz, const ValueType& val) { | |
| 424 | this->setValueOn(LeafNode::coordToOffset(xyz), val); | ||
| 425 | 155689312 | } | |
| 426 | /// Set the value of the voxel at the given coordinates and mark the voxel as active. | ||
| 427 |
9/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 1 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 1 times.
✗ Branch 26 not taken.
|
9 | void setValue(const Coord& xyz, const ValueType& val) { this->setValueOn(xyz, val); } |
| 428 | /// Set the value of the voxel at the given offset and mark the voxel as active. | ||
| 429 | void setValueOn(Index offset, const ValueType& val) { | ||
| 430 |
16/32✓ Branch 1 taken 89414 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 397 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 169518 times.
✓ Branch 10 taken 7 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 169518 times.
✓ Branch 13 taken 81359 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 57263 times.
✓ Branch 16 taken 6 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 6 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✓ Branch 22 taken 6 times.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✓ Branch 25 taken 1 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 1 times.
✗ Branch 29 not taken.
✓ Branch 31 taken 1 times.
✗ Branch 32 not taken.
✓ Branch 34 taken 1 times.
✗ Branch 35 not taken.
✓ Branch 37 taken 1 times.
✗ Branch 38 not taken.
|
92443662 | mBuffer.setValue(offset, val); |
| 431 | 96474851 | mValueMask.setOn(offset); | |
| 432 | 1761058 | } | |
| 433 | |||
| 434 | /// @brief Apply a functor to the value of the voxel at the given offset | ||
| 435 | /// and mark the voxel as active. | ||
| 436 | template<typename ModifyOp> | ||
| 437 | 1079684540 | void modifyValue(Index offset, const ModifyOp& op) | |
| 438 | { | ||
| 439 | 1079684540 | mBuffer.loadValues(); | |
| 440 | if (!mBuffer.empty()) { | ||
| 441 | // in-place modify value | ||
| 442 | ValueType& val = const_cast<ValueType&>(mBuffer[offset]); | ||
| 443 | 1026 | op(val); | |
| 444 | 1079684540 | mValueMask.setOn(offset); | |
| 445 | } | ||
| 446 | 1079684540 | } | |
| 447 | |||
| 448 | /// @brief Apply a functor to the value of the voxel at the given coordinates | ||
| 449 | /// and mark the voxel as active. | ||
| 450 | template<typename ModifyOp> | ||
| 451 | 1078979841 | void modifyValue(const Coord& xyz, const ModifyOp& op) | |
| 452 | { | ||
| 453 | 1078979841 | this->modifyValue(this->coordToOffset(xyz), op); | |
| 454 | 1078979841 | } | |
| 455 | |||
| 456 | /// Apply a functor to the voxel at the given coordinates. | ||
| 457 | template<typename ModifyOp> | ||
| 458 | 16 | void modifyValueAndActiveState(const Coord& xyz, const ModifyOp& op) | |
| 459 | { | ||
| 460 | 16 | mBuffer.loadValues(); | |
| 461 | if (!mBuffer.empty()) { | ||
| 462 | const Index offset = this->coordToOffset(xyz); | ||
| 463 | 16 | bool state = mValueMask.isOn(offset); | |
| 464 | // in-place modify value | ||
| 465 | ValueType& val = const_cast<ValueType&>(mBuffer[offset]); | ||
| 466 | 6 | op(val, state); | |
| 467 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
6 | mValueMask.set(offset, state); |
| 468 | } | ||
| 469 | 16 | } | |
| 470 | |||
| 471 | /// Mark all voxels as active but don't change their values. | ||
| 472 | void setValuesOn() { mValueMask.setOn(); } | ||
| 473 | /// Mark all voxels as inactive but don't change their values. | ||
| 474 | void setValuesOff() { mValueMask.setOff(); } | ||
| 475 | |||
| 476 | /// Return @c true if the voxel at the given coordinates is active. | ||
| 477 | 44324056 | bool isValueOn(const Coord& xyz) const {return this->isValueOn(LeafNode::coordToOffset(xyz));} | |
| 478 | /// Return @c true if the voxel at the given offset is active. | ||
| 479 | 40614225 | bool isValueOn(Index offset) const { return mValueMask.isOn(offset); } | |
| 480 | |||
| 481 | /// Return @c false since leaf nodes never contain tiles. | ||
| 482 | static bool hasActiveTiles() { return false; } | ||
| 483 | |||
| 484 | /// Set all voxels that lie outside the given axis-aligned box to the background. | ||
| 485 | void clip(const CoordBBox&, const ValueType& background); | ||
| 486 | |||
| 487 | /// Set all voxels within an axis-aligned box to the specified value and active state. | ||
| 488 | void fill(const CoordBBox& bbox, const ValueType&, bool active = true); | ||
| 489 | /// Set all voxels within an axis-aligned box to the specified value and active state. | ||
| 490 | void denseFill(const CoordBBox& bbox, const ValueType& value, bool active = true) | ||
| 491 | { | ||
| 492 | 11920 | this->fill(bbox, value, active); | |
| 493 | } | ||
| 494 | |||
| 495 | /// Set all voxels to the specified value but don't change their active states. | ||
| 496 | void fill(const ValueType& value); | ||
| 497 | /// Set all voxels to the specified value and active state. | ||
| 498 | void fill(const ValueType& value, bool active); | ||
| 499 | |||
| 500 | /// @brief Copy into a dense grid the values of the voxels that lie within | ||
| 501 | /// a given bounding box. | ||
| 502 | /// | ||
| 503 | /// @param bbox inclusive bounding box of the voxels to be copied into the dense grid | ||
| 504 | /// @param dense dense grid with a stride in @e z of one (see tools::Dense | ||
| 505 | /// in tools/Dense.h for the required API) | ||
| 506 | /// | ||
| 507 | /// @note @a bbox is assumed to be identical to or contained in the coordinate domains | ||
| 508 | /// of both the dense grid and this node, i.e., no bounds checking is performed. | ||
| 509 | /// @note Consider using tools::CopyToDense in tools/Dense.h | ||
| 510 | /// instead of calling this method directly. | ||
| 511 | template<typename DenseT> | ||
| 512 | void copyToDense(const CoordBBox& bbox, DenseT& dense) const; | ||
| 513 | |||
| 514 | /// @brief Copy from a dense grid into this node the values of the voxels | ||
| 515 | /// that lie within a given bounding box. | ||
| 516 | /// @details Only values that are different (by more than the given tolerance) | ||
| 517 | /// from the background value will be active. Other values are inactive | ||
| 518 | /// and truncated to the background value. | ||
| 519 | /// | ||
| 520 | /// @param bbox inclusive bounding box of the voxels to be copied into this node | ||
| 521 | /// @param dense dense grid with a stride in @e z of one (see tools::Dense | ||
| 522 | /// in tools/Dense.h for the required API) | ||
| 523 | /// @param background background value of the tree that this node belongs to | ||
| 524 | /// @param tolerance tolerance within which a value equals the background value | ||
| 525 | /// | ||
| 526 | /// @note @a bbox is assumed to be identical to or contained in the coordinate domains | ||
| 527 | /// of both the dense grid and this node, i.e., no bounds checking is performed. | ||
| 528 | /// @note Consider using tools::CopyFromDense in tools/Dense.h | ||
| 529 | /// instead of calling this method directly. | ||
| 530 | template<typename DenseT> | ||
| 531 | void copyFromDense(const CoordBBox& bbox, const DenseT& dense, | ||
| 532 | const ValueType& background, const ValueType& tolerance); | ||
| 533 | |||
| 534 | /// @brief Return the value of the voxel at the given coordinates. | ||
| 535 | /// @note Used internally by ValueAccessor. | ||
| 536 | template<typename AccessorT> | ||
| 537 | const ValueType& getValueAndCache(const Coord& xyz, AccessorT&) const | ||
| 538 | { | ||
| 539 | 844314473 | return this->getValue(xyz); | |
| 540 | } | ||
| 541 | |||
| 542 | /// @brief Return @c true if the voxel at the given coordinates is active. | ||
| 543 | /// @note Used internally by ValueAccessor. | ||
| 544 | template<typename AccessorT> | ||
| 545 | 9005668 | bool isValueOnAndCache(const Coord& xyz, AccessorT&) const { return this->isValueOn(xyz); } | |
| 546 | |||
| 547 | /// @brief Change the value of the voxel at the given coordinates and mark it as active. | ||
| 548 | /// @note Used internally by ValueAccessor. | ||
| 549 | template<typename AccessorT> | ||
| 550 | void setValueAndCache(const Coord& xyz, const ValueType& val, AccessorT&) | ||
| 551 | { | ||
| 552 | 93772111 | this->setValueOn(xyz, val); | |
| 553 | 93772111 | } | |
| 554 | |||
| 555 | /// @brief Change the value of the voxel at the given coordinates | ||
| 556 | /// but preserve its state. | ||
| 557 | /// @note Used internally by ValueAccessor. | ||
| 558 | template<typename AccessorT> | ||
| 559 | void setValueOnlyAndCache(const Coord& xyz, const ValueType& val, AccessorT&) | ||
| 560 | { | ||
| 561 | 8136073 | this->setValueOnly(xyz, val); | |
| 562 | 8136073 | } | |
| 563 | |||
| 564 | /// @brief Apply a functor to the value of the voxel at the given coordinates | ||
| 565 | /// and mark the voxel as active. | ||
| 566 | /// @note Used internally by ValueAccessor. | ||
| 567 | template<typename ModifyOp, typename AccessorT> | ||
| 568 | void modifyValueAndCache(const Coord& xyz, const ModifyOp& op, AccessorT&) | ||
| 569 | { | ||
| 570 | 539489919 | this->modifyValue(xyz, op); | |
| 571 | 539489919 | } | |
| 572 | |||
| 573 | /// Apply a functor to the voxel at the given coordinates. | ||
| 574 | /// @note Used internally by ValueAccessor. | ||
| 575 | template<typename ModifyOp, typename AccessorT> | ||
| 576 | void modifyValueAndActiveStateAndCache(const Coord& xyz, const ModifyOp& op, AccessorT&) | ||
| 577 | { | ||
| 578 | 8 | this->modifyValueAndActiveState(xyz, op); | |
| 579 | 8 | } | |
| 580 | |||
| 581 | /// @brief Change the value of the voxel at the given coordinates and mark it as inactive. | ||
| 582 | /// @note Used internally by ValueAccessor. | ||
| 583 | template<typename AccessorT> | ||
| 584 | void setValueOffAndCache(const Coord& xyz, const ValueType& value, AccessorT&) | ||
| 585 | { | ||
| 586 | 5685953 | this->setValueOff(xyz, value); | |
| 587 | 5685953 | } | |
| 588 | |||
| 589 | /// @brief Set the active state of the voxel at the given coordinates | ||
| 590 | /// without changing its value. | ||
| 591 | /// @note Used internally by ValueAccessor. | ||
| 592 | template<typename AccessorT> | ||
| 593 | void setActiveStateAndCache(const Coord& xyz, bool on, AccessorT&) | ||
| 594 | { | ||
| 595 | 177034 | this->setActiveState(xyz, on); | |
| 596 | 177034 | } | |
| 597 | |||
| 598 | /// @brief Return @c true if the voxel at the given coordinates is active | ||
| 599 | /// and return the voxel value in @a val. | ||
| 600 | /// @note Used internally by ValueAccessor. | ||
| 601 | template<typename AccessorT> | ||
| 602 | bool probeValueAndCache(const Coord& xyz, ValueType& val, AccessorT&) const | ||
| 603 | { | ||
| 604 | 999273928 | return this->probeValue(xyz, val); | |
| 605 | } | ||
| 606 | |||
| 607 | /// @brief Return the value of the voxel at the given coordinates and return | ||
| 608 | /// its active state and level (i.e., 0) in @a state and @a level. | ||
| 609 | /// @note Used internally by ValueAccessor. | ||
| 610 | template<typename AccessorT> | ||
| 611 | const ValueType& getValue(const Coord& xyz, bool& state, int& level, AccessorT&) const | ||
| 612 | { | ||
| 613 | const Index offset = this->coordToOffset(xyz); | ||
| 614 | state = mValueMask.isOn(offset); | ||
| 615 | level = LEVEL; | ||
| 616 | return mBuffer[offset]; | ||
| 617 | } | ||
| 618 | |||
| 619 | /// @brief Return the LEVEL (=0) at which leaf node values reside. | ||
| 620 | /// @note Used internally by ValueAccessor (note last argument is a dummy). | ||
| 621 | template<typename AccessorT> | ||
| 622 | static Index getValueLevelAndCache(const Coord&, AccessorT&) { return LEVEL; } | ||
| 623 | |||
| 624 | /// @brief Return a const reference to the first value in the buffer. | ||
| 625 | /// @note Though it is potentially risky you can convert this | ||
| 626 | /// to a non-const pointer by means of const_case<ValueType*>&. | ||
| 627 |
2/4✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
|
2441 | const ValueType& getFirstValue() const { return mBuffer[0]; } |
| 628 | /// Return a const reference to the last value in the buffer. | ||
| 629 |
5/8✓ Branch 1 taken 6 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
|
385583 | const ValueType& getLastValue() const { return mBuffer[SIZE - 1]; } |
| 630 | |||
| 631 | /// @brief Replace inactive occurrences of @a oldBackground with @a newBackground, | ||
| 632 | /// and inactive occurrences of @a -oldBackground with @a -newBackground. | ||
| 633 | void resetBackground(const ValueType& oldBackground, const ValueType& newBackground); | ||
| 634 | |||
| 635 | void negate(); | ||
| 636 | |||
| 637 | /// @brief No-op | ||
| 638 | /// @details This function exists only to enable template instantiation. | ||
| 639 | void voxelizeActiveTiles(bool = true) {} | ||
| 640 | |||
| 641 | template<MergePolicy Policy> void merge(const LeafNode&); | ||
| 642 | template<MergePolicy Policy> void merge(const ValueType& tileValue, bool tileActive); | ||
| 643 | template<MergePolicy Policy> | ||
| 644 | void merge(const LeafNode& other, const ValueType& /*bg*/, const ValueType& /*otherBG*/); | ||
| 645 | |||
| 646 | /// @brief Union this node's set of active values with the active values | ||
| 647 | /// of the other node, whose @c ValueType may be different. So a | ||
| 648 | /// resulting voxel will be active if either of the original voxels | ||
| 649 | /// were active. | ||
| 650 | /// | ||
| 651 | /// @note This operation modifies only active states, not values. | ||
| 652 | template<typename OtherType> | ||
| 653 | void topologyUnion(const LeafNode<OtherType, Log2Dim>& other, const bool preserveTiles = false); | ||
| 654 | |||
| 655 | /// @brief Intersect this node's set of active values with the active values | ||
| 656 | /// of the other node, whose @c ValueType may be different. So a | ||
| 657 | /// resulting voxel will be active only if both of the original voxels | ||
| 658 | /// were active. | ||
| 659 | /// | ||
| 660 | /// @details The last dummy argument is required to match the signature | ||
| 661 | /// for InternalNode::topologyIntersection. | ||
| 662 | /// | ||
| 663 | /// @note This operation modifies only active states, not | ||
| 664 | /// values. Also note that this operation can result in all voxels | ||
| 665 | /// being inactive so consider subsequently calling prune. | ||
| 666 | template<typename OtherType> | ||
| 667 | void topologyIntersection(const LeafNode<OtherType, Log2Dim>& other, const ValueType&); | ||
| 668 | |||
| 669 | /// @brief Difference this node's set of active values with the active values | ||
| 670 | /// of the other node, whose @c ValueType may be different. So a | ||
| 671 | /// resulting voxel will be active only if the original voxel is | ||
| 672 | /// active in this LeafNode and inactive in the other LeafNode. | ||
| 673 | /// | ||
| 674 | /// @details The last dummy argument is required to match the signature | ||
| 675 | /// for InternalNode::topologyDifference. | ||
| 676 | /// | ||
| 677 | /// @note This operation modifies only active states, not values. | ||
| 678 | /// Also, because it can deactivate all of this node's voxels, | ||
| 679 | /// consider subsequently calling prune. | ||
| 680 | template<typename OtherType> | ||
| 681 | void topologyDifference(const LeafNode<OtherType, Log2Dim>& other, const ValueType&); | ||
| 682 | |||
| 683 | template<typename CombineOp> | ||
| 684 | void combine(const LeafNode& other, CombineOp& op); | ||
| 685 | template<typename CombineOp> | ||
| 686 | void combine(const ValueType& value, bool valueIsActive, CombineOp& op); | ||
| 687 | |||
| 688 | template<typename CombineOp, typename OtherType /*= ValueType*/> | ||
| 689 | void combine2(const LeafNode& other, const OtherType&, bool valueIsActive, CombineOp&); | ||
| 690 | template<typename CombineOp, typename OtherNodeT /*= LeafNode*/> | ||
| 691 | void combine2(const ValueType&, const OtherNodeT& other, bool valueIsActive, CombineOp&); | ||
| 692 | template<typename CombineOp, typename OtherNodeT /*= LeafNode*/> | ||
| 693 | void combine2(const LeafNode& b0, const OtherNodeT& b1, CombineOp&); | ||
| 694 | |||
| 695 | /// @brief Calls the templated functor BBoxOp with bounding box | ||
| 696 | /// information. An additional level argument is provided to the | ||
| 697 | /// callback. | ||
| 698 | /// | ||
| 699 | /// @note The bounding boxes are guaranteed to be non-overlapping. | ||
| 700 | template<typename BBoxOp> void visitActiveBBox(BBoxOp&) const; | ||
| 701 | |||
| 702 | template<typename VisitorOp> void visit(VisitorOp&); | ||
| 703 | template<typename VisitorOp> void visit(VisitorOp&) const; | ||
| 704 | |||
| 705 | template<typename OtherLeafNodeType, typename VisitorOp> | ||
| 706 | void visit2Node(OtherLeafNodeType& other, VisitorOp&); | ||
| 707 | template<typename OtherLeafNodeType, typename VisitorOp> | ||
| 708 | void visit2Node(OtherLeafNodeType& other, VisitorOp&) const; | ||
| 709 | template<typename IterT, typename VisitorOp> | ||
| 710 | void visit2(IterT& otherIter, VisitorOp&, bool otherIsLHS = false); | ||
| 711 | template<typename IterT, typename VisitorOp> | ||
| 712 | void visit2(IterT& otherIter, VisitorOp&, bool otherIsLHS = false) const; | ||
| 713 | |||
| 714 | //@{ | ||
| 715 | /// This function exists only to enable template instantiation. | ||
| 716 | void prune(const ValueType& /*tolerance*/ = zeroVal<ValueType>()) {} | ||
| 717 | void addLeaf(LeafNode*) {} | ||
| 718 | template<typename AccessorT> | ||
| 719 | void addLeafAndCache(LeafNode*, AccessorT&) {} | ||
| 720 | template<typename NodeT> | ||
| 721 | NodeT* stealNode(const Coord&, const ValueType&, bool) { return nullptr; } | ||
| 722 | template<typename NodeT> | ||
| 723 | NodeT* probeNode(const Coord&) { return nullptr; } | ||
| 724 | template<typename NodeT> | ||
| 725 | const NodeT* probeConstNode(const Coord&) const { return nullptr; } | ||
| 726 | template<typename ArrayT> void getNodes(ArrayT&) const {} | ||
| 727 | template<typename ArrayT> void stealNodes(ArrayT&, const ValueType&, bool) {} | ||
| 728 | //@} | ||
| 729 | |||
| 730 | void addTile(Index level, const Coord&, const ValueType&, bool); | ||
| 731 | void addTile(Index offset, const ValueType&, bool); | ||
| 732 | template<typename AccessorT> | ||
| 733 | void addTileAndCache(Index, const Coord&, const ValueType&, bool, AccessorT&); | ||
| 734 | |||
| 735 | //@{ | ||
| 736 | /// @brief Return a pointer to this node. | ||
| 737 | LeafNode* touchLeaf(const Coord&) { return this; } | ||
| 738 | template<typename AccessorT> | ||
| 739 | LeafNode* touchLeafAndCache(const Coord&, AccessorT&) { return this; } | ||
| 740 | template<typename NodeT, typename AccessorT> | ||
| 741 | NodeT* probeNodeAndCache(const Coord&, AccessorT&) | ||
| 742 | { | ||
| 743 | OPENVDB_NO_UNREACHABLE_CODE_WARNING_BEGIN | ||
| 744 | if (!(std::is_same<NodeT, LeafNode>::value)) return nullptr; | ||
| 745 | return reinterpret_cast<NodeT*>(this); | ||
| 746 | OPENVDB_NO_UNREACHABLE_CODE_WARNING_END | ||
| 747 | } | ||
| 748 | LeafNode* probeLeaf(const Coord&) { return this; } | ||
| 749 | template<typename AccessorT> | ||
| 750 | LeafNode* probeLeafAndCache(const Coord&, AccessorT&) { return this; } | ||
| 751 | //@} | ||
| 752 | //@{ | ||
| 753 | /// @brief Return a @const pointer to this node. | ||
| 754 | const LeafNode* probeConstLeaf(const Coord&) const { return this; } | ||
| 755 | template<typename AccessorT> | ||
| 756 | const LeafNode* probeConstLeafAndCache(const Coord&, AccessorT&) const { return this; } | ||
| 757 | template<typename AccessorT> | ||
| 758 | const LeafNode* probeLeafAndCache(const Coord&, AccessorT&) const { return this; } | ||
| 759 | const LeafNode* probeLeaf(const Coord&) const { return this; } | ||
| 760 | template<typename NodeT, typename AccessorT> | ||
| 761 | const NodeT* probeConstNodeAndCache(const Coord&, AccessorT&) const | ||
| 762 | { | ||
| 763 | OPENVDB_NO_UNREACHABLE_CODE_WARNING_BEGIN | ||
| 764 | if (!(std::is_same<NodeT, LeafNode>::value)) return nullptr; | ||
| 765 | return reinterpret_cast<const NodeT*>(this); | ||
| 766 | OPENVDB_NO_UNREACHABLE_CODE_WARNING_END | ||
| 767 | } | ||
| 768 | //@} | ||
| 769 | |||
| 770 | /// Return @c true if all of this node's values have the same active state | ||
| 771 | /// and are in the range this->getFirstValue() +/- @a tolerance. | ||
| 772 | /// | ||
| 773 | /// | ||
| 774 | /// @param firstValue Is updated with the first value of this leaf node. | ||
| 775 | /// @param state Is updated with the state of all values IF method | ||
| 776 | /// returns @c true. Else the value is undefined! | ||
| 777 | /// @param tolerance The tolerance used to determine if values are | ||
| 778 | /// approximately equal to the for value. | ||
| 779 | bool isConstant(ValueType& firstValue, bool& state, | ||
| 780 | const ValueType& tolerance = zeroVal<ValueType>()) const; | ||
| 781 | |||
| 782 | /// Return @c true if all of this node's values have the same active state | ||
| 783 | /// and the range (@a maxValue - @a minValue) < @a tolerance. | ||
| 784 | /// | ||
| 785 | /// @param minValue Is updated with the minimum of all values IF method | ||
| 786 | /// returns @c true. Else the value is undefined! | ||
| 787 | /// @param maxValue Is updated with the maximum of all values IF method | ||
| 788 | /// returns @c true. Else the value is undefined! | ||
| 789 | /// @param state Is updated with the state of all values IF method | ||
| 790 | /// returns @c true. Else the value is undefined! | ||
| 791 | /// @param tolerance The tolerance used to determine if values are | ||
| 792 | /// approximately constant. | ||
| 793 | bool isConstant(ValueType& minValue, ValueType& maxValue, | ||
| 794 | bool& state, const ValueType& tolerance = zeroVal<ValueType>()) const; | ||
| 795 | |||
| 796 | |||
| 797 | /// @brief Computes the median value of all the active AND inactive voxels in this node. | ||
| 798 | /// @return The median value of all values in this node. | ||
| 799 | /// | ||
| 800 | /// @param tmp Optional temporary storage that can hold at least NUM_VALUES values | ||
| 801 | /// Use of this temporary storage can improve performance | ||
| 802 | /// when this method is called multiple times. | ||
| 803 | /// | ||
| 804 | /// @note If tmp = this->buffer().data() then the median | ||
| 805 | /// value is computed very efficiently (in place) but | ||
| 806 | /// the voxel values in this node are re-shuffled! | ||
| 807 | /// | ||
| 808 | /// @warning If tmp != nullptr then it is the responsibility of | ||
| 809 | /// the client code that it points to enough memory to | ||
| 810 | /// hold NUM_VALUES elements of type ValueType. | ||
| 811 | ValueType medianAll(ValueType *tmp = nullptr) const; | ||
| 812 | |||
| 813 | /// @brief Computes the median value of all the active voxels in this node. | ||
| 814 | /// @return The number of active voxels. | ||
| 815 | /// | ||
| 816 | /// @param value If the return value is non zero @a value is updated | ||
| 817 | /// with the median value. | ||
| 818 | /// | ||
| 819 | /// @param tmp Optional temporary storage that can hold at least | ||
| 820 | /// as many values as there are active voxels in this node. | ||
| 821 | /// Use of this temporary storage can improve performance | ||
| 822 | /// when this method is called multiple times. | ||
| 823 | /// | ||
| 824 | /// @warning If tmp != nullptr then it is the responsibility of | ||
| 825 | /// the client code that it points to enough memory to | ||
| 826 | /// hold the number of active voxels of type ValueType. | ||
| 827 | Index medianOn(ValueType &value, ValueType *tmp = nullptr) const; | ||
| 828 | |||
| 829 | /// @brief Computes the median value of all the inactive voxels in this node. | ||
| 830 | /// @return The number of inactive voxels. | ||
| 831 | /// | ||
| 832 | /// @param value If the return value is non zero @a value is updated | ||
| 833 | /// with the median value. | ||
| 834 | /// | ||
| 835 | /// @param tmp Optional temporary storage that can hold at least | ||
| 836 | /// as many values as there are inactive voxels in this node. | ||
| 837 | /// Use of this temporary storage can improve performance | ||
| 838 | /// when this method is called multiple times. | ||
| 839 | /// | ||
| 840 | /// @warning If tmp != nullptr then it is the responsibility of | ||
| 841 | /// the client code that it points to enough memory to | ||
| 842 | /// hold the number of inactive voxels of type ValueType. | ||
| 843 | Index medianOff(ValueType &value, ValueType *tmp = nullptr) const; | ||
| 844 | |||
| 845 | /// Return @c true if all of this node's values are inactive. | ||
| 846 | bool isInactive() const { return mValueMask.isOff(); } | ||
| 847 | |||
| 848 | protected: | ||
| 849 | friend class ::TestLeaf; | ||
| 850 | template<typename> friend class ::TestLeafIO; | ||
| 851 | |||
| 852 | // During topology-only construction, access is needed | ||
| 853 | // to protected/private members of other template instances. | ||
| 854 | template<typename, Index> friend class LeafNode; | ||
| 855 | |||
| 856 | friend struct ValueIter<MaskOnIterator, LeafNode, ValueType, ValueOn>; | ||
| 857 | friend struct ValueIter<MaskOffIterator, LeafNode, ValueType, ValueOff>; | ||
| 858 | friend struct ValueIter<MaskDenseIterator, LeafNode, ValueType, ValueAll>; | ||
| 859 | friend struct ValueIter<MaskOnIterator, const LeafNode, ValueType, ValueOn>; | ||
| 860 | friend struct ValueIter<MaskOffIterator, const LeafNode, ValueType, ValueOff>; | ||
| 861 | friend struct ValueIter<MaskDenseIterator, const LeafNode, ValueType, ValueAll>; | ||
| 862 | |||
| 863 | // Allow iterators to call mask accessor methods (see below). | ||
| 864 | /// @todo Make mask accessors public? | ||
| 865 | friend class IteratorBase<MaskOnIterator, LeafNode>; | ||
| 866 | friend class IteratorBase<MaskOffIterator, LeafNode>; | ||
| 867 | friend class IteratorBase<MaskDenseIterator, LeafNode>; | ||
| 868 | |||
| 869 | // Mask accessors | ||
| 870 | public: | ||
| 871 | 7540057 | bool isValueMaskOn(Index n) const { return mValueMask.isOn(n); } | |
| 872 | bool isValueMaskOn() const { return mValueMask.isOn(); } | ||
| 873 | bool isValueMaskOff(Index n) const { return mValueMask.isOff(n); } | ||
| 874 | bool isValueMaskOff() const { return mValueMask.isOff(); } | ||
| 875 |
4/32✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 1894 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 41 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 41 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 41 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
|
329759 | const NodeMaskType& getValueMask() const { return mValueMask; } |
| 876 |
3/32✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 41 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 41 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 41 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
|
394727 | NodeMaskType& getValueMask() { return mValueMask; } |
| 877 | 50973 | const NodeMaskType& valueMask() const { return mValueMask; } | |
| 878 | void setValueMask(const NodeMaskType& mask) { mValueMask = mask; } | ||
| 879 | bool isChildMaskOn(Index) const { return false; } // leaf nodes have no children | ||
| 880 | bool isChildMaskOff(Index) const { return true; } | ||
| 881 | bool isChildMaskOff() const { return true; } | ||
| 882 | protected: | ||
| 883 |
10/32✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3326941 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 278 times.
✓ Branch 9 taken 7918 times.
✓ Branch 10 taken 3894 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 2 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✓ Branch 20 taken 3326941 times.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✓ Branch 24 taken 4 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 2 times.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
|
6666037 | void setValueMask(Index n, bool on) { mValueMask.set(n, on); } |
| 884 | 5498740 | void setValueMaskOn(Index n) { mValueMask.setOn(n); } | |
| 885 | void setValueMaskOff(Index n) { mValueMask.setOff(n); } | ||
| 886 | |||
| 887 | inline void skipCompressedValues(bool seekable, std::istream&, bool fromHalf); | ||
| 888 | |||
| 889 | /// Compute the origin of the leaf node that contains the voxel with the given coordinates. | ||
| 890 | static void evalNodeOrigin(Coord& xyz) { xyz &= ~(DIM - 1); } | ||
| 891 | |||
| 892 | template<typename NodeT, typename VisitorOp, typename ChildAllIterT> | ||
| 893 | static inline void doVisit(NodeT&, VisitorOp&); | ||
| 894 | |||
| 895 | template<typename NodeT, typename OtherNodeT, typename VisitorOp, | ||
| 896 | typename ChildAllIterT, typename OtherChildAllIterT> | ||
| 897 | static inline void doVisit2Node(NodeT& self, OtherNodeT& other, VisitorOp&); | ||
| 898 | |||
| 899 | template<typename NodeT, typename VisitorOp, | ||
| 900 | typename ChildAllIterT, typename OtherChildAllIterT> | ||
| 901 | static inline void doVisit2(NodeT& self, OtherChildAllIterT&, VisitorOp&, bool otherIsLHS); | ||
| 902 | |||
| 903 | private: | ||
| 904 | /// Buffer containing the actual data values | ||
| 905 | Buffer mBuffer; | ||
| 906 | /// Bitmask that determines which voxels are active | ||
| 907 | NodeMaskType mValueMask; | ||
| 908 | /// Global grid index coordinates (x,y,z) of the local origin of this node | ||
| 909 | Coord mOrigin; | ||
| 910 | #if OPENVDB_ABI_VERSION_NUMBER >= 9 | ||
| 911 | /// Transient data (not serialized) | ||
| 912 | Index32 mTransientData = 0; | ||
| 913 | #endif | ||
| 914 | }; // end of LeafNode class | ||
| 915 | |||
| 916 | |||
| 917 | //////////////////////////////////////// | ||
| 918 | |||
| 919 | |||
| 920 | //@{ | ||
| 921 | /// Helper metafunction used to implement LeafNode::SameConfiguration | ||
| 922 | /// (which, as an inner class, can't be independently specialized) | ||
| 923 | template<Index Dim1, typename NodeT2> | ||
| 924 | struct SameLeafConfig { static const bool value = false; }; | ||
| 925 | |||
| 926 | template<Index Dim1, typename T2> | ||
| 927 | struct SameLeafConfig<Dim1, LeafNode<T2, Dim1> > { static const bool value = true; }; | ||
| 928 | //@} | ||
| 929 | |||
| 930 | |||
| 931 | //////////////////////////////////////// | ||
| 932 | |||
| 933 | |||
| 934 | template<typename T, Index Log2Dim> | ||
| 935 | inline | ||
| 936 | 44883 | LeafNode<T, Log2Dim>::LeafNode(): | |
| 937 | mValueMask(),//default is off! | ||
| 938 |
5/13✓ Branch 1 taken 333 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✓ Branch 4 taken 400 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 333 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 400 times.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
|
46362 | mOrigin(0, 0, 0) |
| 939 | { | ||
| 940 | } | ||
| 941 | |||
| 942 | |||
| 943 | template<typename T, Index Log2Dim> | ||
| 944 | inline | ||
| 945 | 11780157 | LeafNode<T, Log2Dim>::LeafNode(const Coord& xyz, const ValueType& val, bool active): | |
| 946 | mBuffer(val), | ||
| 947 | mValueMask(active), | ||
| 948 | 11780157 | mOrigin(xyz & (~(DIM - 1))) | |
| 949 | { | ||
| 950 | 11780157 | } | |
| 951 | |||
| 952 | |||
| 953 | template<typename T, Index Log2Dim> | ||
| 954 | inline | ||
| 955 |
1/2✓ Branch 0 taken 23074 times.
✗ Branch 1 not taken.
|
46148 | LeafNode<T, Log2Dim>::LeafNode(PartialCreate, const Coord& xyz, const ValueType& val, bool active): |
| 956 | mBuffer(PartialCreate(), val), | ||
| 957 | mValueMask(active), | ||
| 958 | 46148 | mOrigin(xyz & (~(DIM - 1))) | |
| 959 | { | ||
| 960 | 46148 | } | |
| 961 | |||
| 962 | |||
| 963 | template<typename T, Index Log2Dim> | ||
| 964 | inline | ||
| 965 | 87898 | LeafNode<T, Log2Dim>::LeafNode(const LeafNode& other) | |
| 966 | 87898 | : mBuffer(other.mBuffer) | |
| 967 | , mValueMask(other.valueMask()) | ||
| 968 | , mOrigin(other.mOrigin) | ||
| 969 | #if OPENVDB_ABI_VERSION_NUMBER >= 9 | ||
| 970 |
0/2✗ Branch 1 not taken.
✗ Branch 2 not taken.
|
87898 | , mTransientData(other.mTransientData) |
| 971 | #endif | ||
| 972 | { | ||
| 973 | 87898 | } | |
| 974 | |||
| 975 | |||
| 976 | // Copy-construct from a leaf node with the same configuration but a different ValueType. | ||
| 977 | template<typename T, Index Log2Dim> | ||
| 978 | template<typename OtherValueType> | ||
| 979 | inline | ||
| 980 | 33625 | LeafNode<T, Log2Dim>::LeafNode(const LeafNode<OtherValueType, Log2Dim>& other) | |
| 981 | : mValueMask(other.valueMask()) | ||
| 982 | , mOrigin(other.mOrigin) | ||
| 983 | #if OPENVDB_ABI_VERSION_NUMBER >= 9 | ||
| 984 | 67250 | , mTransientData(other.mTransientData) | |
| 985 | #endif | ||
| 986 | { | ||
| 987 | struct Local { | ||
| 988 | /// @todo Consider using a value conversion functor passed as an argument instead. | ||
| 989 | 17219584 | static inline ValueType convertValue(const OtherValueType& val) { return ValueType(val); } | |
| 990 | }; | ||
| 991 | |||
| 992 |
2/2✓ Branch 0 taken 17217536 times.
✓ Branch 1 taken 33621 times.
|
17253209 | for (Index i = 0; i < SIZE; ++i) { |
| 993 |
1/2✓ Branch 1 taken 17217536 times.
✗ Branch 2 not taken.
|
34439168 | mBuffer[i] = Local::convertValue(other.mBuffer[i]); |
| 994 | } | ||
| 995 | 33625 | } | |
| 996 | |||
| 997 | |||
| 998 | template<typename T, Index Log2Dim> | ||
| 999 | template<typename OtherValueType> | ||
| 1000 | inline | ||
| 1001 | 85826 | LeafNode<T, Log2Dim>::LeafNode(const LeafNode<OtherValueType, Log2Dim>& other, | |
| 1002 | const ValueType& background, TopologyCopy) | ||
| 1003 | : mBuffer(background) | ||
| 1004 | , mValueMask(other.valueMask()) | ||
| 1005 | , mOrigin(other.mOrigin) | ||
| 1006 | #if OPENVDB_ABI_VERSION_NUMBER >= 9 | ||
| 1007 |
23/100✓ Branch 1 taken 5669 times.
✓ Branch 2 taken 3848 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9515 times.
✓ Branch 5 taken 2526 times.
✓ Branch 6 taken 32 times.
✓ Branch 7 taken 751 times.
✓ Branch 8 taken 136 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 4078 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 10519 times.
✓ Branch 13 taken 16510 times.
✓ Branch 14 taken 16 times.
✓ Branch 15 taken 3254 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 16049 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✓ Branch 22 taken 1833 times.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✓ Branch 26 taken 793 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 3517 times.
✓ Branch 29 taken 6 times.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✓ Branch 33 taken 4 times.
✓ Branch 34 taken 24 times.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✓ Branch 38 taken 72 times.
✗ Branch 39 not taken.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✗ Branch 46 not taken.
✗ Branch 47 not taken.
✗ Branch 48 not taken.
✗ Branch 49 not taken.
✗ Branch 50 not taken.
✓ Branch 51 taken 18 times.
✗ Branch 52 not taken.
✗ Branch 53 not taken.
✗ Branch 55 not taken.
✗ Branch 56 not taken.
✗ Branch 58 not taken.
✗ Branch 59 not taken.
✗ Branch 60 not taken.
✗ Branch 61 not taken.
✗ Branch 62 not taken.
✗ Branch 63 not taken.
✗ Branch 64 not taken.
✗ Branch 65 not taken.
✗ Branch 67 not taken.
✗ Branch 68 not taken.
✗ Branch 70 not taken.
✗ Branch 71 not taken.
✗ Branch 72 not taken.
✗ Branch 73 not taken.
✗ Branch 74 not taken.
✗ Branch 76 not taken.
✗ Branch 77 not taken.
✗ Branch 79 not taken.
✗ Branch 80 not taken.
✗ Branch 82 not taken.
✗ Branch 83 not taken.
✗ Branch 85 not taken.
✗ Branch 86 not taken.
✗ Branch 88 not taken.
✗ Branch 89 not taken.
✗ Branch 91 not taken.
✗ Branch 92 not taken.
✗ Branch 94 not taken.
✗ Branch 95 not taken.
✗ Branch 97 not taken.
✗ Branch 98 not taken.
✗ Branch 100 not taken.
✗ Branch 101 not taken.
✗ Branch 103 not taken.
✗ Branch 104 not taken.
✗ Branch 106 not taken.
✗ Branch 107 not taken.
✗ Branch 109 not taken.
✗ Branch 110 not taken.
✓ Branch 112 taken 1408 times.
✗ Branch 113 not taken.
✓ Branch 115 taken 5248 times.
✗ Branch 116 not taken.
✗ Branch 118 not taken.
✗ Branch 119 not taken.
|
171652 | , mTransientData(other.mTransientData) |
| 1008 | #endif | ||
| 1009 | { | ||
| 1010 | } | ||
| 1011 | |||
| 1012 | |||
| 1013 | template<typename T, Index Log2Dim> | ||
| 1014 | template<typename OtherValueType> | ||
| 1015 | inline | ||
| 1016 | 9 | LeafNode<T, Log2Dim>::LeafNode(const LeafNode<OtherValueType, Log2Dim>& other, | |
| 1017 | const ValueType& offValue, const ValueType& onValue, TopologyCopy) | ||
| 1018 | : mValueMask(other.valueMask()) | ||
| 1019 | , mOrigin(other.mOrigin) | ||
| 1020 | #if OPENVDB_ABI_VERSION_NUMBER >= 9 | ||
| 1021 | 18 | , mTransientData(other.mTransientData) | |
| 1022 | #endif | ||
| 1023 | { | ||
| 1024 |
2/2✓ Branch 0 taken 2560 times.
✓ Branch 1 taken 5 times.
|
4617 | for (Index i = 0; i < SIZE; ++i) { |
| 1025 |
2/2✓ Branch 1 taken 512 times.
✓ Branch 2 taken 2048 times.
|
9216 | mBuffer[i] = (mValueMask.isOn(i) ? onValue : offValue); |
| 1026 | } | ||
| 1027 | 9 | } | |
| 1028 | |||
| 1029 | |||
| 1030 | template<typename T, Index Log2Dim> | ||
| 1031 | inline | ||
| 1032 | LeafNode<T, Log2Dim>::~LeafNode() | ||
| 1033 | { | ||
| 1034 |
1/2✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
|
6079330 | } |
| 1035 | |||
| 1036 | |||
| 1037 | template<typename T, Index Log2Dim> | ||
| 1038 | inline std::string | ||
| 1039 | LeafNode<T, Log2Dim>::str() const | ||
| 1040 | { | ||
| 1041 | std::ostringstream ostr; | ||
| 1042 | ostr << "LeafNode @" << mOrigin << ": " << mBuffer; | ||
| 1043 | return ostr.str(); | ||
| 1044 | } | ||
| 1045 | |||
| 1046 | |||
| 1047 | //////////////////////////////////////// | ||
| 1048 | |||
| 1049 | |||
| 1050 | template<typename T, Index Log2Dim> | ||
| 1051 | inline Index | ||
| 1052 | LeafNode<T, Log2Dim>::coordToOffset(const Coord& xyz) | ||
| 1053 | { | ||
| 1054 | 2545225891 | assert ((xyz[0] & (DIM-1u)) < DIM && (xyz[1] & (DIM-1u)) < DIM && (xyz[2] & (DIM-1u)) < DIM); | |
| 1055 | 2545225891 | return ((xyz[0] & (DIM-1u)) << 2*Log2Dim) | |
| 1056 | 2545225891 | + ((xyz[1] & (DIM-1u)) << Log2Dim) | |
| 1057 |
19/82✗ Branch 0 not taken.
✓ Branch 1 taken 5640 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 264 times.
✓ Branch 4 taken 17 times.
✓ Branch 5 taken 4 times.
✓ Branch 6 taken 257026 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 17 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 41344 times.
✓ Branch 11 taken 4 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 3 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 15 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✓ Branch 20 taken 1 times.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✓ Branch 23 taken 8 times.
✓ Branch 24 taken 2 times.
✗ Branch 25 not taken.
✓ Branch 26 taken 6 times.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✓ Branch 29 taken 15 times.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✓ Branch 32 taken 1654104 times.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 46 not taken.
✗ Branch 47 not taken.
✗ Branch 49 not taken.
✗ Branch 50 not taken.
✗ Branch 52 not taken.
✗ Branch 53 not taken.
✗ Branch 55 not taken.
✗ Branch 56 not taken.
✗ Branch 58 not taken.
✗ Branch 59 not taken.
✗ Branch 61 not taken.
✗ Branch 62 not taken.
✗ Branch 64 not taken.
✗ Branch 65 not taken.
✗ Branch 67 not taken.
✗ Branch 68 not taken.
✗ Branch 70 not taken.
✗ Branch 71 not taken.
✗ Branch 73 not taken.
✗ Branch 74 not taken.
✓ Branch 76 taken 4 times.
✗ Branch 77 not taken.
✓ Branch 79 taken 4 times.
✗ Branch 80 not taken.
✗ Branch 82 not taken.
✗ Branch 83 not taken.
✗ Branch 85 not taken.
✗ Branch 86 not taken.
✗ Branch 88 not taken.
✗ Branch 89 not taken.
✗ Branch 91 not taken.
✗ Branch 92 not taken.
✗ Branch 94 not taken.
✗ Branch 95 not taken.
✗ Branch 97 not taken.
✗ Branch 98 not taken.
✗ Branch 100 not taken.
✗ Branch 101 not taken.
✓ Branch 103 taken 3837100 times.
✗ Branch 104 not taken.
|
704680159 | + (xyz[2] & (DIM-1u)); |
| 1058 | } | ||
| 1059 | |||
| 1060 | template<typename T, Index Log2Dim> | ||
| 1061 | inline Coord | ||
| 1062 | 8868062148 | LeafNode<T, Log2Dim>::offsetToLocalCoord(Index n) | |
| 1063 | { | ||
| 1064 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 4444854948 times.
|
8868062148 | assert(n<(1<< 3*Log2Dim)); |
| 1065 | Coord xyz; | ||
| 1066 | 8868062148 | xyz.setX(n >> 2*Log2Dim); | |
| 1067 | 8868062148 | n &= ((1<<2*Log2Dim)-1); | |
| 1068 | 8868062148 | xyz.setY(n >> Log2Dim); | |
| 1069 | 8868062148 | xyz.setZ(n & ((1<<Log2Dim)-1)); | |
| 1070 | 8868062148 | return xyz; | |
| 1071 | } | ||
| 1072 | |||
| 1073 | |||
| 1074 | template<typename T, Index Log2Dim> | ||
| 1075 | inline Coord | ||
| 1076 | 508882843 | LeafNode<T, Log2Dim>::offsetToGlobalCoord(Index n) const | |
| 1077 | { | ||
| 1078 | 508882843 | return (this->offsetToLocalCoord(n) + this->origin()); | |
| 1079 | } | ||
| 1080 | |||
| 1081 | |||
| 1082 | //////////////////////////////////////// | ||
| 1083 | |||
| 1084 | |||
| 1085 | template<typename ValueT, Index Log2Dim> | ||
| 1086 | inline const ValueT& | ||
| 1087 | 1446046736 | LeafNode<ValueT, Log2Dim>::getValue(const Coord& xyz) const | |
| 1088 | { | ||
| 1089 | 1446046736 | return this->getValue(LeafNode::coordToOffset(xyz)); | |
| 1090 | } | ||
| 1091 | |||
| 1092 | template<typename ValueT, Index Log2Dim> | ||
| 1093 | inline const ValueT& | ||
| 1094 | 2395982389 | LeafNode<ValueT, Log2Dim>::getValue(Index offset) const | |
| 1095 | { | ||
| 1096 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1200523297 times.
|
2395982389 | assert(offset < SIZE); |
| 1097 |
27/54✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1 times.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 1 times.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 1 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 1 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 1 times.
✗ Branch 29 not taken.
✓ Branch 31 taken 1 times.
✗ Branch 32 not taken.
✓ Branch 34 taken 1 times.
✗ Branch 35 not taken.
✓ Branch 37 taken 1 times.
✗ Branch 38 not taken.
✓ Branch 40 taken 1 times.
✗ Branch 41 not taken.
✓ Branch 43 taken 1 times.
✗ Branch 44 not taken.
✓ Branch 46 taken 1 times.
✗ Branch 47 not taken.
✓ Branch 49 taken 1 times.
✗ Branch 50 not taken.
✓ Branch 52 taken 1 times.
✗ Branch 53 not taken.
✓ Branch 55 taken 1 times.
✗ Branch 56 not taken.
✓ Branch 58 taken 1 times.
✗ Branch 59 not taken.
✓ Branch 61 taken 1 times.
✗ Branch 62 not taken.
✓ Branch 64 taken 1 times.
✗ Branch 65 not taken.
✓ Branch 67 taken 1 times.
✗ Branch 68 not taken.
✓ Branch 70 taken 1 times.
✗ Branch 71 not taken.
✓ Branch 73 taken 1 times.
✗ Branch 74 not taken.
✓ Branch 76 taken 1 times.
✗ Branch 77 not taken.
|
2395993176 | return mBuffer[offset]; |
| 1098 | } | ||
| 1099 | |||
| 1100 | |||
| 1101 | template<typename T, Index Log2Dim> | ||
| 1102 | inline bool | ||
| 1103 | 1994932138 | LeafNode<T, Log2Dim>::probeValue(const Coord& xyz, ValueType& val) const | |
| 1104 | { | ||
| 1105 | 1994932138 | return this->probeValue(LeafNode::coordToOffset(xyz), val); | |
| 1106 | } | ||
| 1107 | |||
| 1108 | template<typename T, Index Log2Dim> | ||
| 1109 | inline bool | ||
| 1110 | 1994932138 | LeafNode<T, Log2Dim>::probeValue(Index offset, ValueType& val) const | |
| 1111 | { | ||
| 1112 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 999284969 times.
|
1994932138 | assert(offset < SIZE); |
| 1113 | 1994932138 | val = mBuffer[offset]; | |
| 1114 | 1994932138 | return mValueMask.isOn(offset); | |
| 1115 | } | ||
| 1116 | |||
| 1117 | |||
| 1118 | template<typename T, Index Log2Dim> | ||
| 1119 | inline void | ||
| 1120 | 8801555 | LeafNode<T, Log2Dim>::setValueOff(const Coord& xyz, const ValueType& val) | |
| 1121 | { | ||
| 1122 | 8801555 | this->setValueOff(LeafNode::coordToOffset(xyz), val); | |
| 1123 | 8801555 | } | |
| 1124 | |||
| 1125 | template<typename T, Index Log2Dim> | ||
| 1126 | inline void | ||
| 1127 | 11557955 | LeafNode<T, Log2Dim>::setValueOff(Index offset, const ValueType& val) | |
| 1128 | { | ||
| 1129 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 5779029 times.
|
11557955 | assert(offset < SIZE); |
| 1130 |
13/26✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 1 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 1 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 1 times.
✗ Branch 29 not taken.
✓ Branch 31 taken 1 times.
✗ Branch 32 not taken.
✓ Branch 34 taken 1 times.
✗ Branch 35 not taken.
✓ Branch 37 taken 1 times.
✗ Branch 38 not taken.
|
11557968 | mBuffer.setValue(offset, val); |
| 1131 | 11557968 | mValueMask.setOff(offset); | |
| 1132 | 11557955 | } | |
| 1133 | |||
| 1134 | |||
| 1135 | template<typename T, Index Log2Dim> | ||
| 1136 | inline void | ||
| 1137 | 354102 | LeafNode<T, Log2Dim>::setActiveState(const Coord& xyz, bool on) | |
| 1138 | { | ||
| 1139 |
2/2✓ Branch 0 taken 177059 times.
✓ Branch 1 taken 1 times.
|
354102 | mValueMask.set(this->coordToOffset(xyz), on); |
| 1140 | 354102 | } | |
| 1141 | |||
| 1142 | |||
| 1143 | template<typename T, Index Log2Dim> | ||
| 1144 | inline void | ||
| 1145 | 16272169 | LeafNode<T, Log2Dim>::setValueOnly(const Coord& xyz, const ValueType& val) | |
| 1146 | { | ||
| 1147 | 16272169 | this->setValueOnly(LeafNode::coordToOffset(xyz), val); | |
| 1148 | 16272169 | } | |
| 1149 | |||
| 1150 | template<typename T, Index Log2Dim> | ||
| 1151 | inline void | ||
| 1152 | 104273471 | LeafNode<T, Log2Dim>::setValueOnly(Index offset, const ValueType& val) | |
| 1153 | { | ||
| 1154 |
56/113✗ Branch 0 not taken.
✓ Branch 1 taken 52441495 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 1 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 1 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 1 times.
✗ Branch 29 not taken.
✓ Branch 31 taken 1 times.
✗ Branch 32 not taken.
✓ Branch 34 taken 1 times.
✗ Branch 35 not taken.
✓ Branch 37 taken 1 times.
✗ Branch 38 not taken.
✓ Branch 40 taken 1 times.
✗ Branch 41 not taken.
✓ Branch 43 taken 1 times.
✗ Branch 44 not taken.
✓ Branch 46 taken 1 times.
✗ Branch 47 not taken.
✓ Branch 49 taken 1 times.
✗ Branch 50 not taken.
✓ Branch 52 taken 1 times.
✗ Branch 53 not taken.
✓ Branch 55 taken 1 times.
✗ Branch 56 not taken.
✓ Branch 58 taken 1 times.
✗ Branch 59 not taken.
✓ Branch 61 taken 1 times.
✗ Branch 62 not taken.
✓ Branch 64 taken 1 times.
✗ Branch 65 not taken.
✓ Branch 67 taken 1 times.
✗ Branch 68 not taken.
✓ Branch 70 taken 1 times.
✗ Branch 71 not taken.
✓ Branch 73 taken 1 times.
✗ Branch 74 not taken.
✓ Branch 76 taken 1 times.
✗ Branch 77 not taken.
✓ Branch 79 taken 1 times.
✗ Branch 80 not taken.
✓ Branch 82 taken 1 times.
✗ Branch 83 not taken.
✓ Branch 85 taken 1 times.
✗ Branch 86 not taken.
✓ Branch 88 taken 1 times.
✗ Branch 89 not taken.
✓ Branch 91 taken 1 times.
✗ Branch 92 not taken.
✓ Branch 94 taken 1 times.
✗ Branch 95 not taken.
✓ Branch 97 taken 1 times.
✗ Branch 98 not taken.
✓ Branch 100 taken 1 times.
✗ Branch 101 not taken.
✓ Branch 103 taken 1 times.
✗ Branch 104 not taken.
✓ Branch 106 taken 1 times.
✗ Branch 107 not taken.
✓ Branch 109 taken 1 times.
✗ Branch 110 not taken.
✓ Branch 112 taken 1 times.
✗ Branch 113 not taken.
✓ Branch 115 taken 1 times.
✗ Branch 116 not taken.
✓ Branch 118 taken 1 times.
✗ Branch 119 not taken.
✓ Branch 121 taken 1 times.
✗ Branch 122 not taken.
✓ Branch 124 taken 1 times.
✗ Branch 125 not taken.
✓ Branch 127 taken 1 times.
✗ Branch 128 not taken.
✓ Branch 130 taken 1 times.
✗ Branch 131 not taken.
✓ Branch 133 taken 1 times.
✗ Branch 134 not taken.
✓ Branch 136 taken 1 times.
✗ Branch 137 not taken.
✓ Branch 139 taken 1 times.
✗ Branch 140 not taken.
✓ Branch 142 taken 1 times.
✗ Branch 143 not taken.
✓ Branch 145 taken 1 times.
✗ Branch 146 not taken.
✓ Branch 148 taken 1 times.
✗ Branch 149 not taken.
✓ Branch 151 taken 1 times.
✗ Branch 152 not taken.
✓ Branch 154 taken 1 times.
✗ Branch 155 not taken.
✓ Branch 157 taken 1 times.
✗ Branch 158 not taken.
✓ Branch 160 taken 1 times.
✗ Branch 161 not taken.
✓ Branch 163 taken 1 times.
✗ Branch 164 not taken.
✓ Branch 166 taken 1 times.
✗ Branch 167 not taken.
|
104273527 | assert(offset<SIZE); mBuffer.setValue(offset, val); |
| 1155 | 104273527 | } | |
| 1156 | |||
| 1157 | |||
| 1158 | //////////////////////////////////////// | ||
| 1159 | |||
| 1160 | |||
| 1161 | template<typename T, Index Log2Dim> | ||
| 1162 | inline void | ||
| 1163 | 8268 | LeafNode<T, Log2Dim>::clip(const CoordBBox& clipBBox, const T& background) | |
| 1164 | { | ||
| 1165 | 8268 | CoordBBox nodeBBox = this->getNodeBoundingBox(); | |
| 1166 | if (!clipBBox.hasOverlap(nodeBBox)) { | ||
| 1167 | // This node lies completely outside the clipping region. Fill it with the background. | ||
| 1168 | ✗ | this->fill(background, /*active=*/false); | |
| 1169 | } else if (clipBBox.isInside(nodeBBox)) { | ||
| 1170 | // This node lies completely inside the clipping region. Leave it intact. | ||
| 1171 | 8222 | return; | |
| 1172 | } | ||
| 1173 | |||
| 1174 | // This node isn't completely contained inside the clipping region. | ||
| 1175 | // Set any voxels that lie outside the region to the background value. | ||
| 1176 | |||
| 1177 | // Construct a boolean mask that is on inside the clipping region and off outside it. | ||
| 1178 | NodeMaskType mask; | ||
| 1179 | 46 | nodeBBox.intersect(clipBBox); | |
| 1180 | Coord xyz; | ||
| 1181 | int &x = xyz.x(), &y = xyz.y(), &z = xyz.z(); | ||
| 1182 |
2/2✓ Branch 0 taken 82 times.
✓ Branch 1 taken 23 times.
|
210 | for (x = nodeBBox.min().x(); x <= nodeBBox.max().x(); ++x) { |
| 1183 |
2/2✓ Branch 0 taken 368 times.
✓ Branch 1 taken 82 times.
|
900 | for (y = nodeBBox.min().y(); y <= nodeBBox.max().y(); ++y) { |
| 1184 |
2/2✓ Branch 0 taken 1698 times.
✓ Branch 1 taken 368 times.
|
4132 | for (z = nodeBBox.min().z(); z <= nodeBBox.max().z(); ++z) { |
| 1185 | 3396 | mask.setOn(static_cast<Index32>(this->coordToOffset(xyz))); | |
| 1186 | } | ||
| 1187 | } | ||
| 1188 | } | ||
| 1189 | |||
| 1190 | // Set voxels that lie in the inactive region of the mask (i.e., outside | ||
| 1191 | // the clipping region) to the background value. | ||
| 1192 |
2/2✓ Branch 1 taken 10078 times.
✓ Branch 2 taken 23 times.
|
20248 | for (MaskOffIterator maskIter = mask.beginOff(); maskIter; ++maskIter) { |
| 1193 | 20156 | this->setValueOff(maskIter.pos(), background); | |
| 1194 | } | ||
| 1195 | } | ||
| 1196 | |||
| 1197 | |||
| 1198 | //////////////////////////////////////// | ||
| 1199 | |||
| 1200 | |||
| 1201 | template<typename T, Index Log2Dim> | ||
| 1202 | inline void | ||
| 1203 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 169903 times.
|
339600 | LeafNode<T, Log2Dim>::fill(const CoordBBox& bbox, const ValueType& value, bool active) |
| 1204 | { | ||
| 1205 |
1/2✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
|
180 | if (!this->allocate()) return; |
| 1206 | |||
| 1207 | 339600 | auto clippedBBox = this->getNodeBoundingBox(); | |
| 1208 | 339600 | clippedBBox.intersect(bbox); | |
| 1209 | if (!clippedBBox) return; | ||
| 1210 | |||
| 1211 |
2/2✓ Branch 0 taken 909285 times.
✓ Branch 1 taken 169993 times.
|
2157424 | for (Int32 x = clippedBBox.min().x(); x <= clippedBBox.max().x(); ++x) { |
| 1212 | 1817824 | const Index offsetX = (x & (DIM-1u)) << 2*Log2Dim; | |
| 1213 |
2/2✓ Branch 0 taken 4732938 times.
✓ Branch 1 taken 909285 times.
|
11280490 | for (Int32 y = clippedBBox.min().y(); y <= clippedBBox.max().y(); ++y) { |
| 1214 | 9462666 | const Index offsetXY = offsetX + ((y & (DIM-1u)) << Log2Dim); | |
| 1215 |
2/2✓ Branch 0 taken 20825678 times.
✓ Branch 1 taken 4732938 times.
|
51094840 | for (Int32 z = clippedBBox.min().z(); z <= clippedBBox.max().z(); ++z) { |
| 1216 | 41632174 | const Index offset = offsetXY + (z & (DIM-1u)); | |
| 1217 | 41631994 | mBuffer[offset] = value; | |
| 1218 |
2/2✓ Branch 0 taken 15176741 times.
✓ Branch 1 taken 5648937 times.
|
41632174 | mValueMask.set(offset, active); |
| 1219 | } | ||
| 1220 | } | ||
| 1221 | } | ||
| 1222 | } | ||
| 1223 | |||
| 1224 | template<typename T, Index Log2Dim> | ||
| 1225 | inline void | ||
| 1226 | LeafNode<T, Log2Dim>::fill(const ValueType& value) | ||
| 1227 | { | ||
| 1228 | 8693 | mBuffer.fill(value); | |
| 1229 | } | ||
| 1230 | |||
| 1231 | template<typename T, Index Log2Dim> | ||
| 1232 | inline void | ||
| 1233 | 1119 | LeafNode<T, Log2Dim>::fill(const ValueType& value, bool active) | |
| 1234 | { | ||
| 1235 | 1119 | mBuffer.fill(value); | |
| 1236 | mValueMask.set(active); | ||
| 1237 | 1119 | } | |
| 1238 | |||
| 1239 | |||
| 1240 | //////////////////////////////////////// | ||
| 1241 | |||
| 1242 | |||
| 1243 | template<typename T, Index Log2Dim> | ||
| 1244 | template<typename DenseT> | ||
| 1245 | inline void | ||
| 1246 | 5202 | LeafNode<T, Log2Dim>::copyToDense(const CoordBBox& bbox, DenseT& dense) const | |
| 1247 | { | ||
| 1248 | 5202 | mBuffer.loadValues(); | |
| 1249 | |||
| 1250 | using DenseValueType = typename DenseT::ValueType; | ||
| 1251 | |||
| 1252 | const size_t xStride = dense.xStride(), yStride = dense.yStride(), zStride = dense.zStride(); | ||
| 1253 | const Coord& min = dense.bbox().min(); | ||
| 1254 | 5202 | DenseValueType* t0 = dense.data() + zStride * (bbox.min()[2] - min[2]); // target array | |
| 1255 | 5202 | const T* s0 = &mBuffer[bbox.min()[2] & (DIM-1u)]; // source array | |
| 1256 |
2/2✓ Branch 0 taken 11323 times.
✓ Branch 1 taken 2601 times.
|
27848 | for (Int32 x = bbox.min()[0], ex = bbox.max()[0] + 1; x < ex; ++x) { |
| 1257 | 22646 | DenseValueType* t1 = t0 + xStride * (x - min[0]); | |
| 1258 | 22646 | const T* s1 = s0 + ((x & (DIM-1u)) << 2*Log2Dim); | |
| 1259 |
2/2✓ Branch 0 taken 51262 times.
✓ Branch 1 taken 11323 times.
|
125170 | for (Int32 y = bbox.min()[1], ey = bbox.max()[1] + 1; y < ey; ++y) { |
| 1260 | 102524 | DenseValueType* t2 = t1 + yStride * (y - min[1]); | |
| 1261 | 102524 | const T* s2 = s1 + ((y & (DIM-1u)) << Log2Dim); | |
| 1262 |
2/2✓ Branch 0 taken 203768 times.
✓ Branch 1 taken 51262 times.
|
510060 | for (Int32 z = bbox.min()[2], ez = bbox.max()[2] + 1; z < ez; ++z, t2 += zStride) { |
| 1263 | 407536 | *t2 = DenseValueType(*s2++); | |
| 1264 | } | ||
| 1265 | } | ||
| 1266 | } | ||
| 1267 | 5202 | } | |
| 1268 | |||
| 1269 | |||
| 1270 | template<typename T, Index Log2Dim> | ||
| 1271 | template<typename DenseT> | ||
| 1272 | inline void | ||
| 1273 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1130 times.
|
2260 | LeafNode<T, Log2Dim>::copyFromDense(const CoordBBox& bbox, const DenseT& dense, |
| 1274 | const ValueType& background, const ValueType& tolerance) | ||
| 1275 | { | ||
| 1276 | if (!this->allocate()) return; | ||
| 1277 | |||
| 1278 | using DenseValueType = typename DenseT::ValueType; | ||
| 1279 | |||
| 1280 | const size_t xStride = dense.xStride(), yStride = dense.yStride(), zStride = dense.zStride(); | ||
| 1281 | const Coord& min = dense.bbox().min(); | ||
| 1282 | |||
| 1283 | 2260 | const DenseValueType* s0 = dense.data() + zStride * (bbox.min()[2] - min[2]); // source | |
| 1284 | 2260 | const Int32 n0 = bbox.min()[2] & (DIM-1u); | |
| 1285 |
2/2✓ Branch 0 taken 7314 times.
✓ Branch 1 taken 1130 times.
|
16888 | for (Int32 x = bbox.min()[0], ex = bbox.max()[0]+1; x < ex; ++x) { |
| 1286 | 14628 | const DenseValueType* s1 = s0 + xStride * (x - min[0]); | |
| 1287 | 14628 | const Int32 n1 = n0 + ((x & (DIM-1u)) << 2*LOG2DIM); | |
| 1288 |
2/2✓ Branch 0 taken 47458 times.
✓ Branch 1 taken 7314 times.
|
109544 | for (Int32 y = bbox.min()[1], ey = bbox.max()[1]+1; y < ey; ++y) { |
| 1289 | 94916 | const DenseValueType* s2 = s1 + yStride * (y - min[1]); | |
| 1290 | 94916 | Int32 n2 = n1 + ((y & (DIM-1u)) << LOG2DIM); | |
| 1291 |
2/2✓ Branch 0 taken 313626 times.
✓ Branch 1 taken 47458 times.
|
722168 | for (Int32 z = bbox.min()[2], ez = bbox.max()[2]+1; z < ez; ++z, ++n2, s2 += zStride) { |
| 1292 |
2/2✓ Branch 0 taken 105064 times.
✓ Branch 1 taken 208562 times.
|
627252 | if (math::isApproxEqual(background, ValueType(*s2), tolerance)) { |
| 1293 | 210128 | mValueMask.setOff(n2); | |
| 1294 | 210128 | mBuffer[n2] = background; | |
| 1295 | } else { | ||
| 1296 | 417124 | mValueMask.setOn(n2); | |
| 1297 | 417124 | mBuffer[n2] = ValueType(*s2); | |
| 1298 | } | ||
| 1299 | } | ||
| 1300 | } | ||
| 1301 | } | ||
| 1302 | } | ||
| 1303 | |||
| 1304 | |||
| 1305 | //////////////////////////////////////// | ||
| 1306 | |||
| 1307 | |||
| 1308 | template<typename T, Index Log2Dim> | ||
| 1309 | inline void | ||
| 1310 | LeafNode<T, Log2Dim>::readTopology(std::istream& is, bool /*fromHalf*/) | ||
| 1311 | { | ||
| 1312 | mValueMask.load(is); | ||
| 1313 | } | ||
| 1314 | |||
| 1315 | |||
| 1316 | template<typename T, Index Log2Dim> | ||
| 1317 | inline void | ||
| 1318 | LeafNode<T, Log2Dim>::writeTopology(std::ostream& os, bool /*toHalf*/) const | ||
| 1319 | { | ||
| 1320 | mValueMask.save(os); | ||
| 1321 | } | ||
| 1322 | |||
| 1323 | |||
| 1324 | //////////////////////////////////////// | ||
| 1325 | |||
| 1326 | |||
| 1327 | |||
| 1328 | template<typename T, Index Log2Dim> | ||
| 1329 | inline void | ||
| 1330 | 46112 | LeafNode<T,Log2Dim>::skipCompressedValues(bool seekable, std::istream& is, bool fromHalf) | |
| 1331 | { | ||
| 1332 |
2/2✓ Branch 0 taken 22873 times.
✓ Branch 1 taken 183 times.
|
46112 | if (seekable) { |
| 1333 | // Seek over voxel values. | ||
| 1334 | 45746 | io::readCompressedValues<ValueType, NodeMaskType>( | |
| 1335 | 45746 | is, nullptr, SIZE, mValueMask, fromHalf); | |
| 1336 | } else { | ||
| 1337 | // Read and discard voxel values. | ||
| 1338 | 732 | Buffer temp; | |
| 1339 |
1/2✓ Branch 1 taken 183 times.
✗ Branch 2 not taken.
|
366 | io::readCompressedValues(is, temp.mData, SIZE, mValueMask, fromHalf); |
| 1340 | } | ||
| 1341 | 46112 | } | |
| 1342 | |||
| 1343 | |||
| 1344 | template<typename T, Index Log2Dim> | ||
| 1345 | inline void | ||
| 1346 | LeafNode<T,Log2Dim>::readBuffers(std::istream& is, bool fromHalf) | ||
| 1347 | { | ||
| 1348 |
12/25✓ Branch 2 taken 10221 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 10221 times.
✗ Branch 6 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✓ Branch 23 taken 1 times.
✗ Branch 24 not taken.
✓ Branch 26 taken 1 times.
✗ Branch 27 not taken.
✓ Branch 30 taken 1 times.
✗ Branch 31 not taken.
✓ Branch 33 taken 1 times.
✗ Branch 34 not taken.
✓ Branch 37 taken 1 times.
✗ Branch 38 not taken.
✓ Branch 40 taken 1 times.
✗ Branch 41 not taken.
|
26872 | this->readBuffers(is, CoordBBox::inf(), fromHalf); |
| 1349 | } | ||
| 1350 | |||
| 1351 | |||
| 1352 | template<typename T, Index Log2Dim> | ||
| 1353 | inline void | ||
| 1354 | 54334 | LeafNode<T,Log2Dim>::readBuffers(std::istream& is, const CoordBBox& clipBBox, bool fromHalf) | |
| 1355 | { | ||
| 1356 | 54334 | SharedPtr<io::StreamMetadata> meta = io::getStreamMetadataPtr(is); | |
| 1357 |
5/6✓ Branch 0 taken 23057 times.
✓ Branch 1 taken 4110 times.
✓ Branch 3 taken 23057 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 184 times.
✓ Branch 6 taken 22873 times.
|
54334 | const bool seekable = meta && meta->seekable(); |
| 1358 | |||
| 1359 |
1/2✓ Branch 1 taken 27167 times.
✗ Branch 2 not taken.
|
54334 | std::streamoff maskpos = is.tellg(); |
| 1360 | |||
| 1361 |
2/2✓ Branch 0 taken 22873 times.
✓ Branch 1 taken 4294 times.
|
54334 | if (seekable) { |
| 1362 | // Seek over the value mask. | ||
| 1363 | mValueMask.seek(is); | ||
| 1364 | } else { | ||
| 1365 | // Read in the value mask. | ||
| 1366 | mValueMask.load(is); | ||
| 1367 | } | ||
| 1368 | |||
| 1369 | 54334 | int8_t numBuffers = 1; | |
| 1370 |
2/4✓ Branch 1 taken 27167 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 27167 times.
|
54334 | if (io::getFormatVersion(is) < OPENVDB_FILE_VERSION_NODE_MASK_COMPRESSION) { |
| 1371 | // Read in the origin. | ||
| 1372 | ✗ | is.read(reinterpret_cast<char*>(&mOrigin), sizeof(Coord::ValueType) * 3); | |
| 1373 | |||
| 1374 | // Read in the number of buffers, which should now always be one. | ||
| 1375 | ✗ | is.read(reinterpret_cast<char*>(&numBuffers), sizeof(int8_t)); | |
| 1376 | } | ||
| 1377 | |||
| 1378 | 54334 | CoordBBox nodeBBox = this->getNodeBoundingBox(); | |
| 1379 | if (!clipBBox.hasOverlap(nodeBBox)) { | ||
| 1380 | // This node lies completely outside the clipping region. | ||
| 1381 |
1/2✓ Branch 1 taken 295 times.
✗ Branch 2 not taken.
|
590 | skipCompressedValues(seekable, is, fromHalf); |
| 1382 | mValueMask.setOff(); | ||
| 1383 | mBuffer.setOutOfCore(false); | ||
| 1384 | } else { | ||
| 1385 | // If this node lies completely inside the clipping region and it is being read | ||
| 1386 | // from a memory-mapped file, delay loading of its buffer until the buffer | ||
| 1387 | // is actually accessed. (If this node requires clipping, its buffer | ||
| 1388 | // must be accessed and therefore must be loaded.) | ||
| 1389 |
1/2✓ Branch 1 taken 26872 times.
✗ Branch 2 not taken.
|
53744 | io::MappedFile::Ptr mappedFile = io::getMappedFilePtr(is); |
| 1390 |
2/2✓ Branch 0 taken 22761 times.
✓ Branch 1 taken 4111 times.
|
53744 | const bool delayLoad = ((mappedFile.get() != nullptr) && clipBBox.isInside(nodeBBox)); |
| 1391 | |||
| 1392 | if (delayLoad) { | ||
| 1393 | mBuffer.setOutOfCore(true); | ||
| 1394 |
1/2✓ Branch 1 taken 22761 times.
✗ Branch 2 not taken.
|
45522 | mBuffer.mFileInfo = new typename Buffer::FileInfo; |
| 1395 | mBuffer.mFileInfo->meta = meta; | ||
| 1396 |
1/2✓ Branch 1 taken 22761 times.
✗ Branch 2 not taken.
|
45522 | mBuffer.mFileInfo->bufpos = is.tellg(); |
| 1397 | 45522 | mBuffer.mFileInfo->mapping = mappedFile; | |
| 1398 | // Save the offset to the value mask, because the in-memory copy | ||
| 1399 | // might change before the value buffer gets read. | ||
| 1400 | 45522 | mBuffer.mFileInfo->maskpos = maskpos; | |
| 1401 | // Skip over voxel values. | ||
| 1402 |
1/2✓ Branch 1 taken 22761 times.
✗ Branch 2 not taken.
|
45522 | skipCompressedValues(seekable, is, fromHalf); |
| 1403 | } else { | ||
| 1404 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
4 | mBuffer.allocate(); |
| 1405 |
1/2✓ Branch 1 taken 4111 times.
✗ Branch 2 not taken.
|
8222 | io::readCompressedValues(is, mBuffer.mData, SIZE, mValueMask, fromHalf); |
| 1406 | mBuffer.setOutOfCore(false); | ||
| 1407 | |||
| 1408 | // Get this tree's background value. | ||
| 1409 | 7194 | T background = zeroVal<T>(); | |
| 1410 |
3/4✓ Branch 1 taken 4111 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
✓ Branch 4 taken 4103 times.
|
8222 | if (const void* bgPtr = io::getGridBackgroundValuePtr(is)) { |
| 1411 | 16 | background = *static_cast<const T*>(bgPtr); | |
| 1412 | } | ||
| 1413 |
1/2✓ Branch 1 taken 4111 times.
✗ Branch 2 not taken.
|
8222 | this->clip(clipBBox, background); |
| 1414 | } | ||
| 1415 | } | ||
| 1416 | |||
| 1417 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 27167 times.
|
54334 | if (numBuffers > 1) { |
| 1418 | // Read in and discard auxiliary buffers that were created with earlier | ||
| 1419 | // versions of the library. (Auxiliary buffers are not mask compressed.) | ||
| 1420 | ✗ | const bool zipped = io::getDataCompression(is) & io::COMPRESS_ZIP; | |
| 1421 | ✗ | Buffer temp; | |
| 1422 | ✗ | for (int i = 1; i < numBuffers; ++i) { | |
| 1423 | ✗ | if (fromHalf) { | |
| 1424 | ✗ | io::HalfReader<io::RealToHalf<T>::isReal, T>::read(is, temp.mData, SIZE, zipped); | |
| 1425 | } else { | ||
| 1426 | ✗ | io::readData<T>(is, temp.mData, SIZE, zipped); | |
| 1427 | } | ||
| 1428 | } | ||
| 1429 | } | ||
| 1430 | |||
| 1431 | // increment the leaf number | ||
| 1432 |
4/6✓ Branch 0 taken 23057 times.
✓ Branch 1 taken 4110 times.
✓ Branch 3 taken 23057 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 23057 times.
✗ Branch 7 not taken.
|
54334 | if (meta) meta->setLeaf(meta->leaf() + 1); |
| 1433 | 54334 | } | |
| 1434 | |||
| 1435 | |||
| 1436 | template<typename T, Index Log2Dim> | ||
| 1437 | inline void | ||
| 1438 | 80124 | LeafNode<T, Log2Dim>::writeBuffers(std::ostream& os, bool toHalf) const | |
| 1439 | { | ||
| 1440 | // Write out the value mask. | ||
| 1441 | mValueMask.save(os); | ||
| 1442 | |||
| 1443 | 80124 | mBuffer.loadValues(); | |
| 1444 | |||
| 1445 | 80124 | io::writeCompressedValues(os, mBuffer.mData, SIZE, | |
| 1446 | 80124 | mValueMask, /*childMask=*/NodeMaskType(), toHalf); | |
| 1447 | 80124 | } | |
| 1448 | |||
| 1449 | |||
| 1450 | //////////////////////////////////////// | ||
| 1451 | |||
| 1452 | |||
| 1453 | template<typename T, Index Log2Dim> | ||
| 1454 | inline bool | ||
| 1455 |
1/2✓ Branch 0 taken 628 times.
✗ Branch 1 not taken.
|
628 | LeafNode<T, Log2Dim>::operator==(const LeafNode& other) const |
| 1456 | { | ||
| 1457 |
2/2✓ Branch 0 taken 625 times.
✓ Branch 1 taken 2 times.
|
627 | return mOrigin == other.mOrigin && |
| 1458 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 624 times.
|
625 | mValueMask == other.valueMask() && |
| 1459 | 625 | mBuffer == other.mBuffer; | |
| 1460 | } | ||
| 1461 | |||
| 1462 | |||
| 1463 | template<typename T, Index Log2Dim> | ||
| 1464 | inline Index64 | ||
| 1465 |
2/2✓ Branch 0 taken 56914 times.
✓ Branch 1 taken 11607 times.
|
137042 | LeafNode<T, Log2Dim>::memUsage() const |
| 1466 | { | ||
| 1467 | // Use sizeof(*this) to capture alignment-related padding | ||
| 1468 | // (but note that sizeof(*this) includes sizeof(mBuffer)). | ||
| 1469 | 137042 | return sizeof(*this) + mBuffer.memUsage() - sizeof(mBuffer); | |
| 1470 | } | ||
| 1471 | |||
| 1472 | |||
| 1473 | template<typename T, Index Log2Dim> | ||
| 1474 | inline Index64 | ||
| 1475 | LeafNode<T, Log2Dim>::memUsageIfLoaded() const | ||
| 1476 | { | ||
| 1477 | // Use sizeof(*this) to capture alignment-related padding | ||
| 1478 | // (but note that sizeof(*this) includes sizeof(mBuffer)). | ||
| 1479 | return sizeof(*this) + mBuffer.memUsageIfLoaded() - sizeof(mBuffer); | ||
| 1480 | } | ||
| 1481 | |||
| 1482 | |||
| 1483 | template<typename T, Index Log2Dim> | ||
| 1484 | inline void | ||
| 1485 | 236725 | LeafNode<T, Log2Dim>::evalActiveBoundingBox(CoordBBox& bbox, bool visitVoxels) const | |
| 1486 | { | ||
| 1487 | 236725 | CoordBBox this_bbox = this->getNodeBoundingBox(); | |
| 1488 | 194842 | if (bbox.isInside(this_bbox)) return;//this LeafNode is already enclosed in the bbox | |
| 1489 |
2/2✓ Branch 0 taken 21779 times.
✓ Branch 1 taken 156 times.
|
41883 | if (ValueOnCIter iter = this->cbeginValueOn()) {//any active values? |
| 1490 |
2/2✓ Branch 0 taken 20774 times.
✓ Branch 1 taken 1005 times.
|
41571 | if (visitVoxels) {//use voxel granularity? |
| 1491 | 39561 | this_bbox.reset(); | |
| 1492 |
2/2✓ Branch 0 taken 1739965 times.
✓ Branch 1 taken 20774 times.
|
3220402 | for(; iter; ++iter) this_bbox.expand(this->offsetToLocalCoord(iter.pos())); |
| 1493 | this_bbox.translate(this->origin()); | ||
| 1494 | } | ||
| 1495 | 41571 | bbox.expand(this_bbox); | |
| 1496 | } | ||
| 1497 | } | ||
| 1498 | |||
| 1499 | |||
| 1500 | template<typename T, Index Log2Dim> | ||
| 1501 | template<typename OtherType, Index OtherLog2Dim> | ||
| 1502 | inline bool | ||
| 1503 | 9474 | LeafNode<T, Log2Dim>::hasSameTopology(const LeafNode<OtherType, OtherLog2Dim>* other) const | |
| 1504 | { | ||
| 1505 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 4373 times.
|
9474 | assert(other); |
| 1506 | 9474 | return (Log2Dim == OtherLog2Dim && mValueMask == other->getValueMask()); | |
| 1507 | } | ||
| 1508 | |||
| 1509 | template<typename T, Index Log2Dim> | ||
| 1510 | inline bool | ||
| 1511 |
2/2✓ Branch 0 taken 6889 times.
✓ Branch 1 taken 16169 times.
|
44986 | LeafNode<T, Log2Dim>::isConstant(ValueType& firstValue, |
| 1512 | bool& state, | ||
| 1513 | const ValueType& tolerance) const | ||
| 1514 | { | ||
| 1515 |
2/2✓ Branch 0 taken 15853 times.
✓ Branch 1 taken 2436 times.
|
35916 | if (!mValueMask.isConstant(state)) return false;// early termination |
| 1516 | 31280 | firstValue = mBuffer[0]; | |
| 1517 |
2/2✓ Branch 0 taken 286242 times.
✓ Branch 1 taken 525 times.
|
402284 | for (Index i = 1; i < SIZE; ++i) { |
| 1518 |
2/3✓ Branch 0 taken 249963 times.
✓ Branch 1 taken 5946 times.
✗ Branch 2 not taken.
|
340898 | if ( !math::isApproxEqual(mBuffer[i], firstValue, tolerance) ) return false;// early termination |
| 1519 | } | ||
| 1520 | return true; | ||
| 1521 | } | ||
| 1522 | |||
| 1523 | template<typename T, Index Log2Dim> | ||
| 1524 | inline bool | ||
| 1525 |
2/2✓ Branch 0 taken 22370 times.
✓ Branch 1 taken 12632 times.
|
65298 | LeafNode<T, Log2Dim>::isConstant(ValueType& minValue, |
| 1526 | ValueType& maxValue, | ||
| 1527 | bool& state, | ||
| 1528 | const ValueType& tolerance) const | ||
| 1529 | { | ||
| 1530 |
2/2✓ Branch 0 taken 16512 times.
✓ Branch 1 taken 5412 times.
|
39142 | if (!mValueMask.isConstant(state)) return false;// early termination |
| 1531 | 28318 | minValue = maxValue = mBuffer[0]; | |
| 1532 |
2/2✓ Branch 0 taken 8002731 times.
✓ Branch 1 taken 15448 times.
|
13626886 | for (Index i = 1; i < SIZE; ++i) { |
| 1533 | const T& v = mBuffer[i]; | ||
| 1534 |
3/3✓ Branch 0 taken 472 times.
✓ Branch 1 taken 7218729 times.
✓ Branch 2 taken 783530 times.
|
13600696 | if (v < minValue) { |
| 1535 |
3/3✓ Branch 0 taken 14 times.
✓ Branch 1 taken 458 times.
✓ Branch 2 taken 73 times.
|
1090 | if ((maxValue - v) > tolerance) return false;// early termination |
| 1536 | 28 | minValue = v; | |
| 1537 |
3/3✓ Branch 0 taken 473 times.
✓ Branch 1 taken 7218255 times.
✓ Branch 2 taken 783458 times.
|
13599606 | } else if (v > maxValue) { |
| 1538 |
3/3✓ Branch 0 taken 12 times.
✓ Branch 1 taken 461 times.
✓ Branch 2 taken 72 times.
|
1090 | if ((v - minValue) > tolerance) return false;// early termination |
| 1539 | 24 | maxValue = v; | |
| 1540 | } | ||
| 1541 | } | ||
| 1542 | return true; | ||
| 1543 | } | ||
| 1544 | |||
| 1545 | template<typename T, Index Log2Dim> | ||
| 1546 | inline T | ||
| 1547 | 15488 | LeafNode<T, Log2Dim>::medianAll(T *tmp) const | |
| 1548 | { | ||
| 1549 | 15488 | std::unique_ptr<T[]> data(nullptr); | |
| 1550 |
2/2✓ Branch 0 taken 13 times.
✓ Branch 1 taken 4740 times.
|
15488 | if (tmp == nullptr) {//allocate temporary storage |
| 1551 |
1/4✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
|
13 | data.reset(new T[NUM_VALUES]); |
| 1552 | tmp = data.get(); | ||
| 1553 | } | ||
| 1554 |
3/4✓ Branch 1 taken 4753 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
✓ Branch 4 taken 4740 times.
|
15488 | if (tmp != mBuffer.data()) { |
| 1555 |
1/2✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
|
13 | const T* src = mBuffer.data(); |
| 1556 |
2/2✓ Branch 0 taken 6656 times.
✓ Branch 1 taken 13 times.
|
6669 | for (T* dst = tmp; dst-tmp < NUM_VALUES;) *dst++ = *src++; |
| 1557 | } | ||
| 1558 | static const size_t midpoint = (NUM_VALUES - 1) >> 1; | ||
| 1559 | 15488 | std::nth_element(tmp, tmp + midpoint, tmp + NUM_VALUES); | |
| 1560 |
2/2✓ Branch 0 taken 13 times.
✓ Branch 1 taken 4740 times.
|
15501 | return tmp[midpoint]; |
| 1561 | } | ||
| 1562 | |||
| 1563 | template<typename T, Index Log2Dim> | ||
| 1564 | inline Index | ||
| 1565 | 11 | LeafNode<T, Log2Dim>::medianOn(T &value, T *tmp) const | |
| 1566 | { | ||
| 1567 | 11 | const Index count = mValueMask.countOn(); | |
| 1568 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 10 times.
|
11 | if (count == NUM_VALUES) {//special case: all voxels are active |
| 1569 | 1 | value = this->medianAll(tmp); | |
| 1570 | 1 | return NUM_VALUES; | |
| 1571 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 1 times.
|
10 | } else if (count == 0) { |
| 1572 | return 0; | ||
| 1573 | } | ||
| 1574 | 9 | std::unique_ptr<T[]> data(nullptr); | |
| 1575 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | if (tmp == nullptr) {//allocate temporary storage |
| 1576 |
1/2✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
|
9 | data.reset(new T[count]);// 0 < count < NUM_VALUES |
| 1577 | tmp = data.get(); | ||
| 1578 | } | ||
| 1579 |
2/2✓ Branch 0 taken 45 times.
✓ Branch 1 taken 9 times.
|
99 | for (auto iter=this->cbeginValueOn(); iter; ++iter) *tmp++ = *iter; |
| 1580 | 9 | T *begin = tmp - count; | |
| 1581 | 9 | const size_t midpoint = (count - 1) >> 1; | |
| 1582 | 9 | std::nth_element(begin, begin + midpoint, tmp); | |
| 1583 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | value = begin[midpoint]; |
| 1584 | return count; | ||
| 1585 | } | ||
| 1586 | |||
| 1587 | template<typename T, Index Log2Dim> | ||
| 1588 | inline Index | ||
| 1589 | 11 | LeafNode<T, Log2Dim>::medianOff(T &value, T *tmp) const | |
| 1590 | { | ||
| 1591 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 10 times.
|
11 | const Index count = mValueMask.countOff(); |
| 1592 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 10 times.
|
11 | if (count == NUM_VALUES) {//special case: all voxels are inactive |
| 1593 | 1 | value = this->medianAll(tmp); | |
| 1594 | 1 | return NUM_VALUES; | |
| 1595 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 1 times.
|
10 | } else if (count == 0) { |
| 1596 | return 0; | ||
| 1597 | } | ||
| 1598 | 9 | std::unique_ptr<T[]> data(nullptr); | |
| 1599 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | if (tmp == nullptr) {//allocate temporary storage |
| 1600 |
1/2✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
|
9 | data.reset(new T[count]);// 0 < count < NUM_VALUES |
| 1601 | tmp = data.get(); | ||
| 1602 | } | ||
| 1603 |
2/2✓ Branch 0 taken 4563 times.
✓ Branch 1 taken 9 times.
|
9135 | for (auto iter=this->cbeginValueOff(); iter; ++iter) *tmp++ = *iter; |
| 1604 | 9 | T *begin = tmp - count; | |
| 1605 | 9 | const size_t midpoint = (count - 1) >> 1; | |
| 1606 | 9 | std::nth_element(begin, begin + midpoint, tmp); | |
| 1607 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | value = begin[midpoint]; |
| 1608 | return count; | ||
| 1609 | } | ||
| 1610 | |||
| 1611 | //////////////////////////////////////// | ||
| 1612 | |||
| 1613 | |||
| 1614 | template<typename T, Index Log2Dim> | ||
| 1615 | inline void | ||
| 1616 | 4 | LeafNode<T, Log2Dim>::addTile(Index /*level*/, const Coord& xyz, const ValueType& val, bool active) | |
| 1617 | { | ||
| 1618 | 4 | this->addTile(this->coordToOffset(xyz), val, active); | |
| 1619 | } | ||
| 1620 | |||
| 1621 | template<typename T, Index Log2Dim> | ||
| 1622 | inline void | ||
| 1623 | 4 | LeafNode<T, Log2Dim>::addTile(Index offset, const ValueType& val, bool active) | |
| 1624 | { | ||
| 1625 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
4 | assert(offset < SIZE); |
| 1626 | 4 | setValueOnly(offset, val); | |
| 1627 | 4 | setActiveState(offset, active); | |
| 1628 | } | ||
| 1629 | |||
| 1630 | template<typename T, Index Log2Dim> | ||
| 1631 | template<typename AccessorT> | ||
| 1632 | inline void | ||
| 1633 | LeafNode<T, Log2Dim>::addTileAndCache(Index level, const Coord& xyz, | ||
| 1634 | const ValueType& val, bool active, AccessorT&) | ||
| 1635 | { | ||
| 1636 | ✗ | this->addTile(level, xyz, val, active); | |
| 1637 | } | ||
| 1638 | |||
| 1639 | |||
| 1640 | //////////////////////////////////////// | ||
| 1641 | |||
| 1642 | |||
| 1643 | template<typename T, Index Log2Dim> | ||
| 1644 | inline void | ||
| 1645 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 20866 times.
|
21710 | LeafNode<T, Log2Dim>::resetBackground(const ValueType& oldBackground, |
| 1646 | const ValueType& newBackground) | ||
| 1647 | { | ||
| 1648 | if (!this->allocate()) return; | ||
| 1649 | |||
| 1650 | typename NodeMaskType::OffIterator iter; | ||
| 1651 | // For all inactive values... | ||
| 1652 |
2/2✓ Branch 1 taken 6829447 times.
✓ Branch 2 taken 20866 times.
|
7255439 | for (iter = this->mValueMask.beginOff(); iter; ++iter) { |
| 1653 | 7212019 | ValueType &inactiveValue = mBuffer[iter.pos()]; | |
| 1654 |
2/2✓ Branch 0 taken 5754789 times.
✓ Branch 1 taken 1074658 times.
|
7212019 | if (math::isApproxEqual(inactiveValue, oldBackground)) { |
| 1655 | 6137361 | inactiveValue = newBackground; | |
| 1656 |
1/2✓ Branch 0 taken 1074658 times.
✗ Branch 1 not taken.
|
1074658 | } else if (math::isApproxEqual(inactiveValue, math::negative(oldBackground))) { |
| 1657 | 1074658 | inactiveValue = math::negative(newBackground); | |
| 1658 | } | ||
| 1659 | } | ||
| 1660 | } | ||
| 1661 | |||
| 1662 | |||
| 1663 | template<typename T, Index Log2Dim> | ||
| 1664 | template<MergePolicy Policy> | ||
| 1665 | inline void | ||
| 1666 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 553 times.
|
1106 | LeafNode<T, Log2Dim>::merge(const LeafNode& other) |
| 1667 | { | ||
| 1668 | ✗ | if (!this->allocate()) return; | |
| 1669 | |||
| 1670 | OPENVDB_NO_UNREACHABLE_CODE_WARNING_BEGIN | ||
| 1671 | if (Policy == MERGE_NODES) return; | ||
| 1672 | 1106 | typename NodeMaskType::OnIterator iter = other.valueMask().beginOn(); | |
| 1673 |
2/2✓ Branch 0 taken 74022 times.
✓ Branch 1 taken 553 times.
|
149150 | for (; iter; ++iter) { |
| 1674 | const Index n = iter.pos(); | ||
| 1675 |
2/2✓ Branch 1 taken 68581 times.
✓ Branch 2 taken 5441 times.
|
148044 | if (mValueMask.isOff(n)) { |
| 1676 | 137162 | mBuffer[n] = other.mBuffer[n]; | |
| 1677 | 137162 | mValueMask.setOn(n); | |
| 1678 | } | ||
| 1679 | } | ||
| 1680 | OPENVDB_NO_UNREACHABLE_CODE_WARNING_END | ||
| 1681 | } | ||
| 1682 | |||
| 1683 | template<typename T, Index Log2Dim> | ||
| 1684 | template<MergePolicy Policy> | ||
| 1685 | inline void | ||
| 1686 | LeafNode<T, Log2Dim>::merge(const LeafNode& other, | ||
| 1687 | const ValueType& /*bg*/, const ValueType& /*otherBG*/) | ||
| 1688 | { | ||
| 1689 | 553 | this->template merge<Policy>(other); | |
| 1690 | 553 | } | |
| 1691 | |||
| 1692 | template<typename T, Index Log2Dim> | ||
| 1693 | template<MergePolicy Policy> | ||
| 1694 | inline void | ||
| 1695 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | LeafNode<T, Log2Dim>::merge(const ValueType& tileValue, bool tileActive) |
| 1696 | { | ||
| 1697 | ✗ | if (!this->allocate()) return; | |
| 1698 | |||
| 1699 | OPENVDB_NO_UNREACHABLE_CODE_WARNING_BEGIN | ||
| 1700 | if (Policy != MERGE_ACTIVE_STATES_AND_NODES) return; | ||
| 1701 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if (!tileActive) return; |
| 1702 | // Replace all inactive values with the active tile value. | ||
| 1703 |
2/2✓ Branch 1 taken 512 times.
✓ Branch 2 taken 1 times.
|
514 | for (typename NodeMaskType::OffIterator iter = mValueMask.beginOff(); iter; ++iter) { |
| 1704 | const Index n = iter.pos(); | ||
| 1705 | 512 | mBuffer[n] = tileValue; | |
| 1706 | 512 | mValueMask.setOn(n); | |
| 1707 | } | ||
| 1708 | OPENVDB_NO_UNREACHABLE_CODE_WARNING_END | ||
| 1709 | } | ||
| 1710 | |||
| 1711 | |||
| 1712 | template<typename T, Index Log2Dim> | ||
| 1713 | template<typename OtherType> | ||
| 1714 | inline void | ||
| 1715 | LeafNode<T, Log2Dim>::topologyUnion(const LeafNode<OtherType, Log2Dim>& other, bool) | ||
| 1716 | { | ||
| 1717 | mValueMask |= other.valueMask(); | ||
| 1718 | } | ||
| 1719 | |||
| 1720 | template<typename T, Index Log2Dim> | ||
| 1721 | template<typename OtherType> | ||
| 1722 | inline void | ||
| 1723 | LeafNode<T, Log2Dim>::topologyIntersection(const LeafNode<OtherType, Log2Dim>& other, | ||
| 1724 | const ValueType&) | ||
| 1725 | { | ||
| 1726 | mValueMask &= other.valueMask(); | ||
| 1727 | } | ||
| 1728 | |||
| 1729 | template<typename T, Index Log2Dim> | ||
| 1730 | template<typename OtherType> | ||
| 1731 | inline void | ||
| 1732 | 11 | LeafNode<T, Log2Dim>::topologyDifference(const LeafNode<OtherType, Log2Dim>& other, | |
| 1733 | const ValueType&) | ||
| 1734 | { | ||
| 1735 | 11 | mValueMask &= !other.valueMask(); | |
| 1736 | 11 | } | |
| 1737 | |||
| 1738 | template<typename T, Index Log2Dim> | ||
| 1739 | inline void | ||
| 1740 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 334 times.
|
334 | LeafNode<T, Log2Dim>::negate() |
| 1741 | { | ||
| 1742 | if (!this->allocate()) return; | ||
| 1743 | |||
| 1744 |
2/2✓ Branch 0 taken 171008 times.
✓ Branch 1 taken 334 times.
|
171342 | for (Index i = 0; i < SIZE; ++i) { |
| 1745 | 171008 | mBuffer[i] = -mBuffer[i]; | |
| 1746 | } | ||
| 1747 | } | ||
| 1748 | |||
| 1749 | |||
| 1750 | //////////////////////////////////////// | ||
| 1751 | |||
| 1752 | |||
| 1753 | template<typename T, Index Log2Dim> | ||
| 1754 | template<typename CombineOp> | ||
| 1755 | inline void | ||
| 1756 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
|
73 | LeafNode<T, Log2Dim>::combine(const LeafNode& other, CombineOp& op) |
| 1757 | { | ||
| 1758 | if (!this->allocate()) return; | ||
| 1759 | |||
| 1760 | CombineArgs<T> args; | ||
| 1761 |
2/2✓ Branch 0 taken 21504 times.
✓ Branch 1 taken 42 times.
|
37449 | for (Index i = 0; i < SIZE; ++i) { |
| 1762 | 70656 | op(args.setARef(mBuffer[i]) | |
| 1763 | .setAIsActive(mValueMask.isOn(i)) | ||
| 1764 | 74752 | .setBRef(other.mBuffer[i]) | |
| 1765 | .setBIsActive(other.valueMask().isOn(i)) | ||
| 1766 | 37376 | .setResultRef(mBuffer[i])); | |
| 1767 | mValueMask.set(i, args.resultIsActive()); | ||
| 1768 | } | ||
| 1769 | } | ||
| 1770 | |||
| 1771 | |||
| 1772 | template<typename T, Index Log2Dim> | ||
| 1773 | template<typename CombineOp> | ||
| 1774 | inline void | ||
| 1775 |
0/2✗ Branch 0 not taken.
✗ Branch 1 not taken.
|
673 | LeafNode<T, Log2Dim>::combine(const ValueType& value, bool valueIsActive, CombineOp& op) |
| 1776 | { | ||
| 1777 | if (!this->allocate()) return; | ||
| 1778 | |||
| 1779 | CombineArgs<T> args; | ||
| 1780 | args.setBRef(value).setBIsActive(valueIsActive); | ||
| 1781 |
0/2✗ Branch 0 not taken.
✗ Branch 1 not taken.
|
345249 | for (Index i = 0; i < SIZE; ++i) { |
| 1782 | 689152 | op(args.setARef(mBuffer[i]) | |
| 1783 | .setAIsActive(mValueMask.isOn(i)) | ||
| 1784 | 344576 | .setResultRef(mBuffer[i])); | |
| 1785 | mValueMask.set(i, args.resultIsActive()); | ||
| 1786 | } | ||
| 1787 | } | ||
| 1788 | |||
| 1789 | |||
| 1790 | //////////////////////////////////////// | ||
| 1791 | |||
| 1792 | |||
| 1793 | template<typename T, Index Log2Dim> | ||
| 1794 | template<typename CombineOp, typename OtherType> | ||
| 1795 | inline void | ||
| 1796 | ✗ | LeafNode<T, Log2Dim>::combine2(const LeafNode& other, const OtherType& value, | |
| 1797 | bool valueIsActive, CombineOp& op) | ||
| 1798 | { | ||
| 1799 | if (!this->allocate()) return; | ||
| 1800 | |||
| 1801 | CombineArgs<T, OtherType> args; | ||
| 1802 | args.setBRef(value).setBIsActive(valueIsActive); | ||
| 1803 | ✗ | for (Index i = 0; i < SIZE; ++i) { | |
| 1804 | ✗ | op(args.setARef(other.mBuffer[i]) | |
| 1805 | .setAIsActive(other.valueMask().isOn(i)) | ||
| 1806 | ✗ | .setResultRef(mBuffer[i])); | |
| 1807 | ✗ | mValueMask.set(i, args.resultIsActive()); | |
| 1808 | } | ||
| 1809 | } | ||
| 1810 | |||
| 1811 | |||
| 1812 | template<typename T, Index Log2Dim> | ||
| 1813 | template<typename CombineOp, typename OtherNodeT> | ||
| 1814 | inline void | ||
| 1815 | ✗ | LeafNode<T, Log2Dim>::combine2(const ValueType& value, const OtherNodeT& other, | |
| 1816 | bool valueIsActive, CombineOp& op) | ||
| 1817 | { | ||
| 1818 | if (!this->allocate()) return; | ||
| 1819 | |||
| 1820 | CombineArgs<T, typename OtherNodeT::ValueType> args; | ||
| 1821 | args.setARef(value).setAIsActive(valueIsActive); | ||
| 1822 | ✗ | for (Index i = 0; i < SIZE; ++i) { | |
| 1823 | ✗ | op(args.setBRef(other.mBuffer[i]) | |
| 1824 | ✗ | .setBIsActive(other.valueMask().isOn(i)) | |
| 1825 | ✗ | .setResultRef(mBuffer[i])); | |
| 1826 | ✗ | mValueMask.set(i, args.resultIsActive()); | |
| 1827 | } | ||
| 1828 | } | ||
| 1829 | |||
| 1830 | |||
| 1831 | template<typename T, Index Log2Dim> | ||
| 1832 | template<typename CombineOp, typename OtherNodeT> | ||
| 1833 | inline void | ||
| 1834 | 4 | LeafNode<T, Log2Dim>::combine2(const LeafNode& b0, const OtherNodeT& b1, CombineOp& op) | |
| 1835 | { | ||
| 1836 | if (!this->allocate()) return; | ||
| 1837 | |||
| 1838 | CombineArgs<T, typename OtherNodeT::ValueType> args; | ||
| 1839 | 2052 | for (Index i = 0; i < SIZE; ++i) { | |
| 1840 | 2048 | mValueMask.set(i, b0.valueMask().isOn(i) || b1.valueMask().isOn(i)); | |
| 1841 | 2048 | op(args.setARef(b0.mBuffer[i]) | |
| 1842 | .setAIsActive(b0.valueMask().isOn(i)) | ||
| 1843 | 3584 | .setBRef(b1.mBuffer[i]) | |
| 1844 | 512 | .setBIsActive(b1.valueMask().isOn(i)) | |
| 1845 | 4096 | .setResultRef(mBuffer[i])); | |
| 1846 | mValueMask.set(i, args.resultIsActive()); | ||
| 1847 | } | ||
| 1848 | } | ||
| 1849 | |||
| 1850 | |||
| 1851 | //////////////////////////////////////// | ||
| 1852 | |||
| 1853 | |||
| 1854 | template<typename T, Index Log2Dim> | ||
| 1855 | template<typename BBoxOp> | ||
| 1856 | inline void | ||
| 1857 | 2 | LeafNode<T, Log2Dim>::visitActiveBBox(BBoxOp& op) const | |
| 1858 | { | ||
| 1859 | if (op.template descent<LEVEL>()) { | ||
| 1860 | for (ValueOnCIter i=this->cbeginValueOn(); i; ++i) { | ||
| 1861 | op.template operator()<LEVEL>(CoordBBox::createCube(i.getCoord(), 1)); | ||
| 1862 | } | ||
| 1863 | } else { | ||
| 1864 | 2 | op.template operator()<LEVEL>(this->getNodeBoundingBox()); | |
| 1865 | } | ||
| 1866 | 2 | } | |
| 1867 | |||
| 1868 | |||
| 1869 | template<typename T, Index Log2Dim> | ||
| 1870 | template<typename VisitorOp> | ||
| 1871 | inline void | ||
| 1872 | LeafNode<T, Log2Dim>::visit(VisitorOp& op) | ||
| 1873 | { | ||
| 1874 |
4/8✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 8 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 8 times.
✗ Branch 11 not taken.
|
32 | doVisit<LeafNode, VisitorOp, ChildAllIter>(*this, op); |
| 1875 | 32 | } | |
| 1876 | |||
| 1877 | |||
| 1878 | template<typename T, Index Log2Dim> | ||
| 1879 | template<typename VisitorOp> | ||
| 1880 | inline void | ||
| 1881 | LeafNode<T, Log2Dim>::visit(VisitorOp& op) const | ||
| 1882 | { | ||
| 1883 |
4/8✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 8 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 8 times.
✗ Branch 11 not taken.
|
32 | doVisit<const LeafNode, VisitorOp, ChildAllCIter>(*this, op); |
| 1884 | 32 | } | |
| 1885 | |||
| 1886 | |||
| 1887 | template<typename T, Index Log2Dim> | ||
| 1888 | template<typename NodeT, typename VisitorOp, typename ChildAllIterT> | ||
| 1889 | inline void | ||
| 1890 | 128 | LeafNode<T, Log2Dim>::doVisit(NodeT& self, VisitorOp& op) | |
| 1891 | { | ||
| 1892 |
2/2✓ Branch 1 taken 32768 times.
✓ Branch 2 taken 64 times.
|
65792 | for (ChildAllIterT iter = self.beginChildAll(); iter; ++iter) { |
| 1893 | 65536 | op(iter); | |
| 1894 | } | ||
| 1895 | 128 | } | |
| 1896 | |||
| 1897 | |||
| 1898 | //////////////////////////////////////// | ||
| 1899 | |||
| 1900 | |||
| 1901 | template<typename T, Index Log2Dim> | ||
| 1902 | template<typename OtherLeafNodeType, typename VisitorOp> | ||
| 1903 | inline void | ||
| 1904 | LeafNode<T, Log2Dim>::visit2Node(OtherLeafNodeType& other, VisitorOp& op) | ||
| 1905 | { | ||
| 1906 | doVisit2Node<LeafNode, OtherLeafNodeType, VisitorOp, ChildAllIter, | ||
| 1907 | 24 | typename OtherLeafNodeType::ChildAllIter>(*this, other, op); | |
| 1908 | 24 | } | |
| 1909 | |||
| 1910 | |||
| 1911 | template<typename T, Index Log2Dim> | ||
| 1912 | template<typename OtherLeafNodeType, typename VisitorOp> | ||
| 1913 | inline void | ||
| 1914 | LeafNode<T, Log2Dim>::visit2Node(OtherLeafNodeType& other, VisitorOp& op) const | ||
| 1915 | { | ||
| 1916 | doVisit2Node<const LeafNode, OtherLeafNodeType, VisitorOp, ChildAllCIter, | ||
| 1917 | typename OtherLeafNodeType::ChildAllCIter>(*this, other, op); | ||
| 1918 | } | ||
| 1919 | |||
| 1920 | |||
| 1921 | template<typename T, Index Log2Dim> | ||
| 1922 | template< | ||
| 1923 | typename NodeT, | ||
| 1924 | typename OtherNodeT, | ||
| 1925 | typename VisitorOp, | ||
| 1926 | typename ChildAllIterT, | ||
| 1927 | typename OtherChildAllIterT> | ||
| 1928 | inline void | ||
| 1929 | 48 | LeafNode<T, Log2Dim>::doVisit2Node(NodeT& self, OtherNodeT& other, VisitorOp& op) | |
| 1930 | { | ||
| 1931 | // Allow the two nodes to have different ValueTypes, but not different dimensions. | ||
| 1932 | static_assert(OtherNodeT::SIZE == NodeT::SIZE, | ||
| 1933 | "can't visit nodes of different sizes simultaneously"); | ||
| 1934 | static_assert(OtherNodeT::LEVEL == NodeT::LEVEL, | ||
| 1935 | "can't visit nodes at different tree levels simultaneously"); | ||
| 1936 | |||
| 1937 | 48 | ChildAllIterT iter = self.beginChildAll(); | |
| 1938 | 48 | OtherChildAllIterT otherIter = other.beginChildAll(); | |
| 1939 | |||
| 1940 |
3/4✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 12288 times.
✗ Branch 3 not taken.
|
49200 | for ( ; iter && otherIter; ++iter, ++otherIter) { |
| 1941 | 24576 | op(iter, otherIter); | |
| 1942 | } | ||
| 1943 | 48 | } | |
| 1944 | |||
| 1945 | |||
| 1946 | //////////////////////////////////////// | ||
| 1947 | |||
| 1948 | |||
| 1949 | template<typename T, Index Log2Dim> | ||
| 1950 | template<typename IterT, typename VisitorOp> | ||
| 1951 | inline void | ||
| 1952 | LeafNode<T, Log2Dim>::visit2(IterT& otherIter, VisitorOp& op, bool otherIsLHS) | ||
| 1953 | { | ||
| 1954 | 19 | doVisit2<LeafNode, VisitorOp, ChildAllIter, IterT>( | |
| 1955 | *this, otherIter, op, otherIsLHS); | ||
| 1956 | 19 | } | |
| 1957 | |||
| 1958 | |||
| 1959 | template<typename T, Index Log2Dim> | ||
| 1960 | template<typename IterT, typename VisitorOp> | ||
| 1961 | inline void | ||
| 1962 | LeafNode<T, Log2Dim>::visit2(IterT& otherIter, VisitorOp& op, bool otherIsLHS) const | ||
| 1963 | { | ||
| 1964 | doVisit2<const LeafNode, VisitorOp, ChildAllCIter, IterT>( | ||
| 1965 | *this, otherIter, op, otherIsLHS); | ||
| 1966 | } | ||
| 1967 | |||
| 1968 | |||
| 1969 | template<typename T, Index Log2Dim> | ||
| 1970 | template< | ||
| 1971 | typename NodeT, | ||
| 1972 | typename VisitorOp, | ||
| 1973 | typename ChildAllIterT, | ||
| 1974 | typename OtherChildAllIterT> | ||
| 1975 | inline void | ||
| 1976 | 19 | LeafNode<T, Log2Dim>::doVisit2(NodeT& self, OtherChildAllIterT& otherIter, | |
| 1977 | VisitorOp& op, bool otherIsLHS) | ||
| 1978 | { | ||
| 1979 | 19 | if (!otherIter) return; | |
| 1980 | |||
| 1981 | 19 | if (otherIsLHS) { | |
| 1982 | 5140 | for (ChildAllIterT iter = self.beginChildAll(); iter; ++iter) { | |
| 1983 | 5120 | op(otherIter, iter); | |
| 1984 | } | ||
| 1985 | } else { | ||
| 1986 | 4626 | for (ChildAllIterT iter = self.beginChildAll(); iter; ++iter) { | |
| 1987 | 4608 | op(iter, otherIter); | |
| 1988 | } | ||
| 1989 | } | ||
| 1990 | } | ||
| 1991 | |||
| 1992 | |||
| 1993 | //////////////////////////////////////// | ||
| 1994 | |||
| 1995 | |||
| 1996 | template<typename T, Index Log2Dim> | ||
| 1997 | inline std::ostream& | ||
| 1998 | operator<<(std::ostream& os, const typename LeafNode<T, Log2Dim>::Buffer& buf) | ||
| 1999 | { | ||
| 2000 | for (Index32 i = 0, N = buf.size(); i < N; ++i) os << buf.mData[i] << ", "; | ||
| 2001 | return os; | ||
| 2002 | } | ||
| 2003 | |||
| 2004 | } // namespace tree | ||
| 2005 | } // namespace OPENVDB_VERSION_NAME | ||
| 2006 | } // namespace openvdb | ||
| 2007 | |||
| 2008 | |||
| 2009 | //////////////////////////////////////// | ||
| 2010 | |||
| 2011 | |||
| 2012 | // Specialization for LeafNodes of type bool | ||
| 2013 | #include "LeafNodeBool.h" | ||
| 2014 | |||
| 2015 | // Specialization for LeafNodes with mask information only | ||
| 2016 | #include "LeafNodeMask.h" | ||
| 2017 | |||
| 2018 | #endif // OPENVDB_TREE_LEAFNODE_HAS_BEEN_INCLUDED | ||
| 2019 |