4 #ifndef OPENVDB_TYPES_HAS_BEEN_INCLUDED 5 #define OPENVDB_TYPES_HAS_BEEN_INCLUDED 11 #ifdef OPENVDB_USE_IMATH_HALF 12 #ifdef OPENVDB_IMATH_VERSION 13 #include <Imath/half.h> 15 #include <OpenEXR/half.h> 44 #include <type_traits> 59 using Byte =
unsigned char;
114 template<
typename T>
using SharedPtr = std::shared_ptr<T>;
115 template<
typename T>
using WeakPtr = std::weak_ptr<T>;
155 template<
typename IntType_, Index Kind>
158 static_assert(std::is_integral<IntType_>::value,
"PointIndex requires an integer value type");
225 #define OPENVDB_INIT_INVOKABLE_MEMBER_FUNCTION(F) \ 226 template <typename ClassT, typename... Args> \ 227 struct HasInvokableMemberFunction_##F { \ 229 template <typename T> \ 230 static auto check(T*) -> \ 231 decltype(std::declval<T>(). \ 232 F(std::declval<Args>()...), std::true_type()); \ 233 template <typename T> \ 234 static auto check(...) -> std::false_type; \ 236 static constexpr bool value = \ 237 decltype(check<ClassT>(nullptr))::value; \ 239 #define OPENVDB_HAS_INVOKABLE_MEMBER_FUNCTION(T, F, ...) \ 240 HasInvokableMemberFunction_##F<T, __VA_ARGS__>::value 242 #define OPENVDB_INIT_MEMBER_FUNCTION(F) \ 243 template<typename ClassT, typename Signature> \ 244 struct HasMemberFunction_##F { \ 245 template <typename U, U> struct sigmatch; \ 246 template <typename U> static std::true_type \ 247 check(sigmatch<Signature, &U::F>*); \ 248 template <typename> static std::false_type check(...); \ 249 static const bool value = std::is_same<std::true_type, \ 250 decltype(check<ClassT>(nullptr))>::value; \ 252 #define OPENVDB_HAS_MEMBER_FUNCTION(T, F, S) \ 253 HasMemberFunction_##F<T, S>::value 262 template <
typename T,
template <
typename...>
class Template>
265 template <
typename... Args,
template <
typename...>
class Template>
293 template <std::size_t... Ns>
296 template <std::size_t N, std::size_t... Is>
303 template <std::
size_t N>
305 std::decay_t<decltype(make_index_sequence_impl<N>())>;
311 template<typename T, bool = IsSpecializationOf<T, math::Vec2>::value ||
316 static const bool IsVec =
true;
317 static const int Size = T::size;
324 static const bool IsVec =
false;
325 static const int Size = 1;
329 template<typename T, bool = IsSpecializationOf<T, math::Quat>::value>
332 static const bool IsQuat =
true;
333 static const int Size = T::size;
340 static const bool IsQuat =
false;
341 static const int Size = 1;
345 template<typename T, bool = IsSpecializationOf<T, math::Mat3>::value ||
349 static const bool IsMat =
true;
350 static const int Size = T::size;
357 static const bool IsMat =
false;
358 static const int Size = 1;
362 template<typename T, bool = VecTraits<T>::IsVec ||
370 static const bool IsScalar =
false;
371 static const int Size = T::size;
372 static const int Elements = IsMat ? Size*Size : Size;
379 static const bool IsVec =
false;
380 static const bool IsQuat =
false;
381 static const bool IsMat =
false;
382 static const bool IsScalar =
true;
383 static const int Size = 1;
384 static const int Elements = 1;
400 namespace types_internal
402 template <
size_t Bits,
bool Signed>
struct int_t;
403 template <>
struct int_t<8ul, true> {
using type = int8_t; };
404 template <>
struct int_t<16ul, true> {
using type = int16_t; };
405 template <>
struct int_t<32ul, true> {
using type = int32_t; };
406 template <>
struct int_t<64ul, true> {
using type = int64_t; };
407 template <>
struct int_t<8ul, false> {
using type = uint8_t; };
408 template <>
struct int_t<16ul, false> {
using type = uint16_t; };
409 template <>
struct int_t<32ul, false> {
using type = uint32_t; };
410 template <>
struct int_t<64ul, false> {
using type = uint64_t; };
412 template <
size_t Bits>
struct flt_t;
415 template <>
struct flt_t<64ul> {
using type = double; };
427 template <
size_t bits>
428 using TypeT =
typename std::conditional<std::is_integral<T>::value,
432 static_assert(
sizeof(T) <= 8ul,
"Unsupported source type for promotion");
434 #define OPENVDB_TARGET_BITS(SHIFT, PROMOTE) \ 435 std::max(size_t(8), \ 436 std::min(size_t(64), (PROMOTE ? size_t(8)*(sizeof(T)<<SHIFT) : \ 437 size_t(8)*(sizeof(T)>>SHIFT)))) 438 template <
size_t Shift = ~0UL>
using Promote =
typename TypeT<OPENVDB_TARGET_BITS(Shift, true)>::type;
439 template <
size_t Shift = ~0UL>
using Demote =
typename TypeT<OPENVDB_TARGET_BITS(Shift, false)>::type;
440 #undef OPENVDB_TARGET_BITS 443 using Lowest =
typename TypeT<8ul>::type;
448 template <
typename T,
template <
typename>
class ContainerT>
452 template <
size_t Shift = ~0UL>
using Demote = ContainerT<typename PromoteType<T>::template
Demote<Shift>>;
453 using Highest = ContainerT<typename PromoteType<T>::Highest>;
454 using Lowest = ContainerT<typename PromoteType<T>::Lowest>;
455 using Next = ContainerT<typename PromoteType<T>::Next>;
456 using Previous = ContainerT<typename PromoteType<T>::Previous>;
473 template<
typename FromType,
typename ToType>
474 struct CanConvertType {
enum { value = std::is_constructible<ToType, FromType>::value }; };
479 template<
typename T>
struct CanConvertType<T, math::Vec2<T> > {
enum { value =
true }; };
480 template<
typename T>
struct CanConvertType<T, math::Vec3<T> > {
enum { value =
true }; };
481 template<
typename T>
struct CanConvertType<T, math::Vec4<T> > {
enum { value =
true }; };
485 template<
typename T0,
typename T1>
487 template<
typename T0,
typename T1>
489 template<
typename T0,
typename T1>
510 using Type =
typename std::remove_const<ToType>::type;
514 template<
typename FromType,
typename ToType>
struct CopyConstness<const FromType, ToType> {
515 using Type =
const ToType;
590 template<>
inline const char* typeNameAsString<math::half>() {
return "half"; }
611 template<>
inline const char* typeNameAsString<std::string>() {
return "string"; }
616 template<>
inline const char* typeNameAsString<math::Quats>() {
return "quats"; }
617 template<>
inline const char* typeNameAsString<math::Quatd>() {
return "quatd"; }
638 template<
typename AValueType,
typename BValueType = AValueType>
648 , mResultValPtr(&mResultVal)
651 , mResultIsActive(false)
656 CombineArgs(
const AValueType& a,
const BValueType& b, AValueType& result,
657 bool aOn =
false,
bool bOn =
false)
660 , mResultValPtr(&result)
664 this->updateResultActive();
668 CombineArgs(
const AValueType& a,
const BValueType& b,
bool aOn =
false,
bool bOn =
false)
671 , mResultValPtr(&mResultVal)
675 this->updateResultActive();
679 const AValueType&
a()
const {
return *mAValPtr; }
681 const BValueType&
b()
const {
return *mBValPtr; }
684 const AValueType&
result()
const {
return *mResultValPtr; }
685 AValueType&
result() {
return *mResultValPtr; }
729 template<
typename ValueType,
typename CombineOp>
770 for (
unsigned i = 0; i < 3; ++i, ++
op, ++ip) {
783 #endif // OPENVDB_TYPES_HAS_BEEN_INCLUDED Helper metafunction used to determine if the first template parameter is a specialization of the clas...
Definition: Types.h:263
const char * typeNameAsString< double >()
Definition: Types.h:592
const char * typeNameAsString< int16_t >()
Definition: Types.h:595
const char * typeNameAsString< PointDataIndex32 >()
Definition: Types.h:620
AValueType AValueT
Definition: Types.h:642
Vec2< float > Vec2s
Definition: Vec2.h:532
Mat4< double > Mat4d
Definition: Mat4.h:1355
int32_t Int32
Definition: Types.h:56
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:668
auto make_index_sequence_impl()
Definition: Types.h:297
const char * typeNameAsString< Mat3d >()
Definition: Types.h:613
uint64_t Index64
Definition: Types.h:53
General-purpose arithmetic and comparison routines, most of which accept arbitrary value types (or at...
const char * typeNameAsString< Vec2s >()
Definition: Types.h:601
const char * typeNameAsString< uint32_t >()
Definition: Types.h:598
T * asPointer()
Definition: Vec3.h:95
const char * typeNameAsString< Vec3d >()
Definition: Types.h:607
Vec2< double > Vec2d
Definition: Vec2.h:533
T ElementType
Definition: Types.h:359
PointIndex operator+(T x)
Needed to support the (zeroVal<PointIndex>() + val) idiom.
Definition: Types.h:171
std::shared_ptr< T > SharedPtr
Definition: Types.h:114
Tag dispatch class that distinguishes shallow copy constructors from deep copy constructors.
Definition: Types.h:751
Re-implementation of C++17's index_sequence and the helper alias make_index_sequence. This was introduced to fix an issue with clang's builtin implementation which treats template specializations of builtin templates differently when a subsequent parameter is dependent. The result is a resolution failure during partial specialization selection. For example, the following will fail to specialize:
Definition: Types.h:294
void operator()(CombineArgs< ValueType > &args)
Definition: Types.h:734
This struct collects both input and output arguments to "grid combiner" functors used with the tree::...
Definition: Types.h:639
Axis-aligned bounding box of signed integer coordinates.
Definition: Coord.h:251
T ElementType
Definition: Types.h:342
Mat4< float > Mat4s
Definition: Mat4.h:1354
const char * typeNameAsString< Vec4i >()
Definition: Types.h:608
Index32 Index
Definition: Types.h:54
Vec4< int32_t > Vec4i
Definition: Vec4.h:559
internal::half half
Definition: Types.h:29
const char * typeNameAsString< int32_t >()
Definition: Types.h:597
const AValueType & a() const
Get the A input value.
Definition: Types.h:679
CombineArgs & setBRef(const BValueType &b)
Redirect the B value to a new external source.
Definition: Types.h:694
Vec4< double > Vec4d
Definition: Vec4.h:562
typename std::remove_const< ToType >::type Type
Definition: Types.h:510
int32_t type
Definition: Types.h:405
Quat< double > Quatd
Definition: Quat.h:602
const char * typeNameAsString< Vec4d >()
Definition: Types.h:610
CanConvertType<FromType, ToType>::value is true if a value of type ToType can be constructed from a v...
Definition: Types.h:474
Mat3< float > Mat3s
Definition: Mat3.h:832
bool bIsActive() const
Definition: Types.h:701
Vec3< int32_t > Vec3i
Definition: Vec3.h:662
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:146
const char * typeNameAsString< Vec2i >()
Definition: Types.h:600
const char * typeNameAsString< Vec4f >()
Definition: Types.h:609
const char * typeNameAsString< Vec2d >()
Definition: Types.h:602
AValueType * mResultValPtr
Definition: Types.h:720
Tag dispatch class that distinguishes constructors that steal.
Definition: Types.h:758
IntType_ IntType
Definition: Types.h:160
AValueType & result()
Get the output value.
Definition: Types.h:685
Conversion classes for changing the underlying type of VDB types.
Definition: Types.h:391
BValueType BValueT
Definition: Types.h:643
int16_t Int16
Definition: Types.h:55
CombineArgs & setResultIsActive(bool b)
Set the active state of the output value.
Definition: Types.h:710
const BValueType * mBValPtr
Definition: Types.h:718
CombineArgs & setBIsActive(bool b)
Set the active state of the B value.
Definition: Types.h:708
uint32_t Index32
Definition: Types.h:52
const char * typeNameAsString< Vec3f >()
Definition: Types.h:606
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:136
const char * typeNameAsString< PointDataIndex64 >()
Definition: Types.h:621
const char * typeNameAsString< uint8_t >()
Definition: Types.h:594
SwappedCombineOp(CombineOp &_op)
Definition: Types.h:732
CombineArgs & setResultRef(AValueType &val)
Redirect the result value to a new external destination.
Definition: Types.h:696
Mat3< double > Mat3d
Definition: Mat3.h:833
const AValueType & result() const
Get the output value.
Definition: Types.h:684
const char * typeNameAsString< bool >()
Definition: Types.h:588
Signed (x, y, z) 32-bit integer coordinates.
Definition: Coord.h:25
Tag dispatch class that distinguishes constructors that deep copy.
Definition: Types.h:756
Integer wrapper, required to distinguish PointIndexGrid and PointDataGrid from Int32Grid and Int64Gri...
Definition: Types.h:156
double type
Definition: Types.h:415
bool mResultIsActive
Definition: Types.h:722
Definition: Exceptions.h:13
const char * typeNameAsString< Mat3s >()
Definition: Types.h:612
const char * typeNameAsString()
Definition: Types.h:587
unsigned char Byte
Definition: Types.h:59
uint32_t type
Definition: Types.h:409
Vec2< int32_t > Vec2i
Definition: Vec2.h:530
CombineArgs & setARef(const AValueType &a)
Redirect the A value to a new external source.
Definition: Types.h:692
uint64_t type
Definition: Types.h:410
CombineArgs()
Definition: Types.h:645
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:656
std::weak_ptr< T > WeakPtr
Definition: Types.h:115
Tag dispatch class that distinguishes constructors during file input.
Definition: Types.h:760
static const Real LEVEL_SET_HALF_WIDTH
Definition: Types.h:532
float type
Definition: Types.h:414
CopyConstness<T1, T2>::Type is either const T2 or T2 with no const qualifier, depending on whether T1...
Definition: Types.h:509
const char * typeNameAsString< Vec3U8 >()
Definition: Types.h:603
T ElementType
Definition: Types.h:385
typename T::ValueType ElementType
Definition: Types.h:318
double Real
Definition: Types.h:60
A TypeList provides a compile time sequence of heterogeneous types which can be accessed, transformed and executed over in various ways. It incorporates a subset of functionality similar to boost::mpl::vector however provides most of its content through using declarations rather than additional typed classes.
Vec3< double > Vec3d
Definition: Vec3.h:665
uint8_t type
Definition: Types.h:407
MergePolicy
Definition: Types.h:577
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:126
const char * typeNameAsString< Mat4d >()
Definition: Types.h:615
typename T::ValueType ElementType
Definition: Types.h:373
const char * typeNameAsString< PointIndex32 >()
Definition: Types.h:618
int16_t type
Definition: Types.h:404
uint16_t type
Definition: Types.h:408
bool mBIsActive
Definition: Types.h:721
const AValueType * mAValPtr
Definition: Types.h:717
const char * typeNameAsString< Vec3i >()
Definition: Types.h:605
GridClass
Definition: Types.h:524
Quat< float > Quats
Definition: Quat.h:601
int64_t Int64
Definition: Types.h:57
const BValueType & b() const
Get the B input value.
Definition: Types.h:681
PointIndex(T i)
Explicit type conversion constructor.
Definition: Types.h:165
int8_t type
Definition: Types.h:403
typename T::ValueType ElementType
Definition: Types.h:334
SubT Type
Definition: Types.h:391
const char * typeNameAsString< int64_t >()
Definition: Types.h:599
const char * typeNameAsString< Mat4s >()
Definition: Types.h:614
Vec4< float > Vec4s
Definition: Vec4.h:561
const char * typeNameAsString< int8_t >()
Definition: Types.h:593
T ElementType
Definition: Types.h:326
void updateResultActive()
Definition: Types.h:715
CombineArgs & setAIsActive(bool b)
Set the active state of the A value.
Definition: Types.h:706
AValueType mResultVal
Definition: Types.h:719
Int32 Int
Definition: Types.h:58
bool aIsActive() const
Definition: Types.h:699
CombineArgs & setResult(const AValueType &val)
Set the output value.
Definition: Types.h:689
auto cwiseAdd(const math::Vec3< math::half > &v, const float s)
Definition: Types.h:765
const char * typeNameAsString< float >()
Definition: Types.h:591
PointIndex(IntType i=IntType(0))
Definition: Types.h:162
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h.in:121
typename T::ValueType ElementType
Definition: Types.h:351
const char * typeNameAsString< PointIndex64 >()
Definition: Types.h:619
Tag dispatch class that distinguishes topology copy constructors from deep copy constructors.
Definition: Types.h:754
VecType
Definition: Types.h:554
CombineOp & op
Definition: Types.h:742
std::decay_t< decltype(make_index_sequence_impl< N >())> make_index_sequence
Definition: Types.h:305
const char * typeNameAsString< uint16_t >()
Definition: Types.h:596
int64_t type
Definition: Types.h:406
const char * typeNameAsString< Vec3U16 >()
Definition: Types.h:604
Vec3< float > Vec3s
Definition: Vec3.h:664
bool resultIsActive() const
Definition: Types.h:703
3x3 matrix class.
Definition: Mat3.h:28
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h.in:218
const char * typeNameAsString< ValueMask >()
Definition: Types.h:589