4#ifndef OPENVDB_TYPES_HAS_BEEN_INCLUDED
5#define OPENVDB_TYPES_HAS_BEEN_INCLUDED
95template<
typename T>
using SharedPtr = std::shared_ptr<T>;
96template<
typename T>
using WeakPtr = std::weak_ptr<T>;
136template<
typename IntType_, Index Kind>
139 static_assert(std::is_integral<IntType_>::value,
"PointIndex requires an integer value type");
206#define OPENVDB_INIT_INVOKABLE_MEMBER_FUNCTION(F) \
207 template <typename ClassT, typename... Args> \
208 struct HasInvokableMemberFunction_##F { \
210 template <typename T> \
211 static auto check(T*) -> \
212 decltype(std::declval<T>(). \
213 F(std::declval<Args>()...), std::true_type()); \
214 template <typename T> \
215 static auto check(...) -> std::false_type; \
217 static constexpr bool value = \
218 decltype(check<ClassT>(nullptr))::value; \
220#define OPENVDB_HAS_INVOKABLE_MEMBER_FUNCTION(T, F, ...) \
221 HasInvokableMemberFunction_##F<T, __VA_ARGS__>::value
223#define OPENVDB_INIT_MEMBER_FUNCTION(F) \
224 template<typename ClassT, typename Signature> \
225 struct HasMemberFunction_##F { \
226 template <typename U, U> struct sigmatch; \
227 template <typename U> static std::true_type \
228 check(sigmatch<Signature, &U::F>*); \
229 template <typename> static std::false_type check(...); \
230 static const bool value = std::is_same<std::true_type, \
231 decltype(check<ClassT>(nullptr))>::value; \
233#define OPENVDB_HAS_MEMBER_FUNCTION(T, F, S) \
234 HasMemberFunction_##F<T, S>::value
243template <
typename T,
template <
typename...>
class Template>
246template <
typename... Args,
template <
typename...>
class Template>
274template <std::size_t... Ns>
277template <std::size_t N, std::size_t... Is>
284template <std::
size_t N>
286 std::decay_t<decltype(make_index_sequence_impl<N>())>;
292template<typename T, bool = IsSpecializationOf<T, math::Vec2>::value ||
298 static const int Size = T::size;
310template<typename T, bool = IsSpecializationOf<T, math::Quat>::value>
314 static const int Size = T::size;
326template<typename T, bool = IsSpecializationOf<T, math::Mat3>::value ||
331 static const int Size = T::size;
343template<typename T, bool = VecTraits<T>::IsVec ||
352 static const int Size = T::size;
383namespace types_internal
385template <
size_t Bits,
bool Signed>
struct int_t;
386template <>
struct int_t<8ul, true> {
using type = int8_t; };
387template <>
struct int_t<16ul, true> {
using type = int16_t; };
388template <>
struct int_t<32ul, true> {
using type = int32_t; };
389template <>
struct int_t<64ul, true> {
using type = int64_t; };
390template <>
struct int_t<8ul, false> {
using type = uint8_t; };
391template <>
struct int_t<16ul, false> {
using type = uint16_t; };
392template <>
struct int_t<32ul, false> {
using type = uint32_t; };
393template <>
struct int_t<64ul, false> {
using type = uint64_t; };
395template <
size_t Bits>
struct flt_t;
396template <>
struct flt_t<16ul> {
using type = math::half; };
397template <>
struct flt_t<32ul> {
using type = float; };
398template <>
struct flt_t<64ul> {
using type = double; };
412 template <
size_t bits>
413 using TypeT =
typename std::conditional<std::is_integral<T>::value,
414 types_internal::int_t<bits, std::is_signed<T>::value>,
415 types_internal::flt_t<std::max(
size_t(16), bits)>>::type;
417 static_assert(
sizeof(T) <= 8ul,
"Unsupported source type for promotion");
419#define OPENVDB_TARGET_BITS(SHIFT, PROMOTE) \
420 std::max(size_t(8), \
421 std::min(size_t(64), (PROMOTE ? size_t(8)*(sizeof(T)<<SHIFT) : \
422 size_t(8)*(sizeof(T)>>SHIFT))))
425#undef OPENVDB_TARGET_BITS
428 using Lowest =
typename TypeT<8ul>::type;
433template <
typename T,
template <
typename>
class ContainerT>
437 template <
size_t Shift = ~0UL>
using Demote = ContainerT<typename PromoteType<T>::template
Demote<Shift>>;
438 using Highest = ContainerT<typename PromoteType<T>::Highest>;
439 using Lowest = ContainerT<typename PromoteType<T>::Lowest>;
440 using Next = ContainerT<typename PromoteType<T>::Next>;
441 using Previous = ContainerT<typename PromoteType<T>::Previous>;
458template<
typename FromType,
typename ToType>
470template<
typename T0,
typename T1>
472template<
typename T0,
typename T1>
474template<
typename T0,
typename T1>
495 using Type =
typename std::remove_const<ToType>::type;
499template<
typename FromType,
typename ToType>
struct CopyConstness<const FromType, ToType> {
500 using Type =
const ToType;
638template<
typename AValueType,
typename BValueType = AValueType>
657 bool aOn =
false,
bool bOn =
false)
668 CombineArgs(
const AValueType&
a,
const BValueType&
b,
bool aOn =
false,
bool bOn =
false)
729template<
typename ValueType,
typename CombineOp>
770 for (
unsigned i = 0; i < 3; ++i, ++op, ++ip) {
General-purpose arithmetic and comparison routines, most of which accept arbitrary value types (or at...
A TypeList provides a compile time sequence of heterogeneous types which can be accessed,...
This struct collects both input and output arguments to "grid combiner" functors used with the tree::...
Definition Types.h:640
CombineArgs & setARef(const AValueType &a)
Redirect the A value to a new external source.
Definition Types.h:692
bool bIsActive() const
Definition Types.h:701
const AValueType & result() const
Get the output value.
Definition Types.h:684
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
bool mAIsActive
Definition Types.h:721
AValueType * mResultValPtr
Definition Types.h:720
void updateResultActive()
Definition Types.h:715
CombineArgs & setResultIsActive(bool b)
Set the active state of the output value.
Definition Types.h:710
const AValueType * mAValPtr
Definition Types.h:717
AValueType mResultVal
Definition Types.h:719
bool aIsActive() const
Definition Types.h:699
bool mBIsActive
Definition Types.h:721
CombineArgs & setBIsActive(bool b)
Set the active state of the B value.
Definition Types.h:708
const BValueType & b() const
Get the B input value.
Definition Types.h:681
const BValueType * mBValPtr
Definition Types.h:718
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
CombineArgs & setResultRef(AValueType &val)
Redirect the result value to a new external destination.
Definition Types.h:696
AValueType & result()
Definition Types.h:685
AValueType AValueT
Definition Types.h:642
CombineArgs & setBRef(const BValueType &b)
Redirect the B value to a new external source.
Definition Types.h:694
const AValueType & a() const
Get the A input value.
Definition Types.h:679
bool resultIsActive() const
Definition Types.h:703
bool mResultIsActive
Definition Types.h:722
BValueType BValueT
Definition Types.h:643
CombineArgs()
Definition Types.h:645
CombineArgs & setResult(const AValueType &val)
Set the output value.
Definition Types.h:689
CombineArgs & setAIsActive(bool b)
Set the active state of the A value.
Definition Types.h:706
Tag dispatch class that distinguishes constructors that deep copy.
Definition Types.h:756
Tag dispatch class that distinguishes constructors during file input.
Definition Types.h:760
Tag dispatch class that distinguishes shallow copy constructors from deep copy constructors.
Definition Types.h:751
Tag dispatch class that distinguishes constructors that steal.
Definition Types.h:758
Tag dispatch class that distinguishes topology copy constructors from deep copy constructors.
Definition Types.h:754
Axis-aligned bounding box.
Definition BBox.h:24
Axis-aligned bounding box of signed integer coordinates.
Definition Coord.h:252
Signed (x, y, z) 32-bit integer coordinates.
Definition Coord.h:26
3x3 matrix class.
Definition Mat3.h:29
4x4 -matrix class.
Definition Mat4.h:31
T * asPointer()
Definition Vec3.h:95
Vec2< int32_t > Vec2i
Definition Vec2.h:530
Mat4< float > Mat4s
Definition Mat4.h:1354
Vec2< double > Vec2d
Definition Vec2.h:533
Mat3< double > Mat3d
Definition Mat3.h:833
Vec2< float > Vec2s
Definition Vec2.h:532
Vec4< float > Vec4s
Definition Vec4.h:561
Mat3< float > Mat3s
Definition Mat3.h:832
Vec3< double > Vec3d
Definition Vec3.h:665
Mat4< double > Mat4d
Definition Mat4.h:1355
Vec4< int32_t > Vec4i
Definition Vec4.h:559
Quat< double > Quatd
Definition Quat.h:612
auto cwiseAdd(const Vec3H &v, const float s)
Definition Types.h:765
internal::half half
Definition HalfDecl.h:25
Vec3< int32_t > Vec3i
Definition Vec3.h:662
Vec4< double > Vec4d
Definition Vec4.h:562
Quat< float > Quats
Definition Quat.h:611
Vec3< float > Vec3s
Definition Vec3.h:664
static const Real LEVEL_SET_HALF_WIDTH
Definition Types.h:532
math::Vec4< float > Vec4f
Definition Types.h:70
Index32 Index
Definition Types.h:34
math::Vec4< Index32 > Vec4I
Definition Types.h:69
math::half Half
Definition Types.h:41
math::Vec3< uint16_t > Vec3U16
Definition Types.h:58
PointIndex< Index64, 1 > PointDataIndex64
Definition Types.h:163
math::Vec2< Real > Vec2R
Definition Types.h:44
int16_t Int16
Definition Types.h:35
PointIndex< Index64, 0 > PointIndex64
Definition Types.h:160
auto make_index_sequence_impl()
Definition Types.h:278
unsigned char Byte
Definition Types.h:39
math::Vec3< float > Vec3f
Definition Types.h:55
double Real
Definition Types.h:40
GridClass
Definition Types.h:524
@ GRID_FOG_VOLUME
Definition Types.h:527
@ GRID_STAGGERED
Definition Types.h:528
@ GRID_LEVEL_SET
Definition Types.h:526
@ GRID_UNKNOWN
Definition Types.h:525
int64_t Int64
Definition Types.h:37
PointIndex< Index32, 0 > PointIndex32
Definition Types.h:159
math::Vec2< Half > Vec2H
Definition Types.h:47
Int32 Int
Definition Types.h:38
math::Vec2< Index32 > Vec2I
Definition Types.h:45
std::decay_t< decltype(make_index_sequence_impl< N >())> make_index_sequence
Definition Types.h:285
std::weak_ptr< T > WeakPtr
Definition Types.h:96
math::Mat4< Real > Mat4R
Definition Types.h:82
uint32_t Index32
Definition Types.h:32
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:107
math::BBox< Vec3d > BBoxd
Definition Types.h:65
math::Mat3< Real > Mat3R
Definition Types.h:77
math::Vec3< Index32 > Vec3I
Definition Types.h:54
math::Vec3< Real > Vec3R
Definition Types.h:53
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:117
int32_t Int32
Definition Types.h:36
uint64_t Index64
Definition Types.h:33
@ NUM_GRID_CLASSES
Definition Types.h:530
math::Vec2< float > Vec2f
Definition Types.h:46
std::shared_ptr< T > SharedPtr
Definition Types.h:95
math::Vec4< Half > Vec4H
Definition Types.h:71
MergePolicy
Definition Types.h:577
@ MERGE_ACTIVE_STATES
Definition Types.h:578
@ MERGE_NODES
Definition Types.h:579
@ MERGE_ACTIVE_STATES_AND_NODES
Definition Types.h:580
math::Vec4< Real > Vec4R
Definition Types.h:68
math::Vec3< Half > Vec3H
Definition Types.h:56
math::Vec3< uint8_t > Vec3U8
Definition Types.h:57
VecType
Definition Types.h:554
@ VEC_CONTRAVARIANT_ABSOLUTE
Definition Types.h:559
@ VEC_CONTRAVARIANT_RELATIVE
Definition Types.h:558
@ VEC_COVARIANT
Definition Types.h:556
@ VEC_COVARIANT_NORMALIZE
Definition Types.h:557
@ VEC_INVARIANT
Definition Types.h:555
@ NUM_VEC_TYPES
Definition Types.h:561
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:127
math::Quat< Real > QuatR
Definition Types.h:87
const char * typeNameAsString()
Definition Types.h:587
PointIndex< Index32, 1 > PointDataIndex32
Definition Types.h:162
Definition Exceptions.h:13
#define OPENVDB_TARGET_BITS(SHIFT, PROMOTE)
Definition Types.h:419
@ value
Definition Types.h:477
@ value
Definition Types.h:476
@ value
Definition Types.h:471
@ value
Definition Types.h:473
@ value
Definition Types.h:475
@ value
Definition Types.h:479
@ value
Definition Types.h:464
@ value
Definition Types.h:465
@ value
Definition Types.h:466
@ value
Definition Types.h:481
@ value
Definition Types.h:467
@ value
Definition Types.h:468
@ value
Definition Types.h:469
CanConvertType<FromType, ToType>::value is true if a value of type ToType can be constructed from a v...
Definition Types.h:459
@ value
Definition Types.h:459
math::Mat3< SubT > Type
Definition Types.h:377
math::Mat4< SubT > Type
Definition Types.h:378
math::Quat< SubT > Type
Definition Types.h:376
math::Vec2< SubT > Type
Definition Types.h:373
math::Vec3< SubT > Type
Definition Types.h:374
math::Vec4< SubT > Type
Definition Types.h:375
Conversion classes for changing the underlying type of VDB types.
Definition Types.h:372
SubT Type
Definition Types.h:372
CopyConstness<T1, T2>::Type is either const T2 or T2 with no const qualifier, depending on whether T1...
Definition Types.h:494
typename std::remove_const< ToType >::type Type
Definition Types.h:495
Helper metafunction used to determine if the first template parameter is a specialization of the clas...
Definition Types.h:244
T ElementType
Definition Types.h:340
static const int Size
Definition Types.h:339
static const bool IsMat
Definition Types.h:338
static const int Size
Definition Types.h:331
typename T::ValueType ElementType
Definition Types.h:332
static const bool IsMat
Definition Types.h:330
Integer wrapper, required to distinguish PointIndexGrid and PointDataGrid from Int32Grid and Int64Gri...
Definition Types.h:138
PointIndex(T i)
Explicit type conversion constructor.
Definition Types.h:146
PointIndex(IntType i=IntType(0))
Definition Types.h:143
PointIndex operator+(T x)
Needed to support the (zeroVal<PointIndex>() + val) idiom.
Definition Types.h:152
IntType_ IntType
Definition Types.h:141
T ElementType
Definition Types.h:323
static const int Size
Definition Types.h:322
static const bool IsQuat
Definition Types.h:321
static const int Size
Definition Types.h:314
typename T::ValueType ElementType
Definition Types.h:315
static const bool IsQuat
Definition Types.h:313
SwappedCombineOp(CombineOp &_op)
Definition Types.h:732
void operator()(CombineArgs< ValueType > &args)
Definition Types.h:734
CombineOp & op
Definition Types.h:742
T ElementType
Definition Types.h:366
static const int Elements
Definition Types.h:365
static const bool IsVec
Definition Types.h:360
static const int Size
Definition Types.h:364
static const bool IsQuat
Definition Types.h:361
static const bool IsScalar
Definition Types.h:363
static const bool IsMat
Definition Types.h:362
static const int Elements
Definition Types.h:353
static const bool IsVec
Definition Types.h:348
static const int Size
Definition Types.h:352
typename T::ValueType ElementType
Definition Types.h:354
static const bool IsQuat
Definition Types.h:349
static const bool IsScalar
Definition Types.h:351
static const bool IsMat
Definition Types.h:350
T ElementType
Definition Types.h:307
static const bool IsVec
Definition Types.h:305
static const int Size
Definition Types.h:306
static const bool IsVec
Definition Types.h:297
static const int Size
Definition Types.h:298
typename T::ValueType ElementType
Definition Types.h:299
Re-implementation of C++17's index_sequence and the helper alias make_index_sequence....
Definition Types.h:275
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition version.h.in:121
#define OPENVDB_USE_VERSION_NAMESPACE
Definition version.h.in:218