Line | Branch | Exec | Source |
---|---|---|---|
1 | // Copyright Contributors to the OpenVDB Project | ||
2 | // SPDX-License-Identifier: MPL-2.0 | ||
3 | |||
4 | /// @file NodeUnion.h | ||
5 | /// | ||
6 | /// @details NodeUnion is a templated helper class that controls access to either | ||
7 | /// the child node pointer or the value for a particular element of a root | ||
8 | /// or internal node. For space efficiency, the child pointer and the value | ||
9 | /// are unioned when possible, since the two are never in use simultaneously. | ||
10 | |||
11 | #ifndef OPENVDB_TREE_NODEUNION_HAS_BEEN_INCLUDED | ||
12 | #define OPENVDB_TREE_NODEUNION_HAS_BEEN_INCLUDED | ||
13 | |||
14 | #include <openvdb/version.h> | ||
15 | #include <openvdb/Types.h> | ||
16 | #include <cstring> // for std::memcpy() | ||
17 | #include <type_traits> | ||
18 | |||
19 | namespace openvdb { | ||
20 | OPENVDB_USE_VERSION_NAMESPACE | ||
21 | namespace OPENVDB_VERSION_NAME { | ||
22 | namespace tree { | ||
23 | |||
24 | #if OPENVDB_ABI_VERSION_NUMBER >= 8 | ||
25 | |||
26 | /// @brief Default implementation of a NodeUnion that stores the child pointer | ||
27 | /// and the value separately (i.e., not in a union). Types which select this | ||
28 | /// specialization usually do not conform to the requirements of a union | ||
29 | /// member, that is that the type ValueT is not trivially copyable. This | ||
30 | /// implementation is thus NOT used for POD, math::Vec, math::Mat, math::Quat | ||
31 | /// or math::Coord types, but is used (for example) with std::string | ||
32 | template<typename ValueT, typename ChildT, typename Enable = void> | ||
33 | 10129984 | class NodeUnion | |
34 | { | ||
35 | private: | ||
36 | ChildT* mChild; | ||
37 | ValueT mValue; | ||
38 | |||
39 | public: | ||
40 | 10203712 | NodeUnion(): mChild(nullptr), mValue() {} | |
41 | |||
42 |
6/28✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 3 taken 45 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 190 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✓ Branch 18 taken 1 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 3 times.
✓ Branch 21 taken 90 times.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 2 times.
✗ Branch 28 not taken.
|
2293 | ChildT* getChild() const { return mChild; } |
43 |
0/8✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
|
12 | void setChild(ChildT* child) { mChild = child; } |
44 | |||
45 |
1/8✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 10 taken 45045 times.
✗ Branch 11 not taken.
|
88599648 | const ValueT& getValue() const { return mValue; } |
46 |
0/8✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
|
291 | ValueT& getValue() { return mValue; } |
47 |
7/56✓ Branch 1 taken 32764 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 393208 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ 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 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.
✗ 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 42 not taken.
✗ Branch 43 not taken.
✓ Branch 44 taken 741440 times.
✗ Branch 45 not taken.
✗ Branch 46 not taken.
✗ Branch 47 not taken.
✗ Branch 48 not taken.
✓ Branch 49 taken 8913408 times.
✗ Branch 50 not taken.
✓ Branch 51 taken 12294 times.
✗ Branch 52 not taken.
✓ Branch 54 taken 3 times.
✗ Branch 55 not taken.
✓ Branch 57 taken 49152 times.
✗ Branch 58 not taken.
✗ Branch 60 not taken.
✗ Branch 61 not taken.
|
10216727 | void setValue(const ValueT& val) { mValue = val; } |
48 | |||
49 | // Small check to ensure this class isn't | ||
50 | // selected for some expected types | ||
51 | static_assert(!ValueTraits<ValueT>::IsVec && | ||
52 | !ValueTraits<ValueT>::IsMat && | ||
53 | !ValueTraits<ValueT>::IsQuat && | ||
54 | !std::is_same<ValueT, math::Coord>::value && | ||
55 | !std::is_arithmetic<ValueT>::value, | ||
56 | "Unexpected instantiation of NodeUnion"); | ||
57 | }; | ||
58 | |||
59 | /// @brief Template specialization of a NodeUnion that stores the child pointer | ||
60 | /// and the value together (int, float, pointer, etc.) | ||
61 | template<typename ValueT, typename ChildT> | ||
62 | class NodeUnion<ValueT, ChildT, | ||
63 | typename std::enable_if<std::is_trivially_copyable<ValueT>::value>::type> | ||
64 | { | ||
65 | private: | ||
66 | union { ChildT* mChild; ValueT mValue; }; | ||
67 | |||
68 | public: | ||
69 | 3762358080 | NodeUnion(): mChild(nullptr) {} | |
70 | |||
71 |
157/641✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 2464 times.
✓ Branch 7 taken 3847 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 5216 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 57 times.
✓ Branch 12 taken 5215 times.
✓ Branch 13 taken 5 times.
✓ Branch 14 taken 141 times.
✓ Branch 15 taken 13597 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 15 times.
✓ Branch 18 taken 19613 times.
✓ Branch 19 taken 4446 times.
✓ Branch 20 taken 2079 times.
✓ Branch 21 taken 2854 times.
✓ Branch 22 taken 3361 times.
✓ Branch 23 taken 3 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 96 times.
✓ Branch 26 taken 16 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 7 times.
✓ Branch 29 taken 10512 times.
✓ Branch 30 taken 72 times.
✓ Branch 31 taken 2 times.
✓ Branch 32 taken 4 times.
✓ Branch 33 taken 13223 times.
✓ Branch 34 taken 88 times.
✓ Branch 35 taken 4 times.
✗ Branch 36 not taken.
✓ Branch 37 taken 771 times.
✗ Branch 38 not taken.
✓ Branch 39 taken 38 times.
✓ Branch 40 taken 29 times.
✗ Branch 41 not taken.
✓ Branch 42 taken 24 times.
✗ Branch 43 not taken.
✓ Branch 44 taken 6395 times.
✓ Branch 45 taken 85691 times.
✓ Branch 46 taken 616 times.
✓ Branch 47 taken 9 times.
✗ Branch 48 not taken.
✓ Branch 49 taken 3671 times.
✗ Branch 50 not taken.
✓ Branch 51 taken 659 times.
✗ Branch 52 not taken.
✓ Branch 53 taken 3136 times.
✓ Branch 54 taken 590 times.
✓ Branch 55 taken 1860 times.
✗ Branch 56 not taken.
✓ Branch 57 taken 95159 times.
✓ Branch 58 taken 122 times.
✓ Branch 59 taken 1006 times.
✓ Branch 60 taken 1679 times.
✓ Branch 61 taken 13848 times.
✓ Branch 62 taken 81 times.
✓ Branch 63 taken 4742 times.
✓ Branch 64 taken 2521 times.
✓ Branch 65 taken 89 times.
✗ Branch 66 not taken.
✓ Branch 67 taken 345 times.
✓ Branch 68 taken 14 times.
✗ Branch 69 not taken.
✓ Branch 70 taken 2 times.
✓ Branch 71 taken 17 times.
✓ Branch 72 taken 12 times.
✓ Branch 73 taken 100 times.
✓ Branch 74 taken 17 times.
✓ Branch 75 taken 1 times.
✓ Branch 76 taken 8 times.
✗ Branch 77 not taken.
✗ Branch 78 not taken.
✓ Branch 79 taken 14751 times.
✗ Branch 80 not taken.
✗ Branch 81 not taken.
✓ Branch 82 taken 2 times.
✓ Branch 83 taken 149 times.
✗ Branch 84 not taken.
✓ Branch 85 taken 34 times.
✗ Branch 86 not taken.
✗ Branch 87 not taken.
✗ Branch 88 not taken.
✗ Branch 89 not taken.
✓ Branch 90 taken 3373 times.
✓ Branch 91 taken 449 times.
✓ Branch 92 taken 52 times.
✗ Branch 93 not taken.
✓ Branch 94 taken 11 times.
✗ Branch 95 not taken.
✓ Branch 96 taken 54 times.
✓ Branch 97 taken 49 times.
✓ Branch 98 taken 1408 times.
✓ Branch 99 taken 4 times.
✗ Branch 100 not taken.
✓ Branch 101 taken 5283 times.
✗ Branch 102 not taken.
✓ Branch 103 taken 49 times.
✗ Branch 104 not taken.
✗ Branch 105 not taken.
✓ Branch 106 taken 366 times.
✗ Branch 107 not taken.
✗ Branch 108 not taken.
✓ Branch 109 taken 138 times.
✗ Branch 110 not taken.
✗ Branch 111 not taken.
✗ Branch 112 not taken.
✗ Branch 113 not taken.
✗ Branch 114 not taken.
✓ Branch 115 taken 159 times.
✗ Branch 116 not taken.
✓ Branch 117 taken 3 times.
✓ Branch 118 taken 1886 times.
✗ Branch 119 not taken.
✗ Branch 120 not taken.
✓ Branch 121 taken 116 times.
✓ Branch 122 taken 135 times.
✓ Branch 123 taken 1 times.
✓ Branch 124 taken 32 times.
✓ Branch 125 taken 4619 times.
✗ Branch 126 not taken.
✓ Branch 127 taken 100 times.
✗ Branch 128 not taken.
✗ Branch 129 not taken.
✗ Branch 130 not taken.
✗ Branch 131 not taken.
✗ Branch 132 not taken.
✓ Branch 133 taken 93 times.
✗ Branch 134 not taken.
✗ Branch 135 not taken.
✗ Branch 136 not taken.
✗ Branch 137 not taken.
✓ Branch 138 taken 1100 times.
✓ Branch 139 taken 89 times.
✗ Branch 140 not taken.
✓ Branch 141 taken 5736 times.
✓ Branch 142 taken 20283 times.
✗ Branch 143 not taken.
✓ Branch 144 taken 1314 times.
✓ Branch 145 taken 81 times.
✗ Branch 146 not taken.
✗ Branch 147 not taken.
✗ Branch 148 not taken.
✗ Branch 149 not taken.
✗ Branch 150 not taken.
✓ Branch 151 taken 85 times.
✗ Branch 152 not taken.
✓ Branch 153 taken 32 times.
✗ Branch 154 not taken.
✗ Branch 155 not taken.
✗ Branch 156 not taken.
✓ Branch 157 taken 128 times.
✗ Branch 158 not taken.
✗ Branch 159 not taken.
✗ Branch 160 not taken.
✗ Branch 161 not taken.
✗ Branch 162 not taken.
✓ Branch 163 taken 69 times.
✗ Branch 164 not taken.
✗ Branch 165 not taken.
✗ Branch 166 not taken.
✗ Branch 167 not taken.
✗ Branch 168 not taken.
✓ Branch 169 taken 64 times.
✓ Branch 170 taken 11 times.
✗ Branch 171 not taken.
✗ Branch 172 not taken.
✗ Branch 173 not taken.
✗ Branch 174 not taken.
✓ Branch 175 taken 20 times.
✗ Branch 176 not taken.
✗ Branch 177 not taken.
✗ Branch 178 not taken.
✗ Branch 179 not taken.
✗ Branch 180 not taken.
✗ Branch 181 not taken.
✗ Branch 182 not taken.
✗ Branch 183 not taken.
✗ Branch 184 not taken.
✗ Branch 185 not taken.
✗ Branch 186 not taken.
✗ Branch 187 not taken.
✓ Branch 188 taken 112 times.
✓ Branch 189 taken 7 times.
✗ Branch 190 not taken.
✗ Branch 191 not taken.
✗ Branch 192 not taken.
✗ Branch 193 not taken.
✗ Branch 194 not taken.
✗ Branch 195 not taken.
✗ Branch 196 not taken.
✗ Branch 197 not taken.
✗ Branch 198 not taken.
✗ Branch 199 not taken.
✗ Branch 200 not taken.
✓ Branch 201 taken 2 times.
✗ Branch 202 not taken.
✗ Branch 203 not taken.
✗ Branch 204 not taken.
✓ Branch 205 taken 17 times.
✗ Branch 206 not taken.
✓ Branch 207 taken 40 times.
✗ Branch 208 not taken.
✗ Branch 209 not taken.
✓ Branch 210 taken 31252 times.
✓ Branch 211 taken 3 times.
✗ Branch 212 not taken.
✗ Branch 213 not taken.
✗ Branch 214 not taken.
✓ Branch 215 taken 10 times.
✗ Branch 216 not taken.
✗ Branch 217 not taken.
✗ Branch 218 not taken.
✗ Branch 219 not taken.
✓ Branch 220 taken 2 times.
✗ Branch 221 not taken.
✓ Branch 222 taken 2 times.
✗ Branch 223 not taken.
✗ Branch 224 not taken.
✗ Branch 225 not taken.
✗ Branch 226 not taken.
✗ Branch 227 not taken.
✗ Branch 228 not taken.
✗ Branch 229 not taken.
✗ Branch 230 not taken.
✗ Branch 231 not taken.
✗ Branch 232 not taken.
✗ Branch 233 not taken.
✗ Branch 234 not taken.
✗ Branch 235 not taken.
✗ Branch 236 not taken.
✗ Branch 237 not taken.
✗ Branch 238 not taken.
✓ Branch 239 taken 1 times.
✗ Branch 240 not taken.
✗ Branch 241 not taken.
✗ Branch 242 not taken.
✗ Branch 243 not taken.
✗ Branch 244 not taken.
✗ Branch 245 not taken.
✗ Branch 246 not taken.
✗ Branch 247 not taken.
✗ Branch 248 not taken.
✗ Branch 249 not taken.
✗ Branch 250 not taken.
✗ Branch 251 not taken.
✗ Branch 252 not taken.
✗ Branch 253 not taken.
✗ Branch 254 not taken.
✗ Branch 255 not taken.
✓ Branch 256 taken 12 times.
✗ Branch 257 not taken.
✗ Branch 258 not taken.
✗ Branch 259 not taken.
✗ Branch 260 not taken.
✗ Branch 261 not taken.
✗ Branch 262 not taken.
✗ Branch 263 not taken.
✗ Branch 264 not taken.
✗ Branch 265 not taken.
✗ Branch 266 not taken.
✗ Branch 267 not taken.
✗ Branch 268 not taken.
✓ Branch 269 taken 13 times.
✓ Branch 270 taken 208 times.
✗ Branch 271 not taken.
✓ Branch 272 taken 220 times.
✗ Branch 273 not taken.
✓ Branch 274 taken 216 times.
✗ Branch 275 not taken.
✓ Branch 276 taken 232 times.
✗ Branch 277 not taken.
✓ Branch 278 taken 242 times.
✗ Branch 279 not taken.
✓ Branch 280 taken 238 times.
✗ Branch 281 not taken.
✓ Branch 282 taken 242 times.
✗ Branch 283 not taken.
✓ Branch 284 taken 274 times.
✓ Branch 285 taken 2 times.
✓ Branch 286 taken 390 times.
✗ Branch 287 not taken.
✓ Branch 288 taken 334 times.
✗ Branch 289 not taken.
✓ Branch 290 taken 233 times.
✗ Branch 291 not taken.
✓ Branch 292 taken 216 times.
✗ Branch 293 not taken.
✓ Branch 294 taken 216 times.
✗ Branch 295 not taken.
✓ Branch 296 taken 2 times.
✗ Branch 297 not taken.
✓ Branch 298 taken 152 times.
✗ Branch 299 not taken.
✓ Branch 300 taken 738 times.
✗ Branch 301 not taken.
✓ Branch 302 taken 376 times.
✗ Branch 303 not taken.
✓ Branch 304 taken 241 times.
✗ Branch 305 not taken.
✓ Branch 306 taken 1000 times.
✗ Branch 307 not taken.
✓ Branch 308 taken 240 times.
✗ Branch 309 not taken.
✗ Branch 310 not taken.
✗ Branch 311 not taken.
✗ Branch 312 not taken.
✗ Branch 313 not taken.
✓ Branch 314 taken 1 times.
✗ Branch 315 not taken.
✗ Branch 316 not taken.
✗ Branch 317 not taken.
✗ Branch 318 not taken.
✗ Branch 319 not taken.
✓ Branch 320 taken 1 times.
✗ Branch 321 not taken.
✗ Branch 322 not taken.
✗ Branch 323 not taken.
✗ Branch 324 not taken.
✗ Branch 325 not taken.
✗ Branch 326 not taken.
✗ Branch 327 not taken.
✗ Branch 328 not taken.
✗ Branch 329 not taken.
✗ Branch 330 not taken.
✗ Branch 331 not taken.
✓ Branch 332 taken 1 times.
✗ Branch 333 not taken.
✗ Branch 334 not taken.
✓ Branch 335 taken 20 times.
✗ Branch 336 not taken.
✗ Branch 337 not taken.
✗ Branch 338 not taken.
✗ Branch 339 not taken.
✗ Branch 340 not taken.
✗ Branch 341 not taken.
✗ Branch 342 not taken.
✗ Branch 343 not taken.
✗ Branch 344 not taken.
✗ Branch 345 not taken.
✗ Branch 346 not taken.
✗ Branch 347 not taken.
✗ Branch 348 not taken.
✗ Branch 349 not taken.
✗ Branch 350 not taken.
✗ Branch 351 not taken.
✓ Branch 352 taken 12 times.
✗ Branch 353 not taken.
✗ Branch 354 not taken.
✗ Branch 355 not taken.
✗ Branch 356 not taken.
✗ Branch 357 not taken.
✗ Branch 358 not taken.
✗ Branch 359 not taken.
✗ Branch 360 not taken.
✗ Branch 361 not taken.
✗ Branch 362 not taken.
✓ Branch 363 taken 13 times.
✗ Branch 364 not taken.
✗ Branch 365 not taken.
✗ Branch 366 not taken.
✗ Branch 367 not taken.
✗ Branch 368 not taken.
✗ Branch 369 not taken.
✗ Branch 370 not taken.
✗ Branch 371 not taken.
✗ Branch 372 not taken.
✗ Branch 373 not taken.
✗ Branch 374 not taken.
✗ Branch 375 not taken.
✓ Branch 376 taken 3236 times.
✗ Branch 377 not taken.
✗ Branch 378 not taken.
✗ Branch 379 not taken.
✗ Branch 380 not taken.
✗ Branch 381 not taken.
✗ Branch 382 not taken.
✗ Branch 383 not taken.
✗ Branch 384 not taken.
✗ Branch 385 not taken.
✗ Branch 386 not taken.
✗ Branch 387 not taken.
✗ Branch 388 not taken.
✗ Branch 389 not taken.
✗ Branch 390 not taken.
✗ Branch 391 not taken.
✗ Branch 392 not taken.
✗ Branch 393 not taken.
✓ Branch 394 taken 96 times.
✗ Branch 395 not taken.
✓ Branch 396 taken 102 times.
✗ Branch 397 not taken.
✓ Branch 398 taken 100 times.
✗ Branch 399 not taken.
✓ Branch 400 taken 102 times.
✗ Branch 401 not taken.
✓ Branch 402 taken 114 times.
✗ Branch 403 not taken.
✓ Branch 404 taken 112 times.
✗ Branch 405 not taken.
✓ Branch 406 taken 114 times.
✗ Branch 407 not taken.
✓ Branch 408 taken 130 times.
✗ Branch 409 not taken.
✓ Branch 410 taken 188 times.
✗ Branch 411 not taken.
✓ Branch 412 taken 160 times.
✗ Branch 413 not taken.
✓ Branch 414 taken 98 times.
✗ Branch 415 not taken.
✓ Branch 416 taken 98 times.
✗ Branch 417 not taken.
✓ Branch 418 taken 98 times.
✗ Branch 419 not taken.
✓ Branch 420 taken 590 times.
✗ Branch 421 not taken.
✓ Branch 422 taken 68 times.
✗ Branch 423 not taken.
✓ Branch 424 taken 352 times.
✗ Branch 425 not taken.
✓ Branch 426 taken 178 times.
✗ Branch 427 not taken.
✓ Branch 428 taken 306 times.
✗ Branch 429 not taken.
✓ Branch 430 taken 356 times.
✗ Branch 431 not taken.
✗ Branch 432 not taken.
✗ Branch 433 not taken.
✗ Branch 434 not taken.
✗ Branch 435 not taken.
✗ Branch 436 not taken.
✗ Branch 437 not taken.
✓ Branch 438 taken 1 times.
✗ Branch 439 not taken.
✗ Branch 440 not taken.
✗ Branch 441 not taken.
✗ Branch 442 not taken.
✗ Branch 443 not taken.
✗ Branch 444 not taken.
✗ Branch 445 not taken.
✗ Branch 446 not taken.
✗ Branch 447 not taken.
✗ Branch 448 not taken.
✓ Branch 449 taken 1 times.
✗ Branch 450 not taken.
✗ Branch 451 not taken.
✗ Branch 452 not taken.
✗ Branch 453 not taken.
✗ Branch 454 not taken.
✗ Branch 455 not taken.
✗ Branch 456 not taken.
✗ Branch 457 not taken.
✗ Branch 458 not taken.
✗ Branch 459 not taken.
✗ Branch 460 not taken.
✗ Branch 461 not taken.
✗ Branch 462 not taken.
✗ Branch 463 not taken.
✗ Branch 464 not taken.
✗ Branch 465 not taken.
✗ Branch 466 not taken.
✗ Branch 467 not taken.
✗ Branch 468 not taken.
✗ Branch 469 not taken.
✗ Branch 470 not taken.
✗ Branch 471 not taken.
✗ Branch 472 not taken.
✗ Branch 473 not taken.
✗ Branch 474 not taken.
✗ Branch 475 not taken.
✗ Branch 476 not taken.
✗ Branch 477 not taken.
✗ Branch 478 not taken.
✗ Branch 479 not taken.
✗ Branch 480 not taken.
✗ Branch 481 not taken.
✗ Branch 482 not taken.
✗ Branch 483 not taken.
✗ Branch 484 not taken.
✗ Branch 485 not taken.
✗ Branch 486 not taken.
✗ Branch 487 not taken.
✗ Branch 488 not taken.
✗ Branch 489 not taken.
✗ Branch 490 not taken.
✗ Branch 491 not taken.
✗ Branch 493 not taken.
✗ Branch 494 not taken.
✗ Branch 495 not taken.
✗ Branch 496 not taken.
✗ Branch 497 not taken.
✗ Branch 501 not taken.
✗ Branch 502 not taken.
✗ Branch 503 not taken.
✗ Branch 504 not taken.
✗ Branch 505 not taken.
✗ Branch 506 not taken.
✗ Branch 507 not taken.
✗ Branch 508 not taken.
✗ Branch 509 not taken.
✗ Branch 510 not taken.
✗ Branch 511 not taken.
✗ Branch 512 not taken.
✗ Branch 513 not taken.
✗ Branch 514 not taken.
✗ Branch 515 not taken.
✗ Branch 516 not taken.
✗ Branch 517 not taken.
✗ Branch 518 not taken.
✗ Branch 519 not taken.
✗ Branch 520 not taken.
✗ Branch 521 not taken.
✗ Branch 522 not taken.
✗ Branch 523 not taken.
✗ Branch 524 not taken.
✗ Branch 526 not taken.
✗ Branch 527 not taken.
✗ Branch 529 not taken.
✗ Branch 530 not taken.
✗ Branch 531 not taken.
✗ Branch 532 not taken.
✗ Branch 533 not taken.
✗ Branch 534 not taken.
✗ Branch 536 not taken.
✗ Branch 537 not taken.
✗ Branch 538 not taken.
✗ Branch 539 not taken.
✗ Branch 540 not taken.
✗ Branch 541 not taken.
✗ Branch 542 not taken.
✗ Branch 543 not taken.
✗ Branch 544 not taken.
✗ Branch 545 not taken.
✗ Branch 546 not taken.
✗ Branch 547 not taken.
✗ Branch 548 not taken.
✗ Branch 549 not taken.
✗ Branch 550 not taken.
✗ Branch 551 not taken.
✗ Branch 552 not taken.
✗ Branch 553 not taken.
✗ Branch 554 not taken.
✗ Branch 555 not taken.
✗ Branch 556 not taken.
✗ Branch 557 not taken.
✗ Branch 558 not taken.
✗ Branch 559 not taken.
✗ Branch 560 not taken.
✗ Branch 564 not taken.
✗ Branch 565 not taken.
✗ Branch 568 not taken.
✗ Branch 569 not taken.
✗ Branch 570 not taken.
✗ Branch 571 not taken.
✗ Branch 574 not taken.
✗ Branch 575 not taken.
✗ Branch 579 not taken.
✗ Branch 580 not taken.
✗ Branch 581 not taken.
✗ Branch 582 not taken.
✗ Branch 583 not taken.
✗ Branch 584 not taken.
✗ Branch 594 not taken.
✗ Branch 595 not taken.
✗ Branch 596 not taken.
✗ Branch 597 not taken.
✗ Branch 599 not taken.
✗ Branch 600 not taken.
✗ Branch 603 not taken.
✗ Branch 604 not taken.
✗ Branch 607 not taken.
✗ Branch 608 not taken.
✗ Branch 609 not taken.
✗ Branch 610 not taken.
✗ Branch 611 not taken.
✗ Branch 612 not taken.
✗ Branch 619 not taken.
✗ Branch 620 not taken.
✗ Branch 621 not taken.
✗ Branch 622 not taken.
✗ Branch 623 not taken.
✗ Branch 624 not taken.
✗ Branch 625 not taken.
✗ Branch 649 not taken.
✗ Branch 650 not taken.
✗ Branch 652 not taken.
✗ Branch 653 not taken.
✗ Branch 654 not taken.
✗ Branch 655 not taken.
✗ Branch 656 not taken.
✗ Branch 657 not taken.
✗ Branch 658 not taken.
✗ Branch 659 not taken.
✗ Branch 660 not taken.
✗ Branch 661 not taken.
✗ Branch 662 not taken.
✗ Branch 663 not taken.
✗ Branch 665 not taken.
✗ Branch 666 not taken.
✗ Branch 667 not taken.
✗ Branch 668 not taken.
✗ Branch 669 not taken.
✗ Branch 670 not taken.
✗ Branch 671 not taken.
✗ Branch 672 not taken.
✗ Branch 673 not taken.
✗ Branch 674 not taken.
✗ Branch 675 not taken.
✗ Branch 676 not taken.
✗ Branch 677 not taken.
✗ Branch 678 not taken.
✗ Branch 679 not taken.
✗ Branch 680 not taken.
✗ Branch 688 not taken.
✗ Branch 689 not taken.
✗ Branch 690 not taken.
✗ Branch 691 not taken.
✗ Branch 692 not taken.
✗ Branch 693 not taken.
✗ Branch 694 not taken.
✗ Branch 695 not taken.
✗ Branch 696 not taken.
✗ Branch 697 not taken.
✗ Branch 698 not taken.
✗ Branch 699 not taken.
✗ Branch 700 not taken.
✗ Branch 701 not taken.
✗ Branch 702 not taken.
✗ Branch 703 not taken.
✗ Branch 711 not taken.
✗ Branch 712 not taken.
✗ Branch 714 not taken.
✗ Branch 715 not taken.
✗ Branch 717 not taken.
✗ Branch 718 not taken.
|
646151123 | ChildT* getChild() const { return mChild; } |
72 | 22067261 | void setChild(ChildT* child) { mChild = child; } | |
73 | |||
74 |
17/36✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 1 times.
✓ Branch 14 taken 36855 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 36856 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 36855 times.
✓ 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 42 taken 76 times.
✓ Branch 43 taken 745286 times.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
|
6958678818 | const ValueT& getValue() const { return mValue; } |
75 |
60/173✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 248 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 136 times.
✓ Branch 6 taken 1445 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3254 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 1809 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 6 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 3 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✓ Branch 20 taken 55223 times.
✓ Branch 21 taken 59460 times.
✓ Branch 22 taken 1 times.
✓ Branch 23 taken 98303 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 18 times.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✓ Branch 32 taken 3 times.
✓ Branch 33 taken 1 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 2 times.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✓ Branch 39 taken 4876210 times.
✓ Branch 40 taken 8 times.
✗ Branch 41 not taken.
✓ Branch 42 taken 21139204 times.
✓ Branch 43 taken 40 times.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✓ Branch 46 taken 5695151 times.
✓ Branch 47 taken 8 times.
✗ Branch 48 not taken.
✓ Branch 49 taken 19041824 times.
✓ Branch 50 taken 24 times.
✗ 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 taken 1300 times.
✓ Branch 76 taken 39680 times.
✗ Branch 77 not taken.
✗ Branch 78 not taken.
✓ Branch 79 taken 1300 times.
✓ Branch 80 taken 39680 times.
✗ Branch 81 not taken.
✗ Branch 82 not taken.
✓ Branch 83 taken 1300 times.
✓ Branch 84 taken 39680 times.
✗ Branch 85 not taken.
✗ Branch 86 not taken.
✓ Branch 87 taken 2080 times.
✓ Branch 88 taken 63488 times.
✗ Branch 89 not taken.
✗ Branch 90 not taken.
✓ Branch 91 taken 1170 times.
✓ Branch 92 taken 35712 times.
✗ Branch 93 not taken.
✗ Branch 94 not taken.
✓ Branch 95 taken 1170 times.
✓ Branch 96 taken 35712 times.
✗ Branch 97 not taken.
✗ Branch 98 not taken.
✓ Branch 99 taken 1170 times.
✓ Branch 100 taken 35712 times.
✗ Branch 101 not taken.
✗ Branch 102 not taken.
✓ Branch 103 taken 1170 times.
✓ Branch 104 taken 35712 times.
✗ Branch 105 not taken.
✗ Branch 106 not taken.
✓ Branch 107 taken 1170 times.
✓ Branch 108 taken 35712 times.
✗ Branch 109 not taken.
✗ Branch 110 not taken.
✓ Branch 111 taken 1170 times.
✓ Branch 112 taken 35712 times.
✗ Branch 113 not taken.
✗ Branch 114 not taken.
✓ Branch 115 taken 1560 times.
✓ Branch 116 taken 47616 times.
✗ Branch 117 not taken.
✗ Branch 118 not taken.
✓ Branch 119 taken 1560 times.
✓ Branch 120 taken 47616 times.
✗ Branch 121 not taken.
✗ Branch 122 not taken.
✓ Branch 123 taken 1560 times.
✓ Branch 124 taken 47616 times.
✗ Branch 125 not taken.
✗ Branch 126 not taken.
✓ Branch 127 taken 1040 times.
✓ Branch 128 taken 31744 times.
✗ Branch 129 not taken.
✗ Branch 130 not taken.
✓ Branch 131 taken 2080 times.
✓ Branch 132 taken 63488 times.
✗ Branch 133 not taken.
✗ Branch 134 not taken.
✓ Branch 135 taken 2080 times.
✓ Branch 136 taken 63488 times.
✓ Branch 137 taken 4097 times.
✗ Branch 138 not taken.
✓ Branch 139 taken 4455205 times.
✓ Branch 140 taken 129856768 times.
✗ Branch 141 not taken.
✗ Branch 142 not taken.
✓ Branch 143 taken 3640 times.
✓ Branch 144 taken 111104 times.
✗ Branch 145 not taken.
✗ Branch 146 not taken.
✗ Branch 147 not taken.
✗ 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 156 not taken.
✗ Branch 157 not taken.
✗ Branch 161 not taken.
✗ Branch 162 not taken.
✗ Branch 164 not taken.
✗ Branch 165 not taken.
✗ Branch 169 not taken.
✗ Branch 170 not taken.
✗ Branch 172 not taken.
✗ Branch 173 not taken.
✗ Branch 177 not taken.
✗ Branch 178 not taken.
✗ Branch 180 not taken.
✗ Branch 181 not taken.
✗ Branch 185 not taken.
✗ Branch 186 not taken.
✗ Branch 188 not taken.
✗ Branch 189 not taken.
|
190641916 | ValueT& getValue() { return mValue; } |
76 |
30/126✓ Branch 0 taken 3 times.
✓ Branch 1 taken 19805 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12276 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 163835 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 98301 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 18 not taken.
✗ Branch 19 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 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 4095 times.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✓ Branch 35 taken 32767 times.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✓ Branch 40 taken 4095 times.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
✓ Branch 44 taken 32767 times.
✗ Branch 45 not taken.
✗ Branch 46 not taken.
✓ Branch 47 taken 8190 times.
✗ Branch 48 not taken.
✗ Branch 49 not taken.
✗ Branch 50 not taken.
✓ Branch 51 taken 65534 times.
✗ Branch 52 not taken.
✗ Branch 53 not taken.
✗ Branch 54 not taken.
✗ Branch 55 not taken.
✓ Branch 56 taken 107404 times.
✓ Branch 57 taken 12285 times.
✓ Branch 58 taken 16380 times.
✓ Branch 59 taken 65536 times.
✓ Branch 60 taken 163837 times.
✓ Branch 61 taken 36863 times.
✓ Branch 62 taken 297082 times.
✗ Branch 63 not taken.
✓ Branch 64 taken 8190 times.
✗ Branch 65 not taken.
✗ Branch 66 not taken.
✗ Branch 67 not taken.
✓ Branch 68 taken 4088 times.
✗ Branch 69 not taken.
✗ Branch 70 not taken.
✓ Branch 71 taken 4095 times.
✗ 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 taken 49140 times.
✗ 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 taken 53235 times.
✗ 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 taken 65534 times.
✗ 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 taken 65534 times.
✗ 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 taken 32767 times.
✗ Branch 107 not taken.
✗ Branch 108 not taken.
✗ Branch 109 not taken.
✗ Branch 110 not taken.
✗ Branch 111 not taken.
✗ Branch 112 not taken.
✓ Branch 113 taken 393204 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 taken 425971 times.
✓ Branch 121 taken 32767 times.
✗ Branch 122 not taken.
✗ Branch 123 not taken.
✗ Branch 124 not taken.
✗ Branch 125 not taken.
✗ Branch 126 not taken.
✗ Branch 127 not taken.
✓ Branch 128 taken 32767 times.
✗ Branch 130 not taken.
✗ Branch 131 not taken.
✗ Branch 132 not taken.
✗ Branch 133 not taken.
|
3911645699 | void setValue(const ValueT& val) { mValue = val; } |
77 | }; | ||
78 | |||
79 | #else | ||
80 | |||
81 | // Forward declaration of traits class | ||
82 | template<typename T> struct CopyTraits; | ||
83 | |||
84 | // Default implementation that stores the child pointer and the value separately | ||
85 | // (i.e., not in a union) | ||
86 | // This implementation is not used for POD, math::Vec or math::Coord value types. | ||
87 | template<typename ValueT, typename ChildT, typename Enable = void> | ||
88 | class NodeUnion | ||
89 | { | ||
90 | private: | ||
91 | ChildT* mChild; | ||
92 | ValueT mValue; | ||
93 | |||
94 | public: | ||
95 | NodeUnion(): mChild(nullptr), mValue() {} | ||
96 | |||
97 | ChildT* getChild() const { return mChild; } | ||
98 | void setChild(ChildT* child) { mChild = child; } | ||
99 | |||
100 | const ValueT& getValue() const { return mValue; } | ||
101 | ValueT& getValue() { return mValue; } | ||
102 | void setValue(const ValueT& val) { mValue = val; } | ||
103 | }; | ||
104 | |||
105 | |||
106 | // Template specialization for values of POD types (int, float, pointer, etc.) | ||
107 | template<typename ValueT, typename ChildT> | ||
108 | class NodeUnion<ValueT, ChildT, typename std::enable_if<std::is_pod<ValueT>::value>::type> | ||
109 | { | ||
110 | private: | ||
111 | union { ChildT* mChild; ValueT mValue; }; | ||
112 | |||
113 | public: | ||
114 | NodeUnion(): mChild(nullptr) {} | ||
115 | |||
116 | ChildT* getChild() const { return mChild; } | ||
117 | void setChild(ChildT* child) { mChild = child; } | ||
118 | |||
119 | const ValueT& getValue() const { return mValue; } | ||
120 | ValueT& getValue() { return mValue; } | ||
121 | void setValue(const ValueT& val) { mValue = val; } | ||
122 | }; | ||
123 | |||
124 | |||
125 | // Template specialization for values of types such as math::Vec3f and math::Coord | ||
126 | // for which CopyTraits<T>::IsCopyable is true | ||
127 | template<typename ValueT, typename ChildT> | ||
128 | class NodeUnion<ValueT, ChildT, typename std::enable_if<CopyTraits<ValueT>::IsCopyable>::type> | ||
129 | { | ||
130 | private: | ||
131 | union { ChildT* mChild; ValueT mValue; }; | ||
132 | |||
133 | public: | ||
134 | NodeUnion(): mChild(nullptr) {} | ||
135 | NodeUnion(const NodeUnion& other): mChild(nullptr) | ||
136 | { std::memcpy(static_cast<void*>(this), &other, sizeof(*this)); } | ||
137 | NodeUnion& operator=(const NodeUnion& rhs) | ||
138 | { std::memcpy(static_cast<void*>(this), &rhs, sizeof(*this)); return *this; } | ||
139 | |||
140 | ChildT* getChild() const { return mChild; } | ||
141 | void setChild(ChildT* child) { mChild = child; } | ||
142 | |||
143 | const ValueT& getValue() const { return mValue; } | ||
144 | ValueT& getValue() { return mValue; } | ||
145 | void setValue(const ValueT& val) { mValue = val; } | ||
146 | }; | ||
147 | |||
148 | |||
149 | /// @details A type T is copyable if | ||
150 | /// # T stores member values by value (vs. by pointer or reference) | ||
151 | /// and T's true byte size is given by sizeof(T). | ||
152 | /// # T has a trivial destructor | ||
153 | /// # T has a default constructor | ||
154 | /// # T has an assignment operator | ||
155 | template<typename T> struct CopyTraits { static const bool IsCopyable = false; }; | ||
156 | template<typename T> struct CopyTraits<math::Vec2<T>> { static const bool IsCopyable = true; }; | ||
157 | template<typename T> struct CopyTraits<math::Vec3<T>> { static const bool IsCopyable = true; }; | ||
158 | template<typename T> struct CopyTraits<math::Vec4<T>> { static const bool IsCopyable = true; }; | ||
159 | template<> struct CopyTraits<math::Coord> { static const bool IsCopyable = true; }; | ||
160 | |||
161 | #endif | ||
162 | |||
163 | //////////////////////////////////////// | ||
164 | |||
165 | |||
166 | } // namespace tree | ||
167 | } // namespace OPENVDB_VERSION_NAME | ||
168 | } // namespace openvdb | ||
169 | |||
170 | #endif // OPENVDB_TREE_NODEUNION_HAS_BEEN_INCLUDED | ||
171 |