11 #ifndef OPENVDB_TREE_NODEUNION_HAS_BEEN_INCLUDED    12 #define OPENVDB_TREE_NODEUNION_HAS_BEEN_INCLUDED    14 #include <openvdb/version.h>    17 #include <type_traits>    24 #if OPENVDB_ABI_VERSION_NUMBER >= 8    32 template<
typename ValueT, 
typename ChildT, 
typename Enable = 
void>
    45     const ValueT& 
getValue()
 const { 
return mValue; }
    47     void setValue(
const ValueT& val) { mValue = val; }
    56         "Unexpected instantiation of NodeUnion");
    61 template<
typename ValueT, 
typename ChildT>
    63     typename 
std::enable_if<std::is_trivially_copyable<ValueT>::value>::type>
    66     union { ChildT* mChild; ValueT 
mValue; };
    74     const ValueT& 
getValue()
 const { 
return mValue; }
    76     void setValue(
const ValueT& val) { mValue = val; }
    82 template<
typename T> 
struct CopyTraits;
    87 template<
typename ValueT, 
typename ChildT, 
typename Enable = 
void>
    97     ChildT* getChild()
 const { 
return mChild; }
    98     void setChild(ChildT* 
child) { mChild = 
child; }
   100     const ValueT& getValue()
 const { 
return mValue; }
   101     ValueT& getValue() { 
return mValue; }
   102     void setValue(
const ValueT& val) { mValue = val; }
   107 template<
typename ValueT, 
typename ChildT>
   108 class NodeUnion<ValueT, ChildT, typename std::enable_if<std::is_pod<ValueT>::value>::type>
   111     union { ChildT* mChild; ValueT mValue; };
   116     ChildT* getChild()
 const { 
return mChild; }
   117     void setChild(ChildT* 
child) { mChild = 
child; }
   119     const ValueT& getValue()
 const { 
return mValue; }
   120     ValueT& getValue() { 
return mValue; }
   121     void setValue(
const ValueT& val) { mValue = val; }
   127 template<
typename ValueT, 
typename ChildT>
   128 class NodeUnion<ValueT, ChildT, typename std::enable_if<CopyTraits<ValueT>::IsCopyable>::type>
   131     union { ChildT* mChild; ValueT mValue; };
   136         { std::memcpy(static_cast<void*>(
this), &other, 
sizeof(*
this)); }
   138         { std::memcpy(static_cast<void*>(
this), &rhs, 
sizeof(*
this)); 
return *
this; }
   140     ChildT* getChild()
 const { 
return mChild; }
   141     void setChild(ChildT* 
child) { mChild = 
child; }
   143     const ValueT& getValue()
 const { 
return mValue; }
   144     ValueT& getValue() { 
return mValue; }
   145     void setValue(
const ValueT& val) { mValue = val; }
   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; };
   170 #endif // OPENVDB_TREE_NODEUNION_HAS_BEEN_INCLUDED ChildT * child
Definition: GridBuilder.h:1286
void setChild(ChildT *child)
Definition: NodeUnion.h:72
ValueT & getValue()
Definition: NodeUnion.h:75
ValueT & getValue()
Definition: NodeUnion.h:46
const ValueT & getValue() const 
Definition: NodeUnion.h:74
ChildT * getChild() const 
Definition: NodeUnion.h:42
void setChild(ChildT *child)
Definition: NodeUnion.h:43
Definition: Exceptions.h:13
ValueT value
Definition: GridBuilder.h:1287
const ValueT & getValue() const 
Definition: NodeUnion.h:45
NodeUnion()
Definition: NodeUnion.h:69
ValueT mValue
Definition: NodeUnion.h:66
#define OPENVDB_VERSION_NAME
The version namespace name for this library version. 
Definition: version.h.in:116
NodeUnion()
Definition: NodeUnion.h:40
Default implementation of a NodeUnion that stores the child pointer and the value separately (i...
Definition: NodeUnion.h:33
void setValue(const ValueT &val)
Definition: NodeUnion.h:47
ChildT * getChild() const 
Definition: NodeUnion.h:71
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h.in:202
void setValue(const ValueT &val)
Definition: NodeUnion.h:76