OpenVDB: Types.h Source File

OpenVDB 7.1.0

Types.h
Go to the documentation of this file.
1 // Copyright Contributors to the OpenVDB Project
2 // SPDX-License-Identifier: MPL-2.0
3
4 #ifndef OPENVDB_TYPES_HAS_BEEN_INCLUDED
5 #define OPENVDB_TYPES_HAS_BEEN_INCLUDED
6
7 #include "version.h"
8 #include "Platform.h"
9 #include <OpenEXR/half.h>
10 #include <openvdb/math/Math.h>
11 #include <openvdb/math/BBox.h>
12 #include <openvdb/math/Quat.h>
13 #include <openvdb/math/Vec2.h>
14 #include <openvdb/math/Vec3.h>
15 #include <openvdb/math/Vec4.h>
16 #include <openvdb/math/Mat3.h>
17 #include <openvdb/math/Mat4.h>
18 #include <openvdb/math/Coord.h>
19 #include <cstdint>
20 #include <memory>
21 #include <type_traits>
22
23
24 namespace openvdb {
25 OPENVDB_USE_VERSION_NAMESPACE
26 namespace OPENVDB_VERSION_NAME {
27
28 // One-dimensional scalar types
29 using Index32 = uint32_t;
30 using Index64 = uint64_t;
31 using Index = Index32;
32 using Int16 = int16_t;
33 using Int32 = int32_t;
34 using Int64 = int64_t;
35 using Int = Int32;
36 using Byte = unsigned char;
37 using Real = double;
38
39 // Two-dimensional vector types
40 using Vec2R = math::Vec2<Real>;
41 using Vec2I = math::Vec2<Index32>;
42 using Vec2f = math::Vec2<float>;
43 using Vec2H = math::Vec2<half>;
44 using math::Vec2i;
45 using math::Vec2s;
46 using math::Vec2d;
47
48 // Three-dimensional vector types
49 using Vec3R = math::Vec3<Real>;
50 using Vec3I = math::Vec3<Index32>;
51 using Vec3f = math::Vec3<float>;
52 using Vec3H = math::Vec3<half>;
53 using Vec3U8 = math::Vec3<uint8_t>;
54 using Vec3U16 = math::Vec3<uint16_t>;
55 using math::Vec3i;
56 using math::Vec3s;
57 using math::Vec3d;
58
59 using math::Coord;
60 using math::CoordBBox;
61 using BBoxd = math::BBox<Vec3d>;
62
63 // Four-dimensional vector types
64 using Vec4R = math::Vec4<Real>;
65 using Vec4I = math::Vec4<Index32>;
66 using Vec4f = math::Vec4<float>;
67 using Vec4H = math::Vec4<half>;
68 using math::Vec4i;
69 using math::Vec4s;
70 using math::Vec4d;
71
72 // Three-dimensional matrix types
73 using Mat3R = math::Mat3<Real>;
74 using math::Mat3s;
75 using math::Mat3d;
76
77 // Four-dimensional matrix types
78 using Mat4R = math::Mat4<Real>;
79 using math::Mat4s;
80 using math::Mat4d;
81
82 // Quaternions
83 using QuatR = math::Quat<Real>;
84 using math::Quats;
85 using math::Quatd;
86
87 // Dummy type for a voxel with a binary mask value, e.g. the active state
88 class ValueMask {};
89
90 // Use STL shared pointers from OpenVDB 4 on.
91 template<typename T> using SharedPtr = std::shared_ptr<T>;
92 template<typename T> using WeakPtr = std::weak_ptr<T>;
93
102 template<typename T, typename U> inline SharedPtr<T>
103 ConstPtrCast(const SharedPtr<U>& ptr) { return std::const_pointer_cast<T, U>(ptr); }
104
112 template<typename T, typename U> inline SharedPtr<T>
113 DynamicPtrCast(const SharedPtr<U>& ptr) { return std::dynamic_pointer_cast<T, U>(ptr); }
114
122 template<typename T, typename U> inline SharedPtr<T>
123 StaticPtrCast(const SharedPtr<U>& ptr) { return std::static_pointer_cast<T, U>(ptr); }
124
125
127
128
132 template<typename IntType_, Index Kind>
133 struct PointIndex
134 {
135 static_assert(std::is_integral<IntType_>::value, "PointIndex requires an integer value type");
136
137 using IntType = IntType_;
138
139 PointIndex(IntType i = IntType(0)): mIndex(i) {}
140
142 template<typename T> explicit PointIndex(T i): mIndex(static_cast<IntType>(i)) {}
143
144 operator IntType() const { return mIndex; }
145
147 template<typename T>
148 PointIndex operator+(T x) { return PointIndex(mIndex + IntType(x)); }
149
150 private:
151 IntType mIndex;
152 };
153
154
155 using PointIndex32 = PointIndex<Index32, 0>;
156 using PointIndex64 = PointIndex<Index64, 0>;
157
158 using PointDataIndex32 = PointIndex<Index32, 1>;
159 using PointDataIndex64 = PointIndex<Index64, 1>;
160
161
163
164
168 template <typename T, template <typename...> class Template>
169 struct IsSpecializationOf: public std::false_type {};
170
171 template <typename... Args, template <typename...> class Template>
172 struct IsSpecializationOf<Template<Args...>, Template>: public std::true_type {};
173
174
176
177
178 template<typename T, bool = IsSpecializationOf<T, math::Vec2>::value ||
179 IsSpecializationOf<T, math::Vec3>::value ||
180 IsSpecializationOf<T, math::Vec4>::value>
181 struct VecTraits
182 {
183 static const bool IsVec = true;
184 static const int Size = T::size;
185 using ElementType = typename T::ValueType;
186 };
187
188 template<typename T>
189 struct VecTraits<T, false>
190 {
191 static const bool IsVec = false;
192 static const int Size = 1;
193 using ElementType = T;
194 };
195
196 template<typename T, bool = IsSpecializationOf<T, math::Quat>::value>
197 struct QuatTraits
198 {
199 static const bool IsQuat = true;
200 static const int Size = T::size;
201 using ElementType = typename T::ValueType;
202 };
203
204 template<typename T>
205 struct QuatTraits<T, false>
206 {
207 static const bool IsQuat = false;
208 static const int Size = 1;
209 using ElementType = T;
210 };
211
212 template<typename T, bool = IsSpecializationOf<T, math::Mat3>::value ||
213 IsSpecializationOf<T, math::Mat4>::value>
214 struct MatTraits
215 {
216 static const bool IsMat = true;
217 static const int Size = T::size;
218 using ElementType = typename T::ValueType;
219 };
220
221 template<typename T>
222 struct MatTraits<T, false>
223 {
224 static const bool IsMat = false;
225 static const int Size = 1;
226 using ElementType = T;
227 };
228
229 template<typename T, bool = VecTraits<T>::IsVec ||
230 QuatTraits<T>::IsQuat ||
231 MatTraits<T>::IsMat>
232 struct ValueTraits
233 {
234 static const bool IsVec = VecTraits<T>::IsVec;
235 static const bool IsQuat = QuatTraits<T>::IsQuat;
236 static const bool IsMat = MatTraits<T>::IsMat;
237 static const bool IsScalar = false;
238 static const int Size = T::size;
239 static const int Elements = IsMat ? Size*Size : Size;
240 using ElementType = typename T::ValueType;
241 };
242
243 template<typename T>
244 struct ValueTraits<T, false>
245 {
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;
252 using ElementType = T;
253 };
254
255
257
258
261 template<typename FromType, typename ToType>
262 struct CanConvertType { enum { value = std::is_constructible<ToType, FromType>::value }; };
263
264 // Specializations for vector types, which can be constructed from values
265 // of their own ValueTypes (or values that can be converted to their ValueTypes),
266 // but only explicitly
267 template<typename T> struct CanConvertType<T, math::Vec2<T> > { enum { value = true }; };
268 template<typename T> struct CanConvertType<T, math::Vec3<T> > { enum { value = true }; };
269 template<typename T> struct CanConvertType<T, math::Vec4<T> > { enum { value = true }; };
270 template<typename T> struct CanConvertType<math::Vec2<T>, math::Vec2<T> > { enum {value = true}; };
271 template<typename T> struct CanConvertType<math::Vec3<T>, math::Vec3<T> > { enum {value = true}; };
272 template<typename T> struct CanConvertType<math::Vec4<T>, math::Vec4<T> > { enum {value = true}; };
273 template<typename T0, typename T1>
274 struct CanConvertType<T0, math::Vec2<T1> > { enum { value = CanConvertType<T0, T1>::value }; };
275 template<typename T0, typename T1>
276 struct CanConvertType<T0, math::Vec3<T1> > { enum { value = CanConvertType<T0, T1>::value }; };
277 template<typename T0, typename T1>
278 struct CanConvertType<T0, math::Vec4<T1> > { enum { value = CanConvertType<T0, T1>::value }; };
279 template<> struct CanConvertType<PointIndex32, PointDataIndex32> { enum {value = true}; };
280 template<> struct CanConvertType<PointDataIndex32, PointIndex32> { enum {value = true}; };
281 template<typename T>
282 struct CanConvertType<T, ValueMask> { enum {value = CanConvertType<T, bool>::value}; };
283 template<typename T>
284 struct CanConvertType<ValueMask, T> { enum {value = CanConvertType<bool, T>::value}; };
285
286
288
289
297 template<typename FromType, typename ToType> struct CopyConstness {
298 using Type = typename std::remove_const<ToType>::type;
299 };
300
302 template<typename FromType, typename ToType> struct CopyConstness<const FromType, ToType> {
303 using Type = const ToType;
304 };
306
307
309
310
312
313 template<typename... Ts> struct TypeList; // forward declaration
314
315 namespace internal {
316
317 // Implementation details of @c TypeList
318
321 struct NullType {};
322
323
330 template<typename ListT, size_t Idx, typename = void> struct TSGetElementImpl;
331
335 template<typename... Ts, size_t Idx>
336 struct TSGetElementImpl<TypeList<Ts...>, Idx,
337 typename std::enable_if<(Idx < sizeof...(Ts) && sizeof...(Ts))>::type> {
338 using type = typename std::tuple_element<Idx, std::tuple<Ts...>>::type;
339 };
340
345 template<typename... Ts, size_t Idx>
346 struct TSGetElementImpl<TypeList<Ts...>, Idx,
347 typename std::enable_if<!(Idx < sizeof...(Ts) && sizeof...(Ts))>::type> {
348 using type = NullType;
349 };
350
351
364 template <typename ListT, typename T, size_t=0>
365 struct TSHasTypeImpl;
366
372 template <typename T, size_t Idx>
373 struct TSHasTypeImpl<TypeList<>, T, Idx> {
374 static constexpr bool Value = false;
375 static constexpr int64_t Index = -1;
376 };
377
385 template <typename U, typename T, typename... Ts, size_t Idx>
386 struct TSHasTypeImpl<TypeList<U, Ts...>, T, Idx> :
387 TSHasTypeImpl<TypeList<Ts...>, T, Idx+1> {};
388
394 template <typename T, typename... Ts, size_t Idx>
395 struct TSHasTypeImpl<TypeList<T, Ts...>, T, Idx>
396 {
397 static constexpr bool Value = true;
398 static constexpr int64_t Index = static_cast<int64_t>(Idx);
399 };
400
401
412 template <typename ListT, typename... Ts>
413 struct TSMakeUniqueImpl {
414 using type = ListT;
415 };
416
425 template <typename... Ts, typename U, typename... Us>
426 struct TSMakeUniqueImpl<TypeList<Ts...>, U, Us...>
427 {
428 using type = typename std::conditional<
429 TSHasTypeImpl<TypeList<Ts...>, U>::Value,
430 typename TSMakeUniqueImpl<TypeList<Ts...>, Us...>::type,
431 typename TSMakeUniqueImpl<TypeList<Ts..., U>, Us...>::type >::type;
432 };
433
434
439 template<typename ListT, typename... Ts> struct TSAppendImpl;
440
445 template<typename... Ts, typename... OtherTs>
446 struct TSAppendImpl<TypeList<Ts...>, OtherTs...> {
447 using type = TypeList<Ts..., OtherTs...>;
448 };
449
454 template<typename... Ts, typename... OtherTs>
455 struct TSAppendImpl<TypeList<Ts...>, TypeList<OtherTs...>> {
456 using type = TypeList<Ts..., OtherTs...>;
457 };
458
459
464 template<typename ListT, typename T> struct TSEraseImpl;
465
468 template<typename T>
469 struct TSEraseImpl<TypeList<>, T> { using type = TypeList<>; };
470
476 template<typename... Ts, typename T>
477 struct TSEraseImpl<TypeList<T, Ts...>, T> {
478 using type = typename TSEraseImpl<TypeList<Ts...>, T>::type;
479 };
480
487 template<typename T2, typename... Ts, typename T>
488 struct TSEraseImpl<TypeList<T2, Ts...>, T> {
489 using type = typename TSAppendImpl<TypeList<T2>,
490 typename TSEraseImpl<TypeList<Ts...>, T>::type>::type;
491 };
492
499 template<typename ListT, typename... Ts> struct TSRemoveImpl;
500
503 template<typename ListT>
504 struct TSRemoveImpl<ListT> { using type = ListT; };
505
511 template<typename ListT, typename T, typename... Ts>
512 struct TSRemoveImpl<ListT, T, Ts...> {
513 using type = typename TSRemoveImpl<typename TSEraseImpl<ListT, T>::type, Ts...>::type;
514 };
515
521 template<typename ListT, typename... Ts>
522 struct TSRemoveImpl<ListT, TypeList<Ts...>> {
523 using type = typename TSRemoveImpl<ListT, Ts...>::type;
524 };
525
530 template<typename T>
531 struct TSRemoveFirstImpl {
532 using type = TypeList<>;
533 };
534
539 template<typename T, typename... Ts>
540 struct TSRemoveFirstImpl<TypeList<T, Ts...>> {
541 using type = TypeList<Ts...>;
542 };
543
544
549 template<typename T>
550 struct TSRemoveLastImpl { using type = TypeList<>; };
551
558 template<typename T>
559 struct TSRemoveLastImpl<TypeList<T>> : TSRemoveLastImpl<T> {};
560
567 template<typename T, typename... Ts>
568 struct TSRemoveLastImpl<TypeList<T, Ts...>>
569 {
570 using type =
571 typename TypeList<T>::template
572 Append<typename TSRemoveLastImpl<TypeList<Ts...>>::type>;
573 };
574
575
588 template<typename ListT, size_t First, size_t Last, size_t Idx=0>
589 struct TSRemoveIndicesImpl;
590
595 template<size_t First, size_t Last, size_t Idx>
596 struct TSRemoveIndicesImpl<TypeList<>, First, Last, Idx> {
597 using type = TypeList<>;
598 };
599
605 template<typename T, size_t First, size_t Last, size_t Idx>
606 struct TSRemoveIndicesImpl<TypeList<T>, First, Last, Idx>
607 {
608 private:
609 static constexpr bool Remove = Idx >= First && Idx <= Last;
610 public:
611 using type = typename std::conditional<Remove, TypeList<>, TypeList<T>>::type;
612 };
613
626 template<typename T, typename... Ts, size_t First, size_t Last, size_t Idx>
627 struct TSRemoveIndicesImpl<TypeList<T, Ts...>, First, Last, Idx>
628 {
629 private:
630 using ThisList = typename TSRemoveIndicesImpl<TypeList<T>, First, Last, Idx>::type;
631 using NextList = typename TSRemoveIndicesImpl<TypeList<Ts...>, First, Last, Idx+1>::type;
632 public:
633 using type = typename ThisList::template Append<NextList>;
634 };
635
636
637 template<typename OpT> inline void TSForEachImpl(OpT) {}
638 template<typename OpT, typename T, typename... Ts>
639 inline void TSForEachImpl(OpT op) { op(T()); TSForEachImpl<OpT, Ts...>(op); }
640
641 } // namespace internal
642
644
645
651 template<typename... Ts>
652 struct TypeList
653 {
655 using Self = TypeList;
656
658 static constexpr size_t Size = sizeof...(Ts);
659
662 template<size_t N>
663 using Get = typename internal::TSGetElementImpl<Self, N>::type;
664 using Front = Get<0>;
665 using Back = Get<Size-1>;
666
679 template<typename T>
680 static constexpr bool Contains = internal::TSHasTypeImpl<Self, T>::Value;
681
695 template<typename T>
696 static constexpr int64_t Index = internal::TSHasTypeImpl<Self, T>::Index;
697
709 using Unique = typename internal::TSMakeUniqueImpl<TypeList<>, Ts...>::type;
710
724 template<typename... TypesToAppend>
725 using Append = typename internal::TSAppendImpl<Self, TypesToAppend...>::type;
726
737 template<typename... TypesToRemove>
738 using Remove = typename internal::TSRemoveImpl<Self, TypesToRemove...>::type;
739
753 using PopFront = typename internal::TSRemoveFirstImpl<Self>::type;
754
768 using PopBack = typename internal::TSRemoveLastImpl<Self>::type;
769
784 template <size_t First, size_t Last>
785 using RemoveByIndex = typename internal::TSRemoveIndicesImpl<Self, First, Last>::type;
786
807 template<typename OpT>
808 static void foreach(OpT op) { internal::TSForEachImpl<OpT, Ts...>(op); }
809 };
810
811
813
814
815 // Add new items to the *end* of this list, and update NUM_GRID_CLASSES.
816 enum GridClass {
817 GRID_UNKNOWN = 0,
818 GRID_LEVEL_SET,
819 GRID_FOG_VOLUME,
820 GRID_STAGGERED
821 };
822 enum { NUM_GRID_CLASSES = GRID_STAGGERED + 1 };
823
824 static const Real LEVEL_SET_HALF_WIDTH = 3;
825
846 enum VecType {
847 VEC_INVARIANT = 0,
848 VEC_COVARIANT,
849 VEC_COVARIANT_NORMALIZE,
850 VEC_CONTRAVARIANT_RELATIVE,
851 VEC_CONTRAVARIANT_ABSOLUTE
852 };
853 enum { NUM_VEC_TYPES = VEC_CONTRAVARIANT_ABSOLUTE + 1 };
854
855
869 enum MergePolicy {
870 MERGE_ACTIVE_STATES = 0,
871 MERGE_NODES,
872 MERGE_ACTIVE_STATES_AND_NODES
873 };
874
875
877
878
879 template<typename T> const char* typeNameAsString() { return typeid(T).name(); }
880 template<> inline const char* typeNameAsString<bool>() { return "bool"; }
881 template<> inline const char* typeNameAsString<ValueMask>() { return "mask"; }
882 template<> inline const char* typeNameAsString<half>() { return "half"; }
883 template<> inline const char* typeNameAsString<float>() { return "float"; }
884 template<> inline const char* typeNameAsString<double>() { return "double"; }
885 template<> inline const char* typeNameAsString<int8_t>() { return "int8"; }
886 template<> inline const char* typeNameAsString<uint8_t>() { return "uint8"; }
887 template<> inline const char* typeNameAsString<int16_t>() { return "int16"; }
888 template<> inline const char* typeNameAsString<uint16_t>() { return "uint16"; }
889 template<> inline const char* typeNameAsString<int32_t>() { return "int32"; }
890 template<> inline const char* typeNameAsString<uint32_t>() { return "uint32"; }
891 template<> inline const char* typeNameAsString<int64_t>() { return "int64"; }
892 template<> inline const char* typeNameAsString<Vec2i>() { return "vec2i"; }
893 template<> inline const char* typeNameAsString<Vec2s>() { return "vec2s"; }
894 template<> inline const char* typeNameAsString<Vec2d>() { return "vec2d"; }
895 template<> inline const char* typeNameAsString<Vec3U8>() { return "vec3u8"; }
896 template<> inline const char* typeNameAsString<Vec3U16>() { return "vec3u16"; }
897 template<> inline const char* typeNameAsString<Vec3i>() { return "vec3i"; }
898 template<> inline const char* typeNameAsString<Vec3f>() { return "vec3s"; }
899 template<> inline const char* typeNameAsString<Vec3d>() { return "vec3d"; }
900 template<> inline const char* typeNameAsString<Vec4i>() { return "vec4i"; }
901 template<> inline const char* typeNameAsString<Vec4f>() { return "vec4s"; }
902 template<> inline const char* typeNameAsString<Vec4d>() { return "vec4d"; }
903 template<> inline const char* typeNameAsString<std::string>() { return "string"; }
904 template<> inline const char* typeNameAsString<Mat3s>() { return "mat3s"; }
905 template<> inline const char* typeNameAsString<Mat3d>() { return "mat3d"; }
906 template<> inline const char* typeNameAsString<Mat4s>() { return "mat4s"; }
907 template<> inline const char* typeNameAsString<Mat4d>() { return "mat4d"; }
908 template<> inline const char* typeNameAsString<math::Quats>() { return "quats"; }
909 template<> inline const char* typeNameAsString<math::Quatd>() { return "quatd"; }
910 template<> inline const char* typeNameAsString<PointIndex32>() { return "ptidx32"; }
911 template<> inline const char* typeNameAsString<PointIndex64>() { return "ptidx64"; }
912 template<> inline const char* typeNameAsString<PointDataIndex32>() { return "ptdataidx32"; }
913 template<> inline const char* typeNameAsString<PointDataIndex64>() { return "ptdataidx64"; }
914
915
917
918
930 template<typename AValueType, typename BValueType = AValueType>
931 class CombineArgs
932 {
933 public:
934 using AValueT = AValueType;
935 using BValueT = BValueType;
936
937 CombineArgs()
938 : mAValPtr(nullptr)
939 , mBValPtr(nullptr)
940 , mResultValPtr(&mResultVal)
941 , mAIsActive(false)
942 , mBIsActive(false)
943 , mResultIsActive(false)
944 {
945 }
946
948 CombineArgs(const AValueType& a, const BValueType& b, AValueType& result,
949 bool aOn = false, bool bOn = false)
950 : mAValPtr(&a)
951 , mBValPtr(&b)
952 , mResultValPtr(&result)
953 , mAIsActive(aOn)
954 , mBIsActive(bOn)
955 {
956 this->updateResultActive();
957 }
958
960 CombineArgs(const AValueType& a, const BValueType& b, bool aOn = false, bool bOn = false)
961 : mAValPtr(&a)
962 , mBValPtr(&b)
963 , mResultValPtr(&mResultVal)
964 , mAIsActive(aOn)
965 , mBIsActive(bOn)
966 {
967 this->updateResultActive();
968 }
969
971 const AValueType& a() const { return *mAValPtr; }
973 const BValueType& b() const { return *mBValPtr; }
975 const AValueType& result() const { return *mResultValPtr; }
977 AValueType& result() { return *mResultValPtr; }
979
981 CombineArgs& setResult(const AValueType& val) { *mResultValPtr = val; return *this; }
982
984 CombineArgs& setARef(const AValueType& a) { mAValPtr = &a; return *this; }
986 CombineArgs& setBRef(const BValueType& b) { mBValPtr = &b; return *this; }
988 CombineArgs& setResultRef(AValueType& val) { mResultValPtr = &val; return *this; }
989
991 bool aIsActive() const { return mAIsActive; }
993 bool bIsActive() const { return mBIsActive; }
995 bool resultIsActive() const { return mResultIsActive; }
996
998 CombineArgs& setAIsActive(bool b) { mAIsActive = b; updateResultActive(); return *this; }
1000 CombineArgs& setBIsActive(bool b) { mBIsActive = b; updateResultActive(); return *this; }
1002 CombineArgs& setResultIsActive(bool b) { mResultIsActive = b; return *this; }
1003
1004 protected:
1007 void updateResultActive() { mResultIsActive = mAIsActive || mBIsActive; }
1008
1009 const AValueType* mAValPtr; // pointer to input value from A grid
1010 const BValueType* mBValPtr; // pointer to input value from B grid
1011 AValueType mResultVal; // computed output value (unused if stored externally)
1012 AValueType* mResultValPtr; // pointer to either mResultVal or an external value
1013 bool mAIsActive, mBIsActive; // active states of A and B values
1014 bool mResultIsActive; // computed active state (default: A active || B active)
1015 };
1016
1017
1021 template<typename ValueType, typename CombineOp>
1022 struct SwappedCombineOp
1023 {
1024 SwappedCombineOp(CombineOp& _op): op(_op) {}
1025
1026 void operator()(CombineArgs<ValueType>& args)
1027 {
1028 CombineArgs<ValueType> swappedArgs(args.b(), args.a(), args.result(),
1029 args.bIsActive(), args.aIsActive());
1030 op(swappedArgs);
1031 }
1032
1033 CombineOp& op;
1034 };
1035
1036
1038
1039
1042 class ShallowCopy {};
1045 class TopologyCopy {};
1047 class PartialCreate {};
1048
1049 } // namespace OPENVDB_VERSION_NAME
1050 } // namespace openvdb
1051
1052
1053 #if defined(__ICC)
1054
1055 // Use these defines to bracket a region of code that has safe static accesses.
1056 // Keep the region as small as possible.
1057 #define OPENVDB_START_THREADSAFE_STATIC_REFERENCE __pragma(warning(disable:1710))
1058 #define OPENVDB_FINISH_THREADSAFE_STATIC_REFERENCE __pragma(warning(default:1710))
1059 #define OPENVDB_START_THREADSAFE_STATIC_WRITE __pragma(warning(disable:1711))
1060 #define OPENVDB_FINISH_THREADSAFE_STATIC_WRITE __pragma(warning(default:1711))
1061 #define OPENVDB_START_THREADSAFE_STATIC_ADDRESS __pragma(warning(disable:1712))
1062 #define OPENVDB_FINISH_THREADSAFE_STATIC_ADDRESS __pragma(warning(default:1712))
1063
1064 // Use these defines to bracket a region of code that has unsafe static accesses.
1065 // Keep the region as small as possible.
1066 #define OPENVDB_START_NON_THREADSAFE_STATIC_REFERENCE __pragma(warning(disable:1710))
1067 #define OPENVDB_FINISH_NON_THREADSAFE_STATIC_REFERENCE __pragma(warning(default:1710))
1068 #define OPENVDB_START_NON_THREADSAFE_STATIC_WRITE __pragma(warning(disable:1711))
1069 #define OPENVDB_FINISH_NON_THREADSAFE_STATIC_WRITE __pragma(warning(default:1711))
1070 #define OPENVDB_START_NON_THREADSAFE_STATIC_ADDRESS __pragma(warning(disable:1712))
1071 #define OPENVDB_FINISH_NON_THREADSAFE_STATIC_ADDRESS __pragma(warning(default:1712))
1072
1073 // Simpler version for one-line cases
1074 #define OPENVDB_THREADSAFE_STATIC_REFERENCE(CODE) \
1075 __pragma(warning(disable:1710)); CODE; __pragma(warning(default:1710))
1076 #define OPENVDB_THREADSAFE_STATIC_WRITE(CODE) \
1077 __pragma(warning(disable:1711)); CODE; __pragma(warning(default:1711))
1078 #define OPENVDB_THREADSAFE_STATIC_ADDRESS(CODE) \
1079 __pragma(warning(disable:1712)); CODE; __pragma(warning(default:1712))
1080
1081 #else // GCC does not support these compiler warnings
1082
1083 #define OPENVDB_START_THREADSAFE_STATIC_REFERENCE
1084 #define OPENVDB_FINISH_THREADSAFE_STATIC_REFERENCE
1085 #define OPENVDB_START_THREADSAFE_STATIC_WRITE
1086 #define OPENVDB_FINISH_THREADSAFE_STATIC_WRITE
1087 #define OPENVDB_START_THREADSAFE_STATIC_ADDRESS
1088 #define OPENVDB_FINISH_THREADSAFE_STATIC_ADDRESS
1089
1090 #define OPENVDB_START_NON_THREADSAFE_STATIC_REFERENCE
1091 #define OPENVDB_FINISH_NON_THREADSAFE_STATIC_REFERENCE
1092 #define OPENVDB_START_NON_THREADSAFE_STATIC_WRITE
1093 #define OPENVDB_FINISH_NON_THREADSAFE_STATIC_WRITE
1094 #define OPENVDB_START_NON_THREADSAFE_STATIC_ADDRESS
1095 #define OPENVDB_FINISH_NON_THREADSAFE_STATIC_ADDRESS
1096
1097 #define OPENVDB_THREADSAFE_STATIC_REFERENCE(CODE) CODE
1098 #define OPENVDB_THREADSAFE_STATIC_WRITE(CODE) CODE
1099 #define OPENVDB_THREADSAFE_STATIC_ADDRESS(CODE) CODE
1100
1101 #endif // defined(__ICC)
1102
1103 #endif // OPENVDB_TYPES_HAS_BEEN_INCLUDED
openvdb::v7_1::math::Vec3< Real >
openvdb::v7_1::typeNameAsString< uint8_t >
const char * typeNameAsString< uint8_t >()
Definition: Types.h:886
openvdb::v7_1::typeNameAsString< int8_t >
const char * typeNameAsString< int8_t >()
Definition: Types.h:885
openvdb::v7_1::TypeList::PopBack
typename internal::TSRemoveLastImpl< Self >::type PopBack
Remove the last element of this type list. Has no effect if the type list is already empty.
Definition: Types.h:768
openvdb::v7_1::TypeList
A list of types (not necessarily unique)
Definition: Types.h:653
openvdb::v7_1::math::Vec2d
Vec2< double > Vec2d
Definition: Vec2.h:532
openvdb::v7_1::math::Mat4< Real >
openvdb::v7_1::SwappedCombineOp::SwappedCombineOp
SwappedCombineOp(CombineOp &_op)
Definition: Types.h:1024
openvdb::v7_1::PointIndex::PointIndex
PointIndex(IntType i=IntType(0))
Definition: Types.h:139
openvdb::v7_1::GRID_UNKNOWN
@ GRID_UNKNOWN
Definition: Types.h:817
openvdb::v7_1::typeNameAsString< Mat3d >
const char * typeNameAsString< Mat3d >()
Definition: Types.h:905
openvdb::v7_1::QuatTraits
Definition: Types.h:198
openvdb::v7_1::typeNameAsString< Vec3i >
const char * typeNameAsString< Vec3i >()
Definition: Types.h:897
openvdb::v7_1::CopyConstness
CopyConstness<T1, T2>::Type is either const T2 or T2 with no const qualifier, depending on whether T1...
Definition: Types.h:297
openvdb::v7_1::typeNameAsString
const char * typeNameAsString()
Definition: Types.h:879
openvdb::v7_1::CombineArgs::setBRef
CombineArgs & setBRef(const BValueType &b)
Redirect the B value to a new external source.
Definition: Types.h:986
openvdb::v7_1::VEC_COVARIANT_NORMALIZE
@ VEC_COVARIANT_NORMALIZE
Definition: Types.h:849
openvdb::v7_1::IsSpecializationOf
Helper metafunction used to determine if the first template parameter is a specialization of the clas...
Definition: Types.h:169
openvdb::v7_1::MatTraits< T, false >::ElementType
T ElementType
Definition: Types.h:226
openvdb::v7_1::typeNameAsString< Mat4d >
const char * typeNameAsString< Mat4d >()
Definition: Types.h:907
openvdb::v7_1::typeNameAsString< Vec4i >
const char * typeNameAsString< Vec4i >()
Definition: Types.h:900
openvdb::v7_1::TypeList::Append
typename internal::TSAppendImpl< Self, TypesToAppend... >::type Append
Append types, or the members of another TypeList, to this list.
Definition: Types.h:725
openvdb::v7_1::ValueTraits< T, false >::ElementType
T ElementType
Definition: Types.h:252
openvdb::v7_1::CombineArgs::setResultRef
CombineArgs & setResultRef(AValueType &val)
Redirect the result value to a new external destination.
Definition: Types.h:988
openvdb::v7_1::math::Vec4d
Vec4< double > Vec4d
Definition: Vec4.h:560
openvdb::v7_1::PointIndex::operator+
PointIndex operator+(T x)
Needed to support the (zeroVal<PointIndex>() + val) idiom.
Definition: Types.h:148
openvdb::v7_1::TopologyCopy
Tag dispatch class that distinguishes topology copy constructors from deep copy constructors.
Definition: Types.h:1045
openvdb::v7_1::Index
Index32 Index
Definition: Types.h:31
openvdb::v7_1::typeNameAsString< bool >
const char * typeNameAsString< bool >()
Definition: Types.h:880
openvdb::v7_1::typeNameAsString< half >
const char * typeNameAsString< half >()
Definition: Types.h:882
openvdb::v7_1::typeNameAsString< Vec2i >
const char * typeNameAsString< Vec2i >()
Definition: Types.h:892
openvdb::v7_1::typeNameAsString< int64_t >
const char * typeNameAsString< int64_t >()
Definition: Types.h:891
openvdb::v7_1::Int64
int64_t Int64
Definition: Types.h:34
openvdb::v7_1::StaticPtrCast
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
openvdb::v7_1::TypeList::Front
Get< 0 > Front
Definition: Types.h:664
openvdb::v7_1::QuatTraits< T, false >::ElementType
T ElementType
Definition: Types.h:209
openvdb::v7_1::TypeList::Unique
typename internal::TSMakeUniqueImpl< TypeList<>, Ts... >::type Unique
Remove any duplicate types from this TypeList by rotating the next valid type left (maintains the ord...
Definition: Types.h:709
openvdb::v7_1::typeNameAsString< Mat3s >
const char * typeNameAsString< Mat3s >()
Definition: Types.h:904
openvdb::v7_1::math::Mat3
3x3 matrix class.
Definition: Mat3.h:29
openvdb::v7_1::CombineArgs::a
const AValueType & a() const
Get the A input value.
Definition: Types.h:971
openvdb::v7_1::MERGE_ACTIVE_STATES_AND_NODES
@ MERGE_ACTIVE_STATES_AND_NODES
Definition: Types.h:872
openvdb::v7_1::CombineArgs::setBIsActive
CombineArgs & setBIsActive(bool b)
Set the active state of the B value.
Definition: Types.h:1000
openvdb::v7_1::CombineArgs::mBValPtr
const BValueType * mBValPtr
Definition: Types.h:1010
openvdb::v7_1::CombineArgs::CombineArgs
CombineArgs()
Definition: Types.h:937
openvdb::v7_1::CombineArgs::setAIsActive
CombineArgs & setAIsActive(bool b)
Set the active state of the A value.
Definition: Types.h:998
openvdb::v7_1::GridClass
GridClass
Definition: Types.h:816
openvdb::v7_1::math::Vec3i
Vec3< int32_t > Vec3i
Definition: Vec3.h:659
version.h
Library and file format version numbers.
openvdb::v7_1::VecTraits::ElementType
typename T::ValueType ElementType
Definition: Types.h:185
openvdb::v7_1::VEC_COVARIANT
@ VEC_COVARIANT
Definition: Types.h:848
openvdb::v7_1::typeNameAsString< float >
const char * typeNameAsString< float >()
Definition: Types.h:883
openvdb::v7_1::Index64
uint64_t Index64
Definition: Types.h:30
openvdb::v7_1::typeNameAsString< PointDataIndex64 >
const char * typeNameAsString< PointDataIndex64 >()
Definition: Types.h:913
openvdb::v7_1::CombineArgs::mBIsActive
bool mBIsActive
Definition: Types.h:1013
Platform.h
openvdb::v7_1::typeNameAsString< uint16_t >
const char * typeNameAsString< uint16_t >()
Definition: Types.h:888
openvdb::v7_1::CombineArgs::CombineArgs
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:960
openvdb::v7_1::CanConvertType
CanConvertType<FromType, ToType>::value is true if a value of type ToType can be constructed from a v...
Definition: Types.h:262
openvdb::v7_1::typeNameAsString< Vec3U8 >
const char * typeNameAsString< Vec3U8 >()
Definition: Types.h:895
Vec4.h
openvdb::v7_1::typeNameAsString< Vec4d >
const char * typeNameAsString< Vec4d >()
Definition: Types.h:902
openvdb::v7_1::VecTraits
Definition: Types.h:182
openvdb::v7_1::MERGE_ACTIVE_STATES
@ MERGE_ACTIVE_STATES
Definition: Types.h:870
openvdb::v7_1::Byte
unsigned char Byte
Definition: Types.h:36
openvdb::v7_1::math::CoordBBox
Axis-aligned bounding box of signed integer coordinates.
Definition: Coord.h:249
Vec2.h
openvdb::v7_1::TypeList::Back
Get< Size-1 > Back
Definition: Types.h:665
openvdb::v7_1::typeNameAsString< PointIndex32 >
const char * typeNameAsString< PointIndex32 >()
Definition: Types.h:910
openvdb::v7_1::math::Vec2i
Vec2< int32_t > Vec2i
Definition: Vec2.h:529
openvdb::v7_1::PartialCreate
Tag dispatch class that distinguishes constructors during file input.
Definition: Types.h:1047
openvdb::v7_1::TypeList::Remove
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:738
openvdb::v7_1::math::Quats
Quat< float > Quats
Definition: Quat.h:619
openvdb::v7_1::VecTraits< T, false >::ElementType
T ElementType
Definition: Types.h:193
openvdb::v7_1::CombineArgs::mAValPtr
const AValueType * mAValPtr
Definition: Types.h:1009
openvdb::v7_1::GRID_LEVEL_SET
@ GRID_LEVEL_SET
Definition: Types.h:818
Vec3.h
openvdb::v7_1::Index32
uint32_t Index32
Definition: Types.h:29
openvdb::v7_1::CombineArgs::b
const BValueType & b() const
Get the B input value.
Definition: Types.h:973
openvdb::v7_1::PointIndex::IntType
IntType_ IntType
Definition: Types.h:137
openvdb::v7_1::CombineArgs::mResultIsActive
bool mResultIsActive
Definition: Types.h:1014
openvdb::v7_1::CombineArgs::mResultValPtr
AValueType * mResultValPtr
Definition: Types.h:1012
Math.h
General-purpose arithmetic and comparison routines, most of which accept arbitrary value types (or at...
openvdb::v7_1::Int32
int32_t Int32
Definition: Types.h:33
openvdb::v7_1::math::Vec2
Definition: Vec2.h:24
openvdb::v7_1::CombineArgs::bIsActive
bool bIsActive() const
Definition: Types.h:993
openvdb::v7_1::MatTraits
Definition: Types.h:215
openvdb::v7_1::MERGE_NODES
@ MERGE_NODES
Definition: Types.h:871
openvdb::v7_1::typeNameAsString< int16_t >
const char * typeNameAsString< int16_t >()
Definition: Types.h:887
openvdb::v7_1::ValueTraits::ElementType
typename T::ValueType ElementType
Definition: Types.h:240
openvdb::v7_1::Int16
int16_t Int16
Definition: Types.h:32
openvdb::v7_1::math::Vec4s
Vec4< float > Vec4s
Definition: Vec4.h:559
openvdb::v7_1::typeNameAsString< ValueMask >
const char * typeNameAsString< ValueMask >()
Definition: Types.h:881
openvdb::v7_1::CombineArgs::setARef
CombineArgs & setARef(const AValueType &a)
Redirect the A value to a new external source.
Definition: Types.h:984
openvdb::v7_1::ValueMask
Definition: Types.h:88
openvdb::v7_1::CombineArgs::CombineArgs
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:948
openvdb::v7_1::math::Vec3s
Vec3< float > Vec3s
Definition: Vec3.h:661
openvdb::v7_1::typeNameAsString< Vec2d >
const char * typeNameAsString< Vec2d >()
Definition: Types.h:894
openvdb::v7_1::CombineArgs::aIsActive
bool aIsActive() const
Definition: Types.h:991
openvdb::v7_1::math::Mat3s
Mat3< float > Mat3s
Definition: Mat3.h:815
Mat4.h
openvdb::v7_1::math::Quat
Definition: Mat.h:169
openvdb::v7_1::math::Coord
Signed (x, y, z) 32-bit integer coordinates.
Definition: Coord.h:26
openvdb::v7_1::math::Vec3d
Vec3< double > Vec3d
Definition: Vec3.h:662
openvdb::v7_1::CombineArgs::setResultIsActive
CombineArgs & setResultIsActive(bool b)
Set the active state of the output value.
Definition: Types.h:1002
openvdb::v7_1::CombineArgs::resultIsActive
bool resultIsActive() const
Definition: Types.h:995
openvdb::v7_1::TypeList::PopFront
typename internal::TSRemoveFirstImpl< Self >::type PopFront
Remove the first element of this type list. Has no effect if the type list is already empty.
Definition: Types.h:753
openvdb::v7_1::math::Vec2s
Vec2< float > Vec2s
Definition: Vec2.h:531
openvdb::v7_1::VEC_CONTRAVARIANT_ABSOLUTE
@ VEC_CONTRAVARIANT_ABSOLUTE
Definition: Types.h:851
openvdb::v7_1::VecType
VecType
Definition: Types.h:846
openvdb::v7_1::VEC_INVARIANT
@ VEC_INVARIANT
Definition: Types.h:847
openvdb::v7_1::Int
Int32 Int
Definition: Types.h:35
OPENVDB_USE_VERSION_NAMESPACE
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:146
Mat3.h
openvdb::v7_1::CombineArgs
This struct collects both input and output arguments to "grid combiner" functors used with the tree::...
Definition: Types.h:932
Quat.h
openvdb::v7_1::math::BBox< Vec3d >
openvdb::v7_1::math::Mat4s
Mat4< float > Mat4s
Definition: Mat4.h:1333
openvdb::v7_1::MatTraits::ElementType
typename T::ValueType ElementType
Definition: Types.h:218
openvdb::v7_1::typeNameAsString< PointIndex64 >
const char * typeNameAsString< PointIndex64 >()
Definition: Types.h:911
openvdb::v7_1::TypeList::RemoveByIndex
typename internal::TSRemoveIndicesImpl< Self, First, Last >::type RemoveByIndex
Return a new list with types removed by their location within the list. If First is equal to Last,...
Definition: Types.h:785
openvdb::v7_1::MergePolicy
MergePolicy
Definition: Types.h:869
openvdb::v7_1::typeNameAsString< PointDataIndex32 >
const char * typeNameAsString< PointDataIndex32 >()
Definition: Types.h:912
openvdb::v7_1::GRID_STAGGERED
@ GRID_STAGGERED
Definition: Types.h:820
openvdb::v7_1::math::Quatd
Quat< double > Quatd
Definition: Quat.h:620
openvdb::v7_1::ConstPtrCast
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
openvdb::v7_1::CombineArgs::setResult
CombineArgs & setResult(const AValueType &val)
Set the output value.
Definition: Types.h:981
std
Definition: Coord.h:587
openvdb::v7_1::GRID_FOG_VOLUME
@ GRID_FOG_VOLUME
Definition: Types.h:819
openvdb::v7_1::PointIndex
Integer wrapper, required to distinguish PointIndexGrid and PointDataGrid from Int32Grid and Int64Gri...
Definition: Types.h:134
openvdb::v7_1::DynamicPtrCast
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
openvdb::v7_1::CopyConstness::Type
typename std::remove_const< ToType >::type Type
Definition: Types.h:298
openvdb::v7_1::typeNameAsString< Mat4s >
const char * typeNameAsString< Mat4s >()
Definition: Types.h:906
openvdb::v7_1::math::Mat4d
Mat4< double > Mat4d
Definition: Mat4.h:1334
openvdb::v7_1::math::Vec4
Definition: Mat4.h:24
openvdb::v7_1::ValueTraits
Definition: Types.h:233
openvdb::v7_1::CombineArgs::result
AValueType & result()
Definition: Types.h:977
openvdb::v7_1::typeNameAsString< Vec3d >
const char * typeNameAsString< Vec3d >()
Definition: Types.h:899
OPENVDB_VERSION_NAME
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:94
openvdb::v7_1::PointIndex::PointIndex
PointIndex(T i)
Explicit type conversion constructor.
Definition: Types.h:142
openvdb::v7_1::TypeList::Get
typename internal::TSGetElementImpl< Self, N >::type Get
Access a particular element of this type list. If the index is out of range, internal::NullType is re...
Definition: Types.h:663
openvdb::v7_1::SwappedCombineOp
Definition: Types.h:1023
openvdb::v7_1::math::Mat3d
Mat3< double > Mat3d
Definition: Mat3.h:816
openvdb::v7_1::QuatTraits::ElementType
typename T::ValueType ElementType
Definition: Types.h:201
BBox.h
openvdb::v7_1::typeNameAsString< int32_t >
const char * typeNameAsString< int32_t >()
Definition: Types.h:889
openvdb::v7_1::CombineArgs::mResultVal
AValueType mResultVal
Definition: Types.h:1011
openvdb::v7_1::typeNameAsString< Vec3f >
const char * typeNameAsString< Vec3f >()
Definition: Types.h:898
openvdb::v7_1::ShallowCopy
Tag dispatch class that distinguishes shallow copy constructors from deep copy constructors.
Definition: Types.h:1042
openvdb
Definition: Exceptions.h:13
openvdb::v7_1::VEC_CONTRAVARIANT_RELATIVE
@ VEC_CONTRAVARIANT_RELATIVE
Definition: Types.h:850
openvdb::v7_1::CombineArgs::AValueT
AValueType AValueT
Definition: Types.h:934
openvdb::v7_1::CombineArgs::BValueT
BValueType BValueT
Definition: Types.h:935
openvdb::v7_1::LEVEL_SET_HALF_WIDTH
static const Real LEVEL_SET_HALF_WIDTH
Definition: Types.h:824
openvdb::v7_1::NUM_GRID_CLASSES
@ NUM_GRID_CLASSES
Definition: Types.h:822
openvdb::v7_1::SwappedCombineOp::operator()
void operator()(CombineArgs< ValueType > &args)
Definition: Types.h:1026
openvdb::v7_1::WeakPtr
std::weak_ptr< T > WeakPtr
Definition: Types.h:92
openvdb::v7_1::typeNameAsString< double >
const char * typeNameAsString< double >()
Definition: Types.h:884
openvdb::v7_1::SharedPtr
std::shared_ptr< T > SharedPtr
Definition: Types.h:91
openvdb::v7_1::Real
double Real
Definition: Types.h:37
openvdb::v7_1::math::Vec4i
Vec4< int32_t > Vec4i
Definition: Vec4.h:557
openvdb::v7_1::CombineArgs::result
const AValueType & result() const
Get the output value.
Definition: Types.h:976
openvdb::v7_1::typeNameAsString< uint32_t >
const char * typeNameAsString< uint32_t >()
Definition: Types.h:890
openvdb::v7_1::NUM_VEC_TYPES
@ NUM_VEC_TYPES
Definition: Types.h:853
openvdb::v7_1::typeNameAsString< Vec3U16 >
const char * typeNameAsString< Vec3U16 >()
Definition: Types.h:896
openvdb::v7_1::CombineArgs::updateResultActive
void updateResultActive()
Definition: Types.h:1007
openvdb::v7_1::SwappedCombineOp::op
CombineOp & op
Definition: Types.h:1033
openvdb::v7_1::typeNameAsString< Vec4f >
const char * typeNameAsString< Vec4f >()
Definition: Types.h:901
openvdb::v7_1::typeNameAsString< Vec2s >
const char * typeNameAsString< Vec2s >()
Definition: Types.h:893
Coord.h