4 #ifndef OPENVDB_TYPES_HAS_BEEN_INCLUDED
5 #define OPENVDB_TYPES_HAS_BEEN_INCLUDED
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>;
112 template<
typename T,
typename U>
inline SharedPtr<T>
122 template<
typename T,
typename U>
inline SharedPtr<T>
132 template<
typename IntType_, Index Kind>
168 template <
typename T,
template <
typename...>
class Template>
171 template <
typename... Args,
template <
typename...>
class Template>
229 template<typename T, bool = VecTraits<T>::IsVec ||
261 template<
typename FromType,
typename ToType>
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); }
824 static const Real LEVEL_SET_HALF_WIDTH = 3;
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>
949 bool aOn =
false,
bool bOn =
false)
960 CombineArgs(
const AValueType&
a,
const BValueType&
b,
bool aOn =
false,
bool bOn =
false)
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
static constexpr bool Contains
True if this list contains the given type, false otherwise.
const AValueType & result() const
Get the output value.
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...
PointIndex operator+(T x)
Needed to support the (zeroVal<PointIndex>() + val) idiom.
const char * typeNameAsString< ValueMask >()
const BValueType * mBValPtr
This struct collects both input and output arguments to "grid combiner" functors used with the tree::...
typename T::ValueType ElementType
GLuint const GLchar * name
Tag dispatch class that distinguishes shallow copy constructors from deep copy constructors.
const char * typeNameAsString< PointIndex32 >()
typename T::ValueType ElementType
const char * typeNameAsString< int32_t >()
GLuint const GLfloat * val
const char * typeNameAsString< Vec3i >()
const char * typeNameAsString< uint16_t >()
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.
typename internal::TSRemoveLastImpl< Self >::type PopBack
Remove the last element of this type list. Has no effect if the type list is already empty...
GLboolean GLboolean GLboolean GLboolean a
CombineArgs & setBIsActive(bool b)
Set the active state of the B value.
const char * typeNameAsString< int8_t >()
const char * typeNameAsString< int16_t >()
#define OPENVDB_USE_VERSION_NAMESPACE
const char * typeNameAsString< Mat3s >()
const char * typeNameAsString< half >()
void updateResultActive()
Signed (x, y, z) 32-bit integer coordinates.
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...
Tag dispatch class that distinguishes constructors during file input.
const char * typeNameAsString< PointIndex64 >()
const char * typeNameAsString< Vec3d >()
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...
const char * typeNameAsString< Mat4s >()
std::shared_ptr< T > SharedPtr
const AValueType & a() const
Get the A input value.
SwappedCombineOp(CombineOp &_op)
const char * typeNameAsString< Vec3U16 >()
Helper metafunction used to determine if the first template parameter is a specialization of the clas...
const char * typeNameAsString< Vec3f >()
const char * typeNameAsString< PointDataIndex32 >()
const char * typeNameAsString< uint32_t >()
typename internal::TSMakeUniqueImpl< TypeList<>, Ts...>::type Unique
Remove any duplicate types from this TypeList by rotating the next valid type left (maintains the ord...
std::weak_ptr< T > WeakPtr
typename internal::TSAppendImpl< Self, TypesToAppend...>::type Append
Append types, or the members of another TypeList, to this list.
GLint GLint GLint GLint GLint x
PointIndex(T i)
Explicit type conversion constructor.
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...
const char * typeNameAsString< uint8_t >()
bool resultIsActive() const
const char * typeNameAsString< float >()
const char * typeNameAsString< Vec2i >()
General-purpose arithmetic and comparison routines, most of which accept arbitrary value types (or at...
CombineArgs & setAIsActive(bool b)
Set the active state of the A value.
typename std::remove_const< ToType >::type Type
const char * typeNameAsString()
const char * typeNameAsString< int64_t >()
Axis-aligned bounding box of signed integer coordinates.
Mark the end – don't use this!
static const bool IsScalar
CopyConstness<T1, T2>::Type is either const T2 or T2 with no const qualifier, depending on whether T1...
typename internal::TSRemoveFirstImpl< Self >::type PopFront
Remove the first element of this type list. Has no effect if the type list is already empty...
GLuint GLuint GLsizei GLenum type
const char * typeNameAsString< Vec4d >()
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.
CombineArgs & setResultIsActive(bool b)
Set the active state of the output value.
const char * typeNameAsString< double >()
const AValueType * mAValPtr
AValueType * mResultValPtr
TypeList Self
The type of this list.
CanConvertType<FromType, ToType>::value is true if a value of type ToType can be constructed from a v...
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...
typename T::ValueType ElementType
GLdouble GLdouble GLdouble b
const char * typeNameAsString< bool >()
static const int Elements
AValueType & result()
Get the output value.
CombineArgs & setBRef(const BValueType &b)
Redirect the B value to a new external source.
const char * typeNameAsString< Mat4d >()
CombineArgs & setResultRef(AValueType &val)
Redirect the result value to a new external destination.
const char * typeNameAsString< Vec3U8 >()
const char * typeNameAsString< Vec2d >()
typename internal::TSRemoveImpl< Self, TypesToRemove...>::type Remove
Remove all occurrences of one or more types, or the members of another TypeList, from this list...
void operator()(CombineArgs< ValueType > &args)
CombineArgs & setARef(const AValueType &a)
Redirect the A value to a new external source.
Integer wrapper, required to distinguish PointIndexGrid and PointDataGrid from Int32Grid and Int64Gri...
const char * typeNameAsString< Vec4f >()
Tag dispatch class that distinguishes topology copy constructors from deep copy constructors.
const BValueType & b() const
Get the B input value.
const char * typeNameAsString< Vec4i >()
typename T::ValueType ElementType
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
GLsizei const GLfloat * value
A list of types (not necessarily unique)
const char * typeNameAsString< PointDataIndex64 >()
CombineArgs & setResult(const AValueType &val)
Set the output value.
const char * typeNameAsString< Vec2s >()
static constexpr size_t Size
The number of types in the type list.
PointIndex(IntType i=IntType(0))
const char * typeNameAsString< Mat3d >()