Go to the documentation of this file.
31 #ifndef OPENVDB_TYPES_HAS_BEEN_INCLUDED
32 #define OPENVDB_TYPES_HAS_BEEN_INCLUDED
36 #include <OpenEXR/half.h>
47 #include <type_traits>
48 #if OPENVDB_ABI_VERSION_NUMBER <= 3
49 #include <boost/shared_ptr.hpp>
50 #include <boost/weak_ptr.hpp>
66 using Byte =
unsigned char;
121 #if OPENVDB_ABI_VERSION_NUMBER <= 3
124 template<
typename T>
using SharedPtr = boost::shared_ptr<T>;
125 template<
typename T>
using WeakPtr = boost::weak_ptr<T>;
133 template<
typename T,
typename U>
inline SharedPtr<T>
134 StaticPtrCast(
const SharedPtr<U>& ptr) {
return boost::static_pointer_cast<T, U>(ptr); }
136 #else // if OPENVDB_ABI_VERSION_NUMBER > 3
139 template<
typename T>
using SharedPtr = std::shared_ptr<T>;
140 template<
typename T>
using WeakPtr = std::weak_ptr<T>;
182 template<
typename IntType_, Index Kind>
185 static_assert(std::is_integral<IntType_>::value,
"PointIndex requires an integer value type");
218 template <
typename T,
template <
typename...>
class Template>
221 template <
typename... Args,
template <
typename...>
class Template>
228 template<typename T, bool = IsSpecializationOf<T, math::Vec2>::value ||
233 static const bool IsVec =
true;
234 static const int Size = T::size;
241 static const bool IsVec =
false;
242 static const int Size = 1;
246 template<typename T, bool = IsSpecializationOf<T, math::Quat>::value>
249 static const bool IsQuat =
true;
250 static const int Size = T::size;
257 static const bool IsQuat =
false;
258 static const int Size = 1;
262 template<typename T, bool = IsSpecializationOf<T, math::Mat3>::value ||
266 static const bool IsMat =
true;
267 static const int Size = T::size;
274 static const bool IsMat =
false;
275 static const int Size = 1;
279 template<typename T, bool = VecTraits<T>::IsVec ||
287 static const bool IsScalar =
false;
288 static const int Size = T::size;
289 static const int Elements = IsMat ? Size*Size : Size;
296 static const bool IsVec =
false;
297 static const bool IsQuat =
false;
298 static const bool IsMat =
false;
299 static const bool IsScalar =
true;
300 static const int Size = 1;
301 static const int Elements = 1;
311 template<
typename FromType,
typename ToType>
312 struct CanConvertType {
enum { value = std::is_constructible<ToType, FromType>::value }; };
323 template<
typename T0,
typename T1>
325 template<
typename T0,
typename T1>
327 template<
typename T0,
typename T1>
348 using Type =
typename std::remove_const<ToType>::type;
352 template<
typename FromType,
typename ToType>
struct CopyConstness<const FromType, ToType> {
353 using Type =
const ToType;
363 template<
typename... Ts>
struct TypeList;
369 template<
typename ListT,
typename... Ts>
struct TSAppendImpl;
372 template<
typename... Ts,
typename... OtherTs>
373 struct TSAppendImpl<
TypeList<Ts...>, OtherTs...> {
374 using type =
TypeList<Ts..., OtherTs...>;
378 template<
typename... Ts,
typename... OtherTs>
379 struct TSAppendImpl<TypeList<Ts...>, TypeList<OtherTs...>> {
380 using type = TypeList<Ts..., OtherTs...>;
385 template<
typename ListT,
typename T>
struct TSEraseImpl;
389 struct TSEraseImpl<TypeList<>, T> {
using type = TypeList<>; };
392 template<
typename... Ts,
typename T>
393 struct TSEraseImpl<TypeList<T, Ts...>, T> {
394 using type =
typename TSEraseImpl<TypeList<Ts...>, T>::type;
399 template<
typename T2,
typename... Ts,
typename T>
400 struct TSEraseImpl<TypeList<T2, Ts...>, T> {
401 using type =
typename TSAppendImpl<TypeList<T2>,
402 typename TSEraseImpl<TypeList<Ts...>, T>::type>::type;
406 template<
typename ListT,
typename... Ts>
struct TSRemoveImpl;
408 template<
typename ListT>
409 struct TSRemoveImpl<ListT> {
using type = ListT; };
412 template<
typename ListT,
typename T,
typename... Ts>
413 struct TSRemoveImpl<ListT, T, Ts...> {
414 using type =
typename TSRemoveImpl<typename TSEraseImpl<ListT, T>::type, Ts...>::type;
418 template<
typename ListT,
typename... Ts>
419 struct TSRemoveImpl<ListT, TypeList<Ts...>> {
420 using type =
typename TSRemoveImpl<ListT, Ts...>::type;
424 template<
typename OpT>
inline void TSForEachImpl(OpT) {}
425 template<
typename OpT,
typename T,
typename... Ts>
426 inline void TSForEachImpl(OpT op) { op(T()); TSForEachImpl<OpT, Ts...>(op); }
438 template<
typename... Ts>
457 template<
typename... TypesToAppend>
458 using Append =
typename internal::TSAppendImpl<
Self, TypesToAppend...>::type;
470 template<
typename... TypesToRemove>
471 using Remove =
typename internal::TSRemoveImpl<
Self, TypesToRemove...>::type;
493 template<
typename OpT>
494 static void foreach(OpT op) { internal::TSForEachImpl<OpT, Ts...>(op); }
589 template<>
inline const char* typeNameAsString<std::string>() {
return "string"; }
594 template<>
inline const char* typeNameAsString<math::Quats>() {
return "quats"; }
595 template<>
inline const char* typeNameAsString<math::Quatd>() {
return "quatd"; }
616 template<
typename AValueType,
typename BValueType = AValueType>
626 , mResultValPtr(&mResultVal)
629 , mResultIsActive(false)
634 CombineArgs(
const AValueType& a,
const BValueType& b, AValueType& result,
635 bool aOn =
false,
bool bOn =
false)
638 , mResultValPtr(&result)
642 this->updateResultActive();
646 CombineArgs(
const AValueType& a,
const BValueType& b,
bool aOn =
false,
bool bOn =
false)
649 , mResultValPtr(&mResultVal)
653 this->updateResultActive();
657 const AValueType&
a()
const {
return *mAValPtr; }
659 const BValueType&
b()
const {
return *mBValPtr; }
661 const AValueType& result()
const {
return *mResultValPtr; }
663 AValueType&
result() {
return *mResultValPtr; }
707 template<
typename ValueType,
typename CombineOp>
726 #if OPENVDB_ABI_VERSION_NUMBER <= 3
762 #define OPENVDB_START_THREADSAFE_STATIC_REFERENCE __pragma(warning(disable:1710))
763 #define OPENVDB_FINISH_THREADSAFE_STATIC_REFERENCE __pragma(warning(default:1710))
764 #define OPENVDB_START_THREADSAFE_STATIC_WRITE __pragma(warning(disable:1711))
765 #define OPENVDB_FINISH_THREADSAFE_STATIC_WRITE __pragma(warning(default:1711))
766 #define OPENVDB_START_THREADSAFE_STATIC_ADDRESS __pragma(warning(disable:1712))
767 #define OPENVDB_FINISH_THREADSAFE_STATIC_ADDRESS __pragma(warning(default:1712))
771 #define OPENVDB_START_NON_THREADSAFE_STATIC_REFERENCE __pragma(warning(disable:1710))
772 #define OPENVDB_FINISH_NON_THREADSAFE_STATIC_REFERENCE __pragma(warning(default:1710))
773 #define OPENVDB_START_NON_THREADSAFE_STATIC_WRITE __pragma(warning(disable:1711))
774 #define OPENVDB_FINISH_NON_THREADSAFE_STATIC_WRITE __pragma(warning(default:1711))
775 #define OPENVDB_START_NON_THREADSAFE_STATIC_ADDRESS __pragma(warning(disable:1712))
776 #define OPENVDB_FINISH_NON_THREADSAFE_STATIC_ADDRESS __pragma(warning(default:1712))
779 #define OPENVDB_THREADSAFE_STATIC_REFERENCE(CODE) \
780 __pragma(warning(disable:1710)); CODE; __pragma(warning(default:1710))
781 #define OPENVDB_THREADSAFE_STATIC_WRITE(CODE) \
782 __pragma(warning(disable:1711)); CODE; __pragma(warning(default:1711))
783 #define OPENVDB_THREADSAFE_STATIC_ADDRESS(CODE) \
784 __pragma(warning(disable:1712)); CODE; __pragma(warning(default:1712))
786 #else // GCC does not support these compiler warnings
788 #define OPENVDB_START_THREADSAFE_STATIC_REFERENCE
789 #define OPENVDB_FINISH_THREADSAFE_STATIC_REFERENCE
790 #define OPENVDB_START_THREADSAFE_STATIC_WRITE
791 #define OPENVDB_FINISH_THREADSAFE_STATIC_WRITE
792 #define OPENVDB_START_THREADSAFE_STATIC_ADDRESS
793 #define OPENVDB_FINISH_THREADSAFE_STATIC_ADDRESS
795 #define OPENVDB_START_NON_THREADSAFE_STATIC_REFERENCE
796 #define OPENVDB_FINISH_NON_THREADSAFE_STATIC_REFERENCE
797 #define OPENVDB_START_NON_THREADSAFE_STATIC_WRITE
798 #define OPENVDB_FINISH_NON_THREADSAFE_STATIC_WRITE
799 #define OPENVDB_START_NON_THREADSAFE_STATIC_ADDRESS
800 #define OPENVDB_FINISH_NON_THREADSAFE_STATIC_ADDRESS
802 #define OPENVDB_THREADSAFE_STATIC_REFERENCE(CODE) CODE
803 #define OPENVDB_THREADSAFE_STATIC_WRITE(CODE) CODE
804 #define OPENVDB_THREADSAFE_STATIC_ADDRESS(CODE) CODE
806 #endif // defined(__ICC)
808 #endif // OPENVDB_TYPES_HAS_BEEN_INCLUDED
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:161
const char * typeNameAsString< bool >()
Definition: Types.h:566
Mat3< float > Mat3s
Definition: Mat3.h:842
const char * typeNameAsString< Vec2d >()
Definition: Types.h:580
typename T::ValueType ElementType
Definition: Types.h:268
AValueType & result()
Definition: Types.h:663
const char * typeNameAsString< Vec4f >()
Definition: Types.h:587
const char * typeNameAsString< Vec4i >()
Definition: Types.h:586
const char * typeNameAsString< Mat3d >()
Definition: Types.h:591
Signed (x, y, z) 32-bit integer coordinates.
Definition: Coord.h:52
const char * typeNameAsString< Vec3i >()
Definition: Types.h:583
VecType
Definition: Types.h:532
Int32 Int
Definition: Types.h:65
const char * typeNameAsString< Vec4d >()
Definition: Types.h:588
MergePolicy
Definition: Types.h:555
const char * typeNameAsString< PointDataIndex64 >()
Definition: Types.h:599
const AValueType & result() const
Get the output value.
Definition: Types.h:662
CombineArgs & setResultRef(AValueType &val)
Redirect the result value to a new external destination.
Definition: Types.h:674
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:471
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:151
void updateResultActive()
Definition: Types.h:693
BValueType BValueT
Definition: Types.h:621
const char * typeNameAsString< uint8_t >()
Definition: Types.h:572
Mat3< double > Mat3d
Definition: Mat3.h:843
const char * typeNameAsString< Vec3U8 >()
Definition: Types.h:581
CombineArgs()
Definition: Types.h:623
const char * typeNameAsString< Mat3s >()
Definition: Types.h:590
const char * typeNameAsString< ValueMask >()
Definition: Types.h:567
Mat4< double > Mat4d
Definition: Mat4.h:1361
const char * typeNameAsString< Vec2s >()
Definition: Types.h:579
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:646
bool mBIsActive
Definition: Types.h:699
Quat< double > Quatd
Definition: Quat.h:647
Tag dispatch class that distinguishes topology copy constructors from deep copy constructors.
Definition: Types.h:750
const BValueType * mBValPtr
Definition: Types.h:696
CombineArgs & setBRef(const BValueType &b)
Redirect the B value to a new external source.
Definition: Types.h:672
A list of types (not necessarily unique)
Definition: Types.h:439
const char * typeNameAsString< Vec2i >()
Definition: Types.h:578
const char * typeNameAsString< PointIndex64 >()
Definition: Types.h:597
Vec3< int32_t > Vec3i
Definition: Vec3.h:686
int32_t Int32
Definition: Types.h:63
Library and file format version numbers.
Index32 Index
Definition: Types.h:61
CombineArgs & setBIsActive(bool b)
Set the active state of the B value.
Definition: Types.h:686
const char * typeNameAsString()
Definition: Types.h:565
const char * typeNameAsString< Mat4d >()
Definition: Types.h:593
const char * typeNameAsString< int16_t >()
Definition: Types.h:573
PointIndex(IntType i=IntType(0))
Definition: Types.h:189
const BValueType & b() const
Get the B input value.
Definition: Types.h:659
CombineArgs & setAIsActive(bool b)
Set the active state of the A value.
Definition: Types.h:684
unsigned char Byte
Definition: Types.h:66
const AValueType * mAValPtr
Definition: Types.h:695
Vec4< int32_t > Vec4i
Definition: Vec4.h:584
const char * typeNameAsString< Vec3d >()
Definition: Types.h:585
CombineOp & op
Definition: Types.h:719
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:634
const char * typeNameAsString< uint16_t >()
Definition: Types.h:574
std::shared_ptr< T > SharedPtr
Definition: Types.h:139
double Real
Definition: Types.h:67
const char * typeNameAsString< Mat4s >()
Definition: Types.h:592
General-purpose arithmetic and comparison routines, most of which accept arbitrary value types (or at...
const AValueType & a() const
Get the A input value.
Definition: Types.h:657
std::weak_ptr< T > WeakPtr
Definition: Types.h:140
PointIndex(T i)
Explicit type conversion constructor.
Definition: Types.h:192
Vec2< double > Vec2d
Definition: Vec2.h:559
Mat4< float > Mat4s
Definition: Mat4.h:1360
const char * typeNameAsString< double >()
Definition: Types.h:570
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:171
Axis-aligned bounding box of signed integer coordinates.
Definition: Coord.h:275
typename T::ValueType ElementType
Definition: Types.h:235
CombineArgs & setResultIsActive(bool b)
Set the active state of the output value.
Definition: Types.h:688
const char * typeNameAsString< Vec3U16 >()
Definition: Types.h:582
typename T::ValueType ElementType
Definition: Types.h:290
Tag dispatch class that distinguishes shallow copy constructors from deep copy constructors.
Definition: Types.h:747
Vec4< double > Vec4d
Definition: Vec4.h:587
const char * typeNameAsString< PointIndex32 >()
Definition: Types.h:596
int16_t Int16
Definition: Types.h:62
CombineArgs & setARef(const AValueType &a)
Redirect the A value to a new external source.
Definition: Types.h:670
const char * typeNameAsString< float >()
Definition: Types.h:569
const char * typeNameAsString< PointDataIndex32 >()
Definition: Types.h:598
CombineArgs & setResult(const AValueType &val)
Set the output value.
Definition: Types.h:667
int64_t Int64
Definition: Types.h:64
Vec2< float > Vec2s
Definition: Vec2.h:558
GridClass
Definition: Types.h:502
AValueType * mResultValPtr
Definition: Types.h:698
Vec3< double > Vec3d
Definition: Vec3.h:689
typename internal::TSAppendImpl< Self, TypesToAppend... >::type Append
Append types, or the members of another TypeList, to this list.
Definition: Types.h:458
bool aIsActive() const
Definition: Types.h:677
SwappedCombineOp(CombineOp &_op)
Definition: Types.h:710
bool resultIsActive() const
Definition: Types.h:681
uint32_t Index32
Definition: Types.h:59
bool bIsActive() const
Definition: Types.h:679
T ElementType
Definition: Types.h:302
Vec3< float > Vec3s
Definition: Vec3.h:688
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:180
bool mResultIsActive
Definition: Types.h:700
static const Real LEVEL_SET_HALF_WIDTH
Definition: Types.h:510
IntType_ IntType
Definition: Types.h:187
T ElementType
Definition: Types.h:259
uint64_t Index64
Definition: Types.h:60
CopyConstness<T1, T2>::Type is either const T2 or T2 with no const qualifier, depending on whether T1...
Definition: Types.h:347
Helper metafunction used to determine if the first template parameter is a specialization of the clas...
Definition: Types.h:219
Quat< float > Quats
Definition: Quat.h:646
const char * typeNameAsString< Vec3f >()
Definition: Types.h:584
T ElementType
Definition: Types.h:276
typename std::remove_const< ToType >::type Type
Definition: Types.h:348
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:128
const char * typeNameAsString< int32_t >()
Definition: Types.h:575
typename T::ValueType ElementType
Definition: Types.h:251
const char * typeNameAsString< uint32_t >()
Definition: Types.h:576
const char * typeNameAsString< int8_t >()
Definition: Types.h:571
Vec2< int32_t > Vec2i
Definition: Vec2.h:556
const char * typeNameAsString< half >()
Definition: Types.h:568
CanConvertType<FromType, ToType>::value is true if a value of type ToType can be constructed from a v...
Definition: Types.h:312
const char * typeNameAsString< int64_t >()
Definition: Types.h:577
Vec4< float > Vec4s
Definition: Vec4.h:586
AValueType mResultVal
Definition: Types.h:697
Definition: Exceptions.h:40
void operator()(CombineArgs< ValueType > &args)
Definition: Types.h:712
This struct collects both input and output arguments to "grid combiner" functors used with the tree::...
Definition: Types.h:617
Integer wrapper, required to distinguish PointIndexGrid and PointDataGrid from Int32Grid and Int64Gri...
Definition: Types.h:183
PointIndex operator+(T x)
Needed to support the (zeroVal<PointIndex>() + val) idiom.
Definition: Types.h:198
3x3 matrix class.
Definition: Mat3.h:55
AValueType AValueT
Definition: Types.h:620
T ElementType
Definition: Types.h:243
Tag dispatch class that distinguishes constructors during file input.
Definition: Types.h:752