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>
114template<
typename T>
using SharedPtr = std::shared_ptr<T>;
115template<
typename T>
using WeakPtr = std::weak_ptr<T>;
155template<
typename IntType_, Index Kind>
158 static_assert(std::is_integral<IntType_>::value,
"PointIndex requires an integer value type");
191template <
typename T,
template <
typename...>
class Template>
194template <
typename... Args,
template <
typename...>
class Template>
222template <std::size_t... Ns>
225template <std::size_t N, std::size_t... Is>
232template <std::
size_t N>
234 std::decay_t<decltype(make_index_sequence_impl<N>())>;
240template<typename T, bool = IsSpecializationOf<T, math::Vec2>::value ||
245 static const bool IsVec =
true;
246 static const int Size = T::size;
253 static const bool IsVec =
false;
254 static const int Size = 1;
258template<typename T, bool = IsSpecializationOf<T, math::Quat>::value>
261 static const bool IsQuat =
true;
262 static const int Size = T::size;
269 static const bool IsQuat =
false;
270 static const int Size = 1;
274template<typename T, bool = IsSpecializationOf<T, math::Mat3>::value ||
278 static const bool IsMat =
true;
279 static const int Size = T::size;
286 static const bool IsMat =
false;
287 static const int Size = 1;
291template<typename T, bool = VecTraits<T>::IsVec ||
299 static const bool IsScalar =
false;
300 static const int Size = T::size;
301 static const int Elements = IsMat ? Size*Size : Size;
308 static const bool IsVec =
false;
309 static const bool IsQuat =
false;
310 static const bool IsMat =
false;
311 static const bool IsScalar =
true;
312 static const int Size = 1;
313 static const int Elements = 1;
329namespace types_internal
331template <
size_t Bits,
bool Signed>
struct int_t;
332template <>
struct int_t<8ul, true> {
using type = int8_t; };
333template <>
struct int_t<16ul, true> {
using type = int16_t; };
334template <>
struct int_t<32ul, true> {
using type = int32_t; };
335template <>
struct int_t<64ul, true> {
using type = int64_t; };
336template <>
struct int_t<8ul, false> {
using type = uint8_t; };
337template <>
struct int_t<16ul, false> {
using type = uint16_t; };
338template <>
struct int_t<32ul, false> {
using type = uint32_t; };
339template <>
struct int_t<64ul, false> {
using type = uint64_t; };
356 template <
size_t bits>
357 using TypeT =
typename std::conditional<std::is_integral<T>::value,
361 static_assert(
sizeof(T) <= 8ul,
"Unsupported source type for promotion");
363#define OPENVDB_TARGET_BITS(SHIFT, PROMOTE) \
364 std::max(size_t(8), \
365 std::min(size_t(64), (PROMOTE ? size_t(8)*(sizeof(T)<<SHIFT) : \
366 size_t(8)*(sizeof(T)>>SHIFT))))
369#undef OPENVDB_TARGET_BITS
372 using Lowest =
typename TypeT<8ul>::type;
377template <
typename T,
template <
typename>
class ContainerT>
381 template <
size_t Shift = ~0UL>
using Demote = ContainerT<typename PromoteType<T>::template
Demote<Shift>>;
382 using Highest = ContainerT<typename PromoteType<T>::Highest>;
383 using Lowest = ContainerT<typename PromoteType<T>::Lowest>;
384 using Next = ContainerT<typename PromoteType<T>::Next>;
385 using Previous = ContainerT<typename PromoteType<T>::Previous>;
402template<
typename FromType,
typename ToType>
403struct CanConvertType {
enum { value = std::is_constructible<ToType, FromType>::value }; };
414template<
typename T0,
typename T1>
416template<
typename T0,
typename T1>
418template<
typename T0,
typename T1>
439 using Type =
typename std::remove_const<ToType>::type;
443template<
typename FromType,
typename ToType>
struct CopyConstness<const FromType, ToType> {
444 using Type =
const ToType;
517template<>
inline const char* typeNameAsString<bool>() {
return "bool"; }
518template<>
inline const char* typeNameAsString<ValueMask>() {
return "mask"; }
519template<>
inline const char* typeNameAsString<math::half>() {
return "half"; }
520template<>
inline const char* typeNameAsString<float>() {
return "float"; }
521template<>
inline const char* typeNameAsString<double>() {
return "double"; }
522template<>
inline const char* typeNameAsString<int8_t>() {
return "int8"; }
523template<>
inline const char* typeNameAsString<uint8_t>() {
return "uint8"; }
524template<>
inline const char* typeNameAsString<int16_t>() {
return "int16"; }
525template<>
inline const char* typeNameAsString<uint16_t>() {
return "uint16"; }
526template<>
inline const char* typeNameAsString<int32_t>() {
return "int32"; }
527template<>
inline const char* typeNameAsString<uint32_t>() {
return "uint32"; }
528template<>
inline const char* typeNameAsString<int64_t>() {
return "int64"; }
529template<>
inline const char* typeNameAsString<Vec2i>() {
return "vec2i"; }
530template<>
inline const char* typeNameAsString<Vec2s>() {
return "vec2s"; }
531template<>
inline const char* typeNameAsString<Vec2d>() {
return "vec2d"; }
532template<>
inline const char* typeNameAsString<Vec3U8>() {
return "vec3u8"; }
533template<>
inline const char* typeNameAsString<Vec3U16>() {
return "vec3u16"; }
534template<>
inline const char* typeNameAsString<Vec3i>() {
return "vec3i"; }
535template<>
inline const char* typeNameAsString<Vec3f>() {
return "vec3s"; }
536template<>
inline const char* typeNameAsString<Vec3d>() {
return "vec3d"; }
537template<>
inline const char* typeNameAsString<Vec4i>() {
return "vec4i"; }
538template<>
inline const char* typeNameAsString<Vec4f>() {
return "vec4s"; }
539template<>
inline const char* typeNameAsString<Vec4d>() {
return "vec4d"; }
540template<>
inline const char* typeNameAsString<std::string>() {
return "string"; }
541template<>
inline const char* typeNameAsString<Mat3s>() {
return "mat3s"; }
542template<>
inline const char* typeNameAsString<Mat3d>() {
return "mat3d"; }
543template<>
inline const char* typeNameAsString<Mat4s>() {
return "mat4s"; }
544template<>
inline const char* typeNameAsString<Mat4d>() {
return "mat4d"; }
545template<>
inline const char* typeNameAsString<math::Quats>() {
return "quats"; }
546template<>
inline const char* typeNameAsString<math::Quatd>() {
return "quatd"; }
547template<>
inline const char* typeNameAsString<PointIndex32>() {
return "ptidx32"; }
548template<>
inline const char* typeNameAsString<PointIndex64>() {
return "ptidx64"; }
549template<>
inline const char* typeNameAsString<PointDataIndex32>() {
return "ptdataidx32"; }
550template<>
inline const char* typeNameAsString<PointDataIndex64>() {
return "ptdataidx64"; }
567template<
typename AValueType,
typename BValueType = AValueType>
577 , mResultValPtr(&mResultVal)
580 , mResultIsActive(false)
585 CombineArgs(
const AValueType& a,
const BValueType& b, AValueType& result,
586 bool aOn =
false,
bool bOn =
false)
589 , mResultValPtr(&result)
593 this->updateResultActive();
597 CombineArgs(
const AValueType& a,
const BValueType& b,
bool aOn =
false,
bool bOn =
false)
600 , mResultValPtr(&mResultVal)
604 this->updateResultActive();
608 const AValueType&
a()
const {
return *mAValPtr; }
610 const BValueType&
b()
const {
return *mBValPtr; }
613 const AValueType&
result()
const {
return *mResultValPtr; }
614 AValueType&
result() {
return *mResultValPtr; }
658template<
typename ValueType,
typename CombineOp>
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:569
CombineArgs & setARef(const AValueType &a)
Redirect the A value to a new external source.
Definition Types.h:621
bool bIsActive() const
Definition Types.h:630
const AValueType & result() const
Get the output value.
Definition Types.h:613
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:585
bool mAIsActive
Definition Types.h:650
AValueType * mResultValPtr
Definition Types.h:649
void updateResultActive()
Definition Types.h:644
CombineArgs & setResultIsActive(bool b)
Set the active state of the output value.
Definition Types.h:639
const AValueType * mAValPtr
Definition Types.h:646
AValueType mResultVal
Definition Types.h:648
bool aIsActive() const
Definition Types.h:628
CombineArgs & setBIsActive(bool b)
Set the active state of the B value.
Definition Types.h:637
const BValueType & b() const
Get the B input value.
Definition Types.h:610
const BValueType * mBValPtr
Definition Types.h:647
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:597
CombineArgs & setResultRef(AValueType &val)
Redirect the result value to a new external destination.
Definition Types.h:625
AValueType & result()
Definition Types.h:614
AValueType AValueT
Definition Types.h:571
CombineArgs & setBRef(const BValueType &b)
Redirect the B value to a new external source.
Definition Types.h:623
const AValueType & a() const
Get the A input value.
Definition Types.h:608
bool resultIsActive() const
Definition Types.h:632
bool mResultIsActive
Definition Types.h:651
BValueType BValueT
Definition Types.h:572
CombineArgs()
Definition Types.h:574
CombineArgs & setResult(const AValueType &val)
Set the output value.
Definition Types.h:618
CombineArgs & setAIsActive(bool b)
Set the active state of the A value.
Definition Types.h:635
Tag dispatch class that distinguishes constructors that deep copy.
Definition Types.h:685
Tag dispatch class that distinguishes constructors during file input.
Definition Types.h:689
Tag dispatch class that distinguishes shallow copy constructors from deep copy constructors.
Definition Types.h:680
Tag dispatch class that distinguishes constructors that steal.
Definition Types.h:687
Tag dispatch class that distinguishes topology copy constructors from deep copy constructors.
Definition Types.h:683
Axis-aligned bounding box of signed integer coordinates.
Definition Coord.h:251
Signed (x, y, z) 32-bit integer coordinates.
Definition Coord.h:25
3x3 matrix class.
Definition Mat3.h:29
internal::half half
Definition Types.h:29
static const Real LEVEL_SET_HALF_WIDTH
Definition Types.h:461
@ NUM_GRID_CLASSES
Definition Types.h:459
Index32 Index
Definition Types.h:54
int16_t Int16
Definition Types.h:55
auto make_index_sequence_impl()
Definition Types.h:226
unsigned char Byte
Definition Types.h:59
double Real
Definition Types.h:60
GridClass
Definition Types.h:453
@ GRID_FOG_VOLUME
Definition Types.h:456
@ GRID_STAGGERED
Definition Types.h:457
@ GRID_LEVEL_SET
Definition Types.h:455
@ GRID_UNKNOWN
Definition Types.h:454
int64_t Int64
Definition Types.h:57
Int32 Int
Definition Types.h:58
std::decay_t< decltype(make_index_sequence_impl< N >())> make_index_sequence
Definition Types.h:233
std::weak_ptr< T > WeakPtr
Definition Types.h:115
uint32_t Index32
Definition Types.h:52
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
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
int32_t Int32
Definition Types.h:56
uint64_t Index64
Definition Types.h:53
std::shared_ptr< T > SharedPtr
Definition Types.h:114
MergePolicy
Definition Types.h:506
@ MERGE_ACTIVE_STATES
Definition Types.h:507
@ MERGE_NODES
Definition Types.h:508
@ MERGE_ACTIVE_STATES_AND_NODES
Definition Types.h:509
@ NUM_VEC_TYPES
Definition Types.h:490
VecType
Definition Types.h:483
@ VEC_CONTRAVARIANT_ABSOLUTE
Definition Types.h:488
@ VEC_CONTRAVARIANT_RELATIVE
Definition Types.h:487
@ VEC_COVARIANT
Definition Types.h:485
@ VEC_COVARIANT_NORMALIZE
Definition Types.h:486
@ VEC_INVARIANT
Definition Types.h:484
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()
Definition Types.h:516
Definition Exceptions.h:13
#define OPENVDB_TARGET_BITS(SHIFT, PROMOTE)
Definition Types.h:363
CanConvertType<FromType, ToType>::value is true if a value of type ToType can be constructed from a v...
Definition Types.h:403
Conversion classes for changing the underlying type of VDB types.
Definition Types.h:320
SubT Type
Definition Types.h:320
CopyConstness<T1, T2>::Type is either const T2 or T2 with no const qualifier, depending on whether T1...
Definition Types.h:438
typename std::remove_const< ToType >::type Type
Definition Types.h:439
Helper metafunction used to determine if the first template parameter is a specialization of the clas...
Definition Types.h:192
T ElementType
Definition Types.h:288
typename T::ValueType ElementType
Definition Types.h:280
Integer wrapper, required to distinguish PointIndexGrid and PointDataGrid from Int32Grid and Int64Gri...
Definition Types.h:157
PointIndex(T i)
Explicit type conversion constructor.
Definition Types.h:165
PointIndex(IntType i=IntType(0))
Definition Types.h:162
PointIndex operator+(T x)
Needed to support the (zeroVal<PointIndex>() + val) idiom.
Definition Types.h:171
IntType_ IntType
Definition Types.h:160
T ElementType
Definition Types.h:271
typename T::ValueType ElementType
Definition Types.h:263
SwappedCombineOp(CombineOp &_op)
Definition Types.h:661
void operator()(CombineArgs< ValueType > &args)
Definition Types.h:663
CombineOp & op
Definition Types.h:671
T ElementType
Definition Types.h:314
typename T::ValueType ElementType
Definition Types.h:302
T ElementType
Definition Types.h:255
typename T::ValueType ElementType
Definition Types.h:247
Re-implementation of C++17's index_sequence and the helper alias make_index_sequence....
Definition Types.h:223
float type
Definition Types.h:343
double type
Definition Types.h:344
uint16_t type
Definition Types.h:337
int16_t type
Definition Types.h:333
uint32_t type
Definition Types.h:338
int32_t type
Definition Types.h:334
uint64_t type
Definition Types.h:339
int64_t type
Definition Types.h:335
uint8_t type
Definition Types.h:336
int8_t type
Definition Types.h:332
#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:212