Go to the documentation of this file.
4 #ifndef OPENVDB_TYPES_HAS_BEEN_INCLUDED
5 #define OPENVDB_TYPES_HAS_BEEN_INCLUDED
9 #include <OpenEXR/half.h>
21 #include <type_traits>
36 using Byte =
unsigned char;
91 template<
typename T>
using SharedPtr = std::shared_ptr<T>;
92 template<
typename T>
using WeakPtr = std::weak_ptr<T>;
132 template<
typename IntType_, Index Kind>
135 static_assert(std::is_integral<IntType_>::value,
"PointIndex requires an integer value type");
168 template <
typename T,
template <
typename...>
class Template>
171 template <
typename... Args,
template <
typename...>
class Template>
178 template<typename T, bool = IsSpecializationOf<T, math::Vec2>::value ||
183 static const bool IsVec =
true;
184 static const int Size = T::size;
191 static const bool IsVec =
false;
192 static const int Size = 1;
196 template<typename T, bool = IsSpecializationOf<T, math::Quat>::value>
199 static const bool IsQuat =
true;
200 static const int Size = T::size;
207 static const bool IsQuat =
false;
208 static const int Size = 1;
212 template<typename T, bool = IsSpecializationOf<T, math::Mat3>::value ||
216 static const bool IsMat =
true;
217 static const int Size = T::size;
224 static const bool IsMat =
false;
225 static const int Size = 1;
229 template<typename T, bool = VecTraits<T>::IsVec ||
237 static const bool IsScalar =
false;
238 static const int Size = T::size;
239 static const int Elements = IsMat ? Size*Size : Size;
246 static const bool IsVec =
false;
247 static const bool IsQuat =
false;
248 static const bool IsMat =
false;
249 static const bool IsScalar =
true;
250 static const int Size = 1;
251 static const int Elements = 1;
261 template<
typename FromType,
typename ToType>
262 struct CanConvertType {
enum { value = std::is_constructible<ToType, FromType>::value }; };
273 template<
typename T0,
typename T1>
275 template<
typename T0,
typename T1>
277 template<
typename T0,
typename T1>
302 template<
typename FromType,
typename ToType>
struct CopyConstness<const FromType, ToType> {
303 using Type =
const ToType;
313 template<
typename... Ts>
struct TypeList;
330 template<
typename ListT,
size_t Idx,
typename =
void>
struct TSGetElementImpl;
335 template<
typename... Ts,
size_t Idx>
336 struct TSGetElementImpl<TypeList<Ts...>, Idx,
337 typename
std::enable_if<(Idx < sizeof...(Ts) && sizeof...(Ts))>::type> {
338 using type =
typename std::tuple_element<Idx, std::tuple<Ts...>>
::type;
345 template<
typename... Ts,
size_t Idx>
346 struct TSGetElementImpl<TypeList<Ts...>, Idx,
347 typename
std::enable_if<!(Idx < sizeof...(Ts) && sizeof...(Ts))>::type> {
348 using type = NullType;
364 template <
typename ListT,
typename T,
size_t=0>
365 struct TSHasTypeImpl;
372 template <
typename T,
size_t Idx>
373 struct TSHasTypeImpl<TypeList<>, T, Idx> {
374 static constexpr
bool Value =
false;
375 static constexpr int64_t
Index = -1;
385 template <
typename U,
typename T,
typename... Ts,
size_t Idx>
386 struct TSHasTypeImpl<TypeList<U, Ts...>, T, Idx> :
387 TSHasTypeImpl<TypeList<Ts...>, T, Idx+1> {};
394 template <
typename T,
typename... Ts,
size_t Idx>
395 struct TSHasTypeImpl<TypeList<T, Ts...>, T, Idx>
397 static constexpr
bool Value =
true;
398 static constexpr int64_t
Index =
static_cast<int64_t
>(Idx);
412 template <
typename ListT,
typename... Ts>
413 struct TSMakeUniqueImpl {
425 template <
typename... Ts,
typename U,
typename... Us>
426 struct TSMakeUniqueImpl<TypeList<Ts...>, U, Us...>
428 using type =
typename std::conditional<
429 TSHasTypeImpl<TypeList<Ts...>, U>::Value,
430 typename TSMakeUniqueImpl<TypeList<Ts...>, Us...>
::type,
431 typename TSMakeUniqueImpl<TypeList<Ts..., U>, Us...>
::type >
::type;
439 template<
typename ListT,
typename... Ts>
struct TSAppendImpl;
445 template<
typename... Ts,
typename... OtherTs>
446 struct TSAppendImpl<TypeList<Ts...>, OtherTs...> {
447 using type = TypeList<Ts..., OtherTs...>;
454 template<
typename... Ts,
typename... OtherTs>
455 struct TSAppendImpl<TypeList<Ts...>, TypeList<OtherTs...>> {
456 using type = TypeList<Ts..., OtherTs...>;
464 template<
typename ListT,
typename T>
struct TSEraseImpl;
469 struct TSEraseImpl<TypeList<>, T> {
using type = TypeList<>; };
476 template<
typename... Ts,
typename T>
477 struct TSEraseImpl<TypeList<T, Ts...>, T> {
478 using type =
typename TSEraseImpl<TypeList<Ts...>, T>
::type;
487 template<
typename T2,
typename... Ts,
typename T>
488 struct TSEraseImpl<TypeList<T2, Ts...>, T> {
489 using type =
typename TSAppendImpl<TypeList<T2>,
499 template<
typename ListT,
typename... Ts>
struct TSRemoveImpl;
503 template<
typename ListT>
504 struct TSRemoveImpl<ListT> {
using type = ListT; };
511 template<
typename ListT,
typename T,
typename... Ts>
512 struct TSRemoveImpl<ListT, T, Ts...> {
521 template<
typename ListT,
typename... Ts>
522 struct TSRemoveImpl<ListT, TypeList<Ts...>> {
523 using type =
typename TSRemoveImpl<ListT, Ts...>
::type;
531 struct TSRemoveFirstImpl {
532 using type = TypeList<>;
539 template<
typename T,
typename... Ts>
540 struct TSRemoveFirstImpl<TypeList<T, Ts...>> {
541 using type = TypeList<Ts...>;
550 struct TSRemoveLastImpl {
using type = TypeList<>; };
559 struct TSRemoveLastImpl<TypeList<T>> : TSRemoveLastImpl<T> {};
567 template<
typename T,
typename... Ts>
568 struct TSRemoveLastImpl<TypeList<T, Ts...>>
571 typename TypeList<T>::template
572 Append<
typename TSRemoveLastImpl<TypeList<Ts...>>
::type>;
588 template<
typename ListT,
size_t First,
size_t Last,
size_t Idx=0>
589 struct TSRemoveIndicesImpl;
595 template<
size_t First,
size_t Last,
size_t Idx>
596 struct TSRemoveIndicesImpl<TypeList<>, First, Last, Idx> {
597 using type = TypeList<>;
605 template<
typename T,
size_t First,
size_t Last,
size_t Idx>
606 struct TSRemoveIndicesImpl<TypeList<T>, First, Last, Idx>
609 static constexpr
bool Remove = Idx >= First && Idx <= Last;
611 using type =
typename std::conditional<Remove, TypeList<>, TypeList<T>>
::type;
626 template<
typename T,
typename... Ts,
size_t First,
size_t Last,
size_t Idx>
627 struct TSRemoveIndicesImpl<TypeList<T, Ts...>, First, Last, Idx>
630 using ThisList =
typename TSRemoveIndicesImpl<TypeList<T>, First, Last, Idx>
::type;
631 using NextList =
typename TSRemoveIndicesImpl<TypeList<Ts...>, First, Last, Idx+1>
::type;
633 using type =
typename ThisList::template Append<NextList>;
637 template<
typename OpT>
inline void TSForEachImpl(OpT) {}
638 template<
typename OpT,
typename T,
typename... Ts>
639 inline void TSForEachImpl(OpT op) { op(T()); TSForEachImpl<OpT, Ts...>(op); }
651 template<
typename... Ts>
658 static constexpr
size_t Size =
sizeof...(Ts);
680 static constexpr
bool Contains = internal::TSHasTypeImpl<Self, T>::Value;
709 using Unique =
typename internal::TSMakeUniqueImpl<TypeList<>, Ts...>
::type;
724 template<
typename... TypesToAppend>
737 template<
typename... TypesToRemove>
784 template <
size_t First,
size_t Last>
807 template<
typename OpT>
808 static void foreach(OpT op) { internal::TSForEachImpl<OpT, Ts...>(op); }
903 template<>
inline const char* typeNameAsString<std::string>() {
return "string"; }
908 template<>
inline const char* typeNameAsString<math::Quats>() {
return "quats"; }
909 template<>
inline const char* typeNameAsString<math::Quatd>() {
return "quatd"; }
930 template<
typename AValueType,
typename BValueType = AValueType>
940 , mResultValPtr(&mResultVal)
943 , mResultIsActive(false)
948 CombineArgs(
const AValueType& a,
const BValueType& b, AValueType& result,
949 bool aOn =
false,
bool bOn =
false)
952 , mResultValPtr(&result)
956 this->updateResultActive();
960 CombineArgs(
const AValueType& a,
const BValueType& b,
bool aOn =
false,
bool bOn =
false)
963 , mResultValPtr(&mResultVal)
967 this->updateResultActive();
971 const AValueType&
a()
const {
return *mAValPtr; }
973 const BValueType&
b()
const {
return *mBValPtr; }
975 const AValueType& result()
const {
return *mResultValPtr; }
977 AValueType&
result() {
return *mResultValPtr; }
1021 template<
typename ValueType,
typename CombineOp>
1057 #define OPENVDB_START_THREADSAFE_STATIC_REFERENCE __pragma(warning(disable:1710))
1058 #define OPENVDB_FINISH_THREADSAFE_STATIC_REFERENCE __pragma(warning(default:1710))
1059 #define OPENVDB_START_THREADSAFE_STATIC_WRITE __pragma(warning(disable:1711))
1060 #define OPENVDB_FINISH_THREADSAFE_STATIC_WRITE __pragma(warning(default:1711))
1061 #define OPENVDB_START_THREADSAFE_STATIC_ADDRESS __pragma(warning(disable:1712))
1062 #define OPENVDB_FINISH_THREADSAFE_STATIC_ADDRESS __pragma(warning(default:1712))
1066 #define OPENVDB_START_NON_THREADSAFE_STATIC_REFERENCE __pragma(warning(disable:1710))
1067 #define OPENVDB_FINISH_NON_THREADSAFE_STATIC_REFERENCE __pragma(warning(default:1710))
1068 #define OPENVDB_START_NON_THREADSAFE_STATIC_WRITE __pragma(warning(disable:1711))
1069 #define OPENVDB_FINISH_NON_THREADSAFE_STATIC_WRITE __pragma(warning(default:1711))
1070 #define OPENVDB_START_NON_THREADSAFE_STATIC_ADDRESS __pragma(warning(disable:1712))
1071 #define OPENVDB_FINISH_NON_THREADSAFE_STATIC_ADDRESS __pragma(warning(default:1712))
1074 #define OPENVDB_THREADSAFE_STATIC_REFERENCE(CODE) \
1075 __pragma(warning(disable:1710)); CODE; __pragma(warning(default:1710))
1076 #define OPENVDB_THREADSAFE_STATIC_WRITE(CODE) \
1077 __pragma(warning(disable:1711)); CODE; __pragma(warning(default:1711))
1078 #define OPENVDB_THREADSAFE_STATIC_ADDRESS(CODE) \
1079 __pragma(warning(disable:1712)); CODE; __pragma(warning(default:1712))
1081 #else // GCC does not support these compiler warnings
1083 #define OPENVDB_START_THREADSAFE_STATIC_REFERENCE
1084 #define OPENVDB_FINISH_THREADSAFE_STATIC_REFERENCE
1085 #define OPENVDB_START_THREADSAFE_STATIC_WRITE
1086 #define OPENVDB_FINISH_THREADSAFE_STATIC_WRITE
1087 #define OPENVDB_START_THREADSAFE_STATIC_ADDRESS
1088 #define OPENVDB_FINISH_THREADSAFE_STATIC_ADDRESS
1090 #define OPENVDB_START_NON_THREADSAFE_STATIC_REFERENCE
1091 #define OPENVDB_FINISH_NON_THREADSAFE_STATIC_REFERENCE
1092 #define OPENVDB_START_NON_THREADSAFE_STATIC_WRITE
1093 #define OPENVDB_FINISH_NON_THREADSAFE_STATIC_WRITE
1094 #define OPENVDB_START_NON_THREADSAFE_STATIC_ADDRESS
1095 #define OPENVDB_FINISH_NON_THREADSAFE_STATIC_ADDRESS
1097 #define OPENVDB_THREADSAFE_STATIC_REFERENCE(CODE) CODE
1098 #define OPENVDB_THREADSAFE_STATIC_WRITE(CODE) CODE
1099 #define OPENVDB_THREADSAFE_STATIC_ADDRESS(CODE) CODE
1101 #endif // defined(__ICC)
1103 #endif // OPENVDB_TYPES_HAS_BEEN_INCLUDED
const char * typeNameAsString< uint8_t >()
Definition: Types.h:886
const char * typeNameAsString< int8_t >()
Definition: Types.h:885
typename internal::TSRemoveLastImpl< Self >::type PopBack
Remove the last element of this type list. Has no effect if the type list is already empty.
Definition: Types.h:768
A list of types (not necessarily unique)
Definition: Types.h:653
Vec2< double > Vec2d
Definition: Vec2.h:532
SwappedCombineOp(CombineOp &_op)
Definition: Types.h:1024
PointIndex(IntType i=IntType(0))
Definition: Types.h:139
@ GRID_UNKNOWN
Definition: Types.h:817
const char * typeNameAsString< Mat3d >()
Definition: Types.h:905
const char * typeNameAsString< Vec3i >()
Definition: Types.h:897
CopyConstness<T1, T2>::Type is either const T2 or T2 with no const qualifier, depending on whether T1...
Definition: Types.h:297
const char * typeNameAsString()
Definition: Types.h:879
CombineArgs & setBRef(const BValueType &b)
Redirect the B value to a new external source.
Definition: Types.h:986
@ VEC_COVARIANT_NORMALIZE
Definition: Types.h:849
Helper metafunction used to determine if the first template parameter is a specialization of the clas...
Definition: Types.h:169
T ElementType
Definition: Types.h:226
const char * typeNameAsString< Mat4d >()
Definition: Types.h:907
const char * typeNameAsString< Vec4i >()
Definition: Types.h:900
typename internal::TSAppendImpl< Self, TypesToAppend... >::type Append
Append types, or the members of another TypeList, to this list.
Definition: Types.h:725
T ElementType
Definition: Types.h:252
CombineArgs & setResultRef(AValueType &val)
Redirect the result value to a new external destination.
Definition: Types.h:988
Vec4< double > Vec4d
Definition: Vec4.h:560
PointIndex operator+(T x)
Needed to support the (zeroVal<PointIndex>() + val) idiom.
Definition: Types.h:148
Tag dispatch class that distinguishes topology copy constructors from deep copy constructors.
Definition: Types.h:1045
Index32 Index
Definition: Types.h:31
const char * typeNameAsString< bool >()
Definition: Types.h:880
const char * typeNameAsString< half >()
Definition: Types.h:882
const char * typeNameAsString< Vec2i >()
Definition: Types.h:892
const char * typeNameAsString< int64_t >()
Definition: Types.h:891
int64_t Int64
Definition: Types.h:34
SharedPtr< T > StaticPtrCast(const SharedPtr< U > &ptr)
Return a new shared pointer that points to the same object as the given pointer after a static_cast.
Definition: Types.h:123
Get< 0 > Front
Definition: Types.h:664
T ElementType
Definition: Types.h:209
typename internal::TSMakeUniqueImpl< TypeList<>, Ts... >::type Unique
Remove any duplicate types from this TypeList by rotating the next valid type left (maintains the ord...
Definition: Types.h:709
const char * typeNameAsString< Mat3s >()
Definition: Types.h:904
3x3 matrix class.
Definition: Mat3.h:29
const AValueType & a() const
Get the A input value.
Definition: Types.h:971
@ MERGE_ACTIVE_STATES_AND_NODES
Definition: Types.h:872
CombineArgs & setBIsActive(bool b)
Set the active state of the B value.
Definition: Types.h:1000
const BValueType * mBValPtr
Definition: Types.h:1010
CombineArgs()
Definition: Types.h:937
CombineArgs & setAIsActive(bool b)
Set the active state of the A value.
Definition: Types.h:998
GridClass
Definition: Types.h:816
Vec3< int32_t > Vec3i
Definition: Vec3.h:659
Library and file format version numbers.
typename T::ValueType ElementType
Definition: Types.h:185
@ VEC_COVARIANT
Definition: Types.h:848
const char * typeNameAsString< float >()
Definition: Types.h:883
uint64_t Index64
Definition: Types.h:30
const char * typeNameAsString< PointDataIndex64 >()
Definition: Types.h:913
bool mBIsActive
Definition: Types.h:1013
const char * typeNameAsString< uint16_t >()
Definition: Types.h:888
CombineArgs(const AValueType &a, const BValueType &b, bool aOn=false, bool bOn=false)
Use this constructor when the result value should be stored in this struct.
Definition: Types.h:960
CanConvertType<FromType, ToType>::value is true if a value of type ToType can be constructed from a v...
Definition: Types.h:262
const char * typeNameAsString< Vec3U8 >()
Definition: Types.h:895
const char * typeNameAsString< Vec4d >()
Definition: Types.h:902
@ MERGE_ACTIVE_STATES
Definition: Types.h:870
unsigned char Byte
Definition: Types.h:36
Axis-aligned bounding box of signed integer coordinates.
Definition: Coord.h:249
Get< Size-1 > Back
Definition: Types.h:665
const char * typeNameAsString< PointIndex32 >()
Definition: Types.h:910
Vec2< int32_t > Vec2i
Definition: Vec2.h:529
Tag dispatch class that distinguishes constructors during file input.
Definition: Types.h:1047
typename internal::TSRemoveImpl< Self, TypesToRemove... >::type Remove
Remove all occurrences of one or more types, or the members of another TypeList, from this list.
Definition: Types.h:738
Quat< float > Quats
Definition: Quat.h:619
const Name const NamePair & type
Definition: PointAttribute.h:545
T ElementType
Definition: Types.h:193
const AValueType * mAValPtr
Definition: Types.h:1009
@ GRID_LEVEL_SET
Definition: Types.h:818
uint32_t Index32
Definition: Types.h:29
const BValueType & b() const
Get the B input value.
Definition: Types.h:973
IntType_ IntType
Definition: Types.h:137
bool mResultIsActive
Definition: Types.h:1014
AValueType * mResultValPtr
Definition: Types.h:1012
General-purpose arithmetic and comparison routines, most of which accept arbitrary value types (or at...
int32_t Int32
Definition: Types.h:33
bool bIsActive() const
Definition: Types.h:993
@ MERGE_NODES
Definition: Types.h:871
const char * typeNameAsString< int16_t >()
Definition: Types.h:887
typename T::ValueType ElementType
Definition: Types.h:240
int16_t Int16
Definition: Types.h:32
Vec4< float > Vec4s
Definition: Vec4.h:559
const char * typeNameAsString< ValueMask >()
Definition: Types.h:881
CombineArgs & setARef(const AValueType &a)
Redirect the A value to a new external source.
Definition: Types.h:984
CombineArgs(const AValueType &a, const BValueType &b, AValueType &result, bool aOn=false, bool bOn=false)
Use this constructor when the result value is stored externally.
Definition: Types.h:948
Vec3< float > Vec3s
Definition: Vec3.h:661
const char * typeNameAsString< Vec2d >()
Definition: Types.h:894
bool aIsActive() const
Definition: Types.h:991
Mat3< float > Mat3s
Definition: Mat3.h:815
Signed (x, y, z) 32-bit integer coordinates.
Definition: Coord.h:26
Vec3< double > Vec3d
Definition: Vec3.h:662
CombineArgs & setResultIsActive(bool b)
Set the active state of the output value.
Definition: Types.h:1002
bool resultIsActive() const
Definition: Types.h:995
typename internal::TSRemoveFirstImpl< Self >::type PopFront
Remove the first element of this type list. Has no effect if the type list is already empty.
Definition: Types.h:753
Vec2< float > Vec2s
Definition: Vec2.h:531
@ VEC_CONTRAVARIANT_ABSOLUTE
Definition: Types.h:851
VecType
Definition: Types.h:846
@ VEC_INVARIANT
Definition: Types.h:847
Int32 Int
Definition: Types.h:35
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:146
This struct collects both input and output arguments to "grid combiner" functors used with the tree::...
Definition: Types.h:932
Mat4< float > Mat4s
Definition: Mat4.h:1333
typename T::ValueType ElementType
Definition: Types.h:218
const char * typeNameAsString< PointIndex64 >()
Definition: Types.h:911
typename internal::TSRemoveIndicesImpl< Self, First, Last >::type RemoveByIndex
Return a new list with types removed by their location within the list. If First is equal to Last,...
Definition: Types.h:785
MergePolicy
Definition: Types.h:869
const char * typeNameAsString< PointDataIndex32 >()
Definition: Types.h:912
@ GRID_STAGGERED
Definition: Types.h:820
Quat< double > Quatd
Definition: Quat.h:620
SharedPtr< T > ConstPtrCast(const SharedPtr< U > &ptr)
Return a new shared pointer that points to the same object as the given pointer but with possibly dif...
Definition: Types.h:103
CombineArgs & setResult(const AValueType &val)
Set the output value.
Definition: Types.h:981
@ GRID_FOG_VOLUME
Definition: Types.h:819
Integer wrapper, required to distinguish PointIndexGrid and PointDataGrid from Int32Grid and Int64Gri...
Definition: Types.h:134
SharedPtr< T > DynamicPtrCast(const SharedPtr< U > &ptr)
Return a new shared pointer that is either null or points to the same object as the given pointer aft...
Definition: Types.h:113
typename std::remove_const< ToType >::type Type
Definition: Types.h:298
const char * typeNameAsString< Mat4s >()
Definition: Types.h:906
Mat4< double > Mat4d
Definition: Mat4.h:1334
const Name & name
Definition: PointAttribute.h:544
AValueType & result()
Definition: Types.h:977
const char * typeNameAsString< Vec3d >()
Definition: Types.h:899
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:94
PointIndex(T i)
Explicit type conversion constructor.
Definition: Types.h:142
typename internal::TSGetElementImpl< Self, N >::type Get
Access a particular element of this type list. If the index is out of range, internal::NullType is re...
Definition: Types.h:663
Mat3< double > Mat3d
Definition: Mat3.h:816
typename T::ValueType ElementType
Definition: Types.h:201
const char * typeNameAsString< int32_t >()
Definition: Types.h:889
AValueType mResultVal
Definition: Types.h:1011
const char * typeNameAsString< Vec3f >()
Definition: Types.h:898
Tag dispatch class that distinguishes shallow copy constructors from deep copy constructors.
Definition: Types.h:1042
Definition: Exceptions.h:13
@ VEC_CONTRAVARIANT_RELATIVE
Definition: Types.h:850
AValueType AValueT
Definition: Types.h:934
BValueType BValueT
Definition: Types.h:935
static const Real LEVEL_SET_HALF_WIDTH
Definition: Types.h:824
@ NUM_GRID_CLASSES
Definition: Types.h:822
void operator()(CombineArgs< ValueType > &args)
Definition: Types.h:1026
std::weak_ptr< T > WeakPtr
Definition: Types.h:92
const char * typeNameAsString< double >()
Definition: Types.h:884
std::shared_ptr< T > SharedPtr
Definition: Types.h:91
double Real
Definition: Types.h:37
Vec4< int32_t > Vec4i
Definition: Vec4.h:557
const AValueType & result() const
Get the output value.
Definition: Types.h:976
const char * typeNameAsString< uint32_t >()
Definition: Types.h:890
@ NUM_VEC_TYPES
Definition: Types.h:853
const char * typeNameAsString< Vec3U16 >()
Definition: Types.h:896
void updateResultActive()
Definition: Types.h:1007
CombineOp & op
Definition: Types.h:1033
const char * typeNameAsString< Vec4f >()
Definition: Types.h:901
const char * typeNameAsString< Vec2s >()
Definition: Types.h:893