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>
298 using Type =
typename std::remove_const<ToType>::type;
302 template<
typename FromType,
typename ToType>
struct CopyConstness<const FromType, ToType> {
303 using Type =
const ToType;
313 template<
typename... Ts>
struct TypeList;
319 template<
typename ListT,
typename... Ts>
struct TSAppendImpl;
322 template<
typename... Ts,
typename... OtherTs>
323 struct TSAppendImpl<
TypeList<Ts...>, OtherTs...> {
324 using type =
TypeList<Ts..., OtherTs...>;
328 template<
typename... Ts,
typename... OtherTs>
329 struct TSAppendImpl<TypeList<Ts...>, TypeList<OtherTs...>> {
330 using type = TypeList<Ts..., OtherTs...>;
335 template<
typename ListT,
typename T>
struct TSEraseImpl;
339 struct TSEraseImpl<TypeList<>, T> {
using type = TypeList<>; };
342 template<
typename... Ts,
typename T>
343 struct TSEraseImpl<TypeList<T, Ts...>, T> {
344 using type =
typename TSEraseImpl<TypeList<Ts...>, T>::type;
349 template<
typename T2,
typename... Ts,
typename T>
350 struct TSEraseImpl<TypeList<T2, Ts...>, T> {
351 using type =
typename TSAppendImpl<TypeList<T2>,
352 typename TSEraseImpl<TypeList<Ts...>, T>::type>::type;
356 template<
typename ListT,
typename... Ts>
struct TSRemoveImpl;
358 template<
typename ListT>
359 struct TSRemoveImpl<ListT> {
using type = ListT; };
362 template<
typename ListT,
typename T,
typename... Ts>
363 struct TSRemoveImpl<ListT, T, Ts...> {
364 using type =
typename TSRemoveImpl<typename TSEraseImpl<ListT, T>::type, Ts...>::type;
368 template<
typename ListT,
typename... Ts>
369 struct TSRemoveImpl<ListT, TypeList<Ts...>> {
370 using type =
typename TSRemoveImpl<ListT, Ts...>::type;
374 template<
typename OpT>
inline void TSForEachImpl(OpT) {}
375 template<
typename OpT,
typename T,
typename... Ts>
376 inline void TSForEachImpl(OpT op) { op(T()); TSForEachImpl<OpT, Ts...>(op); }
388 template<
typename... Ts>
407 template<
typename... TypesToAppend>
408 using Append =
typename internal::TSAppendImpl<
Self, TypesToAppend...>::type;
420 template<
typename... TypesToRemove>
421 using Remove =
typename internal::TSRemoveImpl<
Self, TypesToRemove...>::type;
443 template<
typename OpT>
444 static void foreach(OpT op) { internal::TSForEachImpl<OpT, Ts...>(op); }
539 template<>
inline const char* typeNameAsString<std::string>() {
return "string"; }
544 template<>
inline const char* typeNameAsString<math::Quats>() {
return "quats"; }
545 template<>
inline const char* typeNameAsString<math::Quatd>() {
return "quatd"; }
566 template<
typename AValueType,
typename BValueType = AValueType>
576 , mResultValPtr(&mResultVal)
579 , mResultIsActive(false)
584 CombineArgs(
const AValueType& a,
const BValueType& b, AValueType& result,
585 bool aOn =
false,
bool bOn =
false)
588 , mResultValPtr(&result)
592 this->updateResultActive();
596 CombineArgs(
const AValueType& a,
const BValueType& b,
bool aOn =
false,
bool bOn =
false)
599 , mResultValPtr(&mResultVal)
603 this->updateResultActive();
607 const AValueType&
a()
const {
return *mAValPtr; }
609 const BValueType&
b()
const {
return *mBValPtr; }
611 const AValueType& result()
const {
return *mResultValPtr; }
613 AValueType&
result() {
return *mResultValPtr; }
657 template<
typename ValueType,
typename CombineOp>
693 #define OPENVDB_START_THREADSAFE_STATIC_REFERENCE __pragma(warning(disable:1710))
694 #define OPENVDB_FINISH_THREADSAFE_STATIC_REFERENCE __pragma(warning(default:1710))
695 #define OPENVDB_START_THREADSAFE_STATIC_WRITE __pragma(warning(disable:1711))
696 #define OPENVDB_FINISH_THREADSAFE_STATIC_WRITE __pragma(warning(default:1711))
697 #define OPENVDB_START_THREADSAFE_STATIC_ADDRESS __pragma(warning(disable:1712))
698 #define OPENVDB_FINISH_THREADSAFE_STATIC_ADDRESS __pragma(warning(default:1712))
702 #define OPENVDB_START_NON_THREADSAFE_STATIC_REFERENCE __pragma(warning(disable:1710))
703 #define OPENVDB_FINISH_NON_THREADSAFE_STATIC_REFERENCE __pragma(warning(default:1710))
704 #define OPENVDB_START_NON_THREADSAFE_STATIC_WRITE __pragma(warning(disable:1711))
705 #define OPENVDB_FINISH_NON_THREADSAFE_STATIC_WRITE __pragma(warning(default:1711))
706 #define OPENVDB_START_NON_THREADSAFE_STATIC_ADDRESS __pragma(warning(disable:1712))
707 #define OPENVDB_FINISH_NON_THREADSAFE_STATIC_ADDRESS __pragma(warning(default:1712))
710 #define OPENVDB_THREADSAFE_STATIC_REFERENCE(CODE) \
711 __pragma(warning(disable:1710)); CODE; __pragma(warning(default:1710))
712 #define OPENVDB_THREADSAFE_STATIC_WRITE(CODE) \
713 __pragma(warning(disable:1711)); CODE; __pragma(warning(default:1711))
714 #define OPENVDB_THREADSAFE_STATIC_ADDRESS(CODE) \
715 __pragma(warning(disable:1712)); CODE; __pragma(warning(default:1712))
717 #else // GCC does not support these compiler warnings
719 #define OPENVDB_START_THREADSAFE_STATIC_REFERENCE
720 #define OPENVDB_FINISH_THREADSAFE_STATIC_REFERENCE
721 #define OPENVDB_START_THREADSAFE_STATIC_WRITE
722 #define OPENVDB_FINISH_THREADSAFE_STATIC_WRITE
723 #define OPENVDB_START_THREADSAFE_STATIC_ADDRESS
724 #define OPENVDB_FINISH_THREADSAFE_STATIC_ADDRESS
726 #define OPENVDB_START_NON_THREADSAFE_STATIC_REFERENCE
727 #define OPENVDB_FINISH_NON_THREADSAFE_STATIC_REFERENCE
728 #define OPENVDB_START_NON_THREADSAFE_STATIC_WRITE
729 #define OPENVDB_FINISH_NON_THREADSAFE_STATIC_WRITE
730 #define OPENVDB_START_NON_THREADSAFE_STATIC_ADDRESS
731 #define OPENVDB_FINISH_NON_THREADSAFE_STATIC_ADDRESS
733 #define OPENVDB_THREADSAFE_STATIC_REFERENCE(CODE) CODE
734 #define OPENVDB_THREADSAFE_STATIC_WRITE(CODE) CODE
735 #define OPENVDB_THREADSAFE_STATIC_ADDRESS(CODE) CODE
737 #endif // defined(__ICC)
739 #endif // OPENVDB_TYPES_HAS_BEEN_INCLUDED
CanConvertType<FromType, ToType>::value is true if a value of type ToType can be constructed from a v...
Definition: Types.h:262
AValueType AValueT
Definition: Types.h:570
const char * typeNameAsString< Vec3U8 >()
Definition: Types.h:531
typename T::ValueType ElementType
Definition: Types.h:201
VecType
Definition: Types.h:482
@ MERGE_NODES
Definition: Types.h:507
const AValueType * mAValPtr
Definition: Types.h:645
Quat< float > Quats
Definition: Quat.h:619
const char * typeNameAsString< Vec4d >()
Definition: Types.h:538
Vec3< int32_t > Vec3i
Definition: Vec3.h:659
@ VEC_CONTRAVARIANT_ABSOLUTE
Definition: Types.h:487
const char * typeNameAsString()
Definition: Types.h:515
int16_t Int16
Definition: Types.h:32
@ VEC_INVARIANT
Definition: Types.h:483
const char * typeNameAsString< double >()
Definition: Types.h:520
Mat4< double > Mat4d
Definition: Mat4.h:1334
Signed (x, y, z) 32-bit integer coordinates.
Definition: Coord.h:26
const char * typeNameAsString< Vec4f >()
Definition: Types.h:537
typename T::ValueType ElementType
Definition: Types.h:240
Mat3< double > Mat3d
Definition: Mat3.h:816
@ GRID_STAGGERED
Definition: Types.h:456
const char * typeNameAsString< Mat3d >()
Definition: Types.h:541
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:421
AValueType mResultVal
Definition: Types.h:647
Int32 Int
Definition: Types.h:35
CombineArgs & setAIsActive(bool b)
Set the active state of the A value.
Definition: Types.h:634
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
CombineArgs()
Definition: Types.h:573
CombineArgs & setARef(const AValueType &a)
Redirect the A value to a new external source.
Definition: Types.h:620
const char * typeNameAsString< PointDataIndex32 >()
Definition: Types.h:548
MergePolicy
Definition: Types.h:505
Library and file format version numbers.
@ GRID_FOG_VOLUME
Definition: Types.h:455
Vec4< int32_t > Vec4i
Definition: Vec4.h:557
SwappedCombineOp(CombineOp &_op)
Definition: Types.h:660
Vec4< float > Vec4s
Definition: Vec4.h:559
const char * typeNameAsString< uint32_t >()
Definition: Types.h:526
std::weak_ptr< T > WeakPtr
Definition: Types.h:92
typename T::ValueType ElementType
Definition: Types.h:218
std::shared_ptr< T > SharedPtr
Definition: Types.h:91
double Real
Definition: Types.h:37
bool resultIsActive() const
Definition: Types.h:631
Vec4< double > Vec4d
Definition: Vec4.h:560
const AValueType & a() const
Get the A input value.
Definition: Types.h:607
@ NUM_GRID_CLASSES
Definition: Types.h:458
Axis-aligned bounding box of signed integer coordinates.
Definition: Coord.h:249
Vec2< double > Vec2d
Definition: Vec2.h:532
Vec3< double > Vec3d
Definition: Vec3.h:662
const char * typeNameAsString< bool >()
Definition: Types.h:516
const char * typeNameAsString< Vec2i >()
Definition: Types.h:528
const char * typeNameAsString< uint16_t >()
Definition: Types.h:524
@ NUM_VEC_TYPES
Definition: Types.h:489
CombineArgs & setResultRef(AValueType &val)
Redirect the result value to a new external destination.
Definition: Types.h:624
T ElementType
Definition: Types.h:226
const char * typeNameAsString< int64_t >()
Definition: Types.h:527
bool mBIsActive
Definition: Types.h:649
@ VEC_CONTRAVARIANT_RELATIVE
Definition: Types.h:486
const char * typeNameAsString< PointDataIndex64 >()
Definition: Types.h:549
const char * typeNameAsString< Vec3f >()
Definition: Types.h:534
General-purpose arithmetic and comparison routines, most of which accept arbitrary value types (or at...
const char * typeNameAsString< PointIndex32 >()
Definition: Types.h:546
const char * typeNameAsString< ValueMask >()
Definition: Types.h:517
static const Real LEVEL_SET_HALF_WIDTH
Definition: Types.h:460
T ElementType
Definition: Types.h:193
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
Helper metafunction used to determine if the first template parameter is a specialization of the clas...
Definition: Types.h:169
const char * typeNameAsString< uint8_t >()
Definition: Types.h:522
Quat< double > Quatd
Definition: Quat.h:620
const BValueType * mBValPtr
Definition: Types.h:646
PointIndex(IntType i=IntType(0))
Definition: Types.h:139
PointIndex operator+(T x)
Needed to support the (zeroVal<PointIndex>() + val) idiom.
Definition: Types.h:148
AValueType & result()
Definition: Types.h:613
@ VEC_COVARIANT_NORMALIZE
Definition: Types.h:485
bool bIsActive() const
Definition: Types.h:629
void operator()(CombineArgs< ValueType > &args)
Definition: Types.h:662
bool mResultIsActive
Definition: Types.h:650
const char * typeNameAsString< Mat3s >()
Definition: Types.h:540
Tag dispatch class that distinguishes topology copy constructors from deep copy constructors.
Definition: Types.h:681
T ElementType
Definition: Types.h:252
const BValueType & b() const
Get the B input value.
Definition: Types.h:609
const char * typeNameAsString< Vec3U16 >()
Definition: Types.h:532
@ GRID_UNKNOWN
Definition: Types.h:453
const char * typeNameAsString< Vec2d >()
Definition: Types.h:530
CombineArgs & setBIsActive(bool b)
Set the active state of the B value.
Definition: Types.h:636
const char * typeNameAsString< half >()
Definition: Types.h:518
const char * typeNameAsString< float >()
Definition: Types.h:519
CopyConstness<T1, T2>::Type is either const T2 or T2 with no const qualifier, depending on whether T1...
Definition: Types.h:297
PointIndex(T i)
Explicit type conversion constructor.
Definition: Types.h:142
CombineArgs & setResultIsActive(bool b)
Set the active state of the output value.
Definition: Types.h:638
const char * typeNameAsString< int16_t >()
Definition: Types.h:523
This struct collects both input and output arguments to "grid combiner" functors used with the tree::...
Definition: Types.h:568
BValueType BValueT
Definition: Types.h:571
3x3 matrix class.
Definition: Mat3.h:29
const char * typeNameAsString< Mat4d >()
Definition: Types.h:543
typename T::ValueType ElementType
Definition: Types.h:185
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:154
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:584
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:596
const char * typeNameAsString< Vec3i >()
Definition: Types.h:533
CombineArgs & setResult(const AValueType &val)
Set the output value.
Definition: Types.h:617
const char * typeNameAsString< Vec2s >()
Definition: Types.h:529
typename internal::TSAppendImpl< Self, TypesToAppend... >::type Append
Append types, or the members of another TypeList, to this list.
Definition: Types.h:408
AValueType * mResultValPtr
Definition: Types.h:648
bool aIsActive() const
Definition: Types.h:627
const char * typeNameAsString< Vec3d >()
Definition: Types.h:535
const char * typeNameAsString< PointIndex64 >()
Definition: Types.h:547
@ VEC_COVARIANT
Definition: Types.h:484
Index32 Index
Definition: Types.h:31
Integer wrapper, required to distinguish PointIndexGrid and PointDataGrid from Int32Grid and Int64Gri...
Definition: Types.h:134
Vec2< int32_t > Vec2i
Definition: Vec2.h:529
int64_t Int64
Definition: Types.h:34
Vec3< float > Vec3s
Definition: Vec3.h:661
typename std::remove_const< ToType >::type Type
Definition: Types.h:298
A list of types (not necessarily unique)
Definition: Types.h:390
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:102
@ MERGE_ACTIVE_STATES_AND_NODES
Definition: Types.h:508
Vec2< float > Vec2s
Definition: Vec2.h:531
const AValueType & result() const
Get the output value.
Definition: Types.h:612
uint32_t Index32
Definition: Types.h:29
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
void updateResultActive()
Definition: Types.h:643
Tag dispatch class that distinguishes constructors during file input.
Definition: Types.h:683
GridClass
Definition: Types.h:452
const char * typeNameAsString< Mat4s >()
Definition: Types.h:542
@ GRID_LEVEL_SET
Definition: Types.h:454
const char * typeNameAsString< int32_t >()
Definition: Types.h:525
Mat4< float > Mat4s
Definition: Mat4.h:1333
Definition: Exceptions.h:13
int32_t Int32
Definition: Types.h:33
uint64_t Index64
Definition: Types.h:30
@ MERGE_ACTIVE_STATES
Definition: Types.h:506
Mat3< float > Mat3s
Definition: Mat3.h:815
IntType_ IntType
Definition: Types.h:137
const char * typeNameAsString< int8_t >()
Definition: Types.h:521
Tag dispatch class that distinguishes shallow copy constructors from deep copy constructors.
Definition: Types.h:678
CombineArgs & setBRef(const BValueType &b)
Redirect the B value to a new external source.
Definition: Types.h:622
const char * typeNameAsString< Vec4i >()
Definition: Types.h:536
unsigned char Byte
Definition: Types.h:36
T ElementType
Definition: Types.h:209
CombineOp & op
Definition: Types.h:669