7 #ifndef OPENVDB_MATH_TUPLE_HAS_BEEN_INCLUDED 8 #define OPENVDB_MATH_TUPLE_HAS_BEEN_INCLUDED 15 #include <type_traits> 29 template<
int SIZE,
typename T>
36 static const int size = SIZE;
49 template <
int src_size,
typename src_valtype>
51 enum { COPY_END = (SIZE < src_size ? SIZE : src_size) };
53 for (
int i = 0; i < COPY_END; ++i) {
56 for (
int i = COPY_END; i < SIZE; ++i) {
63 template <
typename IdxT,
64 typename std::enable_if<std::is_integral<IdxT>::value,
bool>::type =
true>
72 template <
typename IdxT,
73 typename std::enable_if<std::is_integral<IdxT>::value,
bool>::type =
true>
83 T
operator[](
int i)
const {
return this->
template operator[]<
int>(i); }
84 T&
operator[](
int i) {
return this->
template operator[]<
int>(i); }
92 void toV(S *v)
const {
93 for (
int i = 0; i < SIZE; ++i) {
110 std::ostringstream buffer;
115 for (
unsigned j(0); j < SIZE; j++) {
116 if (j) buffer <<
", ";
125 void write(std::ostream& os)
const {
126 os.write(reinterpret_cast<const char*>(&mm),
sizeof(T)*SIZE);
129 is.read(reinterpret_cast<char*>(&mm),
sizeof(T)*SIZE);
134 for (
int i = 0; i < SIZE; ++i) {
142 for (
int i = 0; i < SIZE; ++i) {
150 for (
int i = 0; i < SIZE; ++i) {
158 for (
int i = 0; i < SIZE; ++i) {
173 template<
int SIZE,
typename T0,
typename T1>
177 for (
int i = 0; i < SIZE-1; ++i) {
180 return t0[SIZE-1] < t1[SIZE-1];
185 template<
int SIZE,
typename T0,
typename T1>
189 for (
int i = 0; i < SIZE-1; ++i) {
192 return t0[SIZE-1] > t1[SIZE-1];
200 template<
int SIZE,
typename T>
205 for (
int i = 0; i < SIZE; ++i) result[i] =
math::Abs(t[i]);
210 template<
int SIZE,
typename T>
214 template<
int SIZE,
typename T>
218 template<
int SIZE,
typename T>
222 template<
int SIZE,
typename T>
229 template <
int SIZE,
typename T>
230 std::ostream& operator<<(std::ostream& ostr, const Tuple<SIZE, T>& classname)
232 ostr << classname.str();
240 #endif // OPENVDB_MATH_TUPLE_HAS_BEEN_INCLUDED bool isExactlyEqual(const T0 &a, const T1 &b)
Return true if a is exactly equal to b.
Definition: Math.h:443
T operator[](IdxT i) const
Definition: Tuple.h:65
T operator[](int i) const
Definition: Tuple.h:83
auto PrintCast(const T &val) -> typename std::enable_if<!std::is_same< T, int8_t >::value &&!std::is_same< T, uint8_t >::value, const T & >::type
8-bit integer values print to std::ostreams as characters. Cast them so that they print as integers i...
Definition: Math.h:882
General-purpose arithmetic and comparison routines, most of which accept arbitrary value types (or at...
T value_type
Definition: Tuple.h:33
Tuple(Tuple< src_size, src_valtype > const &src)
Conversion constructor.
Definition: Tuple.h:50
bool operator>(const Tuple< SIZE, T0 > &t0, const Tuple< SIZE, T1 > &t1)
Definition: Tuple.h:187
T & operator[](int i)
Definition: Tuple.h:84
bool isInfinite(const Tuple< SIZE, T > &t)
Return true if an Inf is present in the tuple.
Definition: Tuple.h:215
T ValueType
Definition: Tuple.h:34
Dummy class for tag dispatch of conversion constructors.
Definition: Tuple.h:24
#define OPENVDB_ASSERT(X)
Definition: Assert.h:41
bool isZero() const
True if all elements are exactly zero.
Definition: Tuple.h:157
void read(std::istream &is)
Definition: Tuple.h:128
bool isNan(const Tuple< SIZE, T > &t)
Return true if a Nan is present in the tuple.
Definition: Tuple.h:211
bool isZero(const Tuple< SIZE, T > &t)
Return true if all elements are exactly equal to zero.
Definition: Tuple.h:223
void toV(S *v) const
Copies this tuple into an array of a compatible type.
Definition: Tuple.h:92
Tuple< SIZE, T > Abs(const Tuple< SIZE, T > &t)
Definition: Tuple.h:202
Definition: Exceptions.h:13
bool isNan() const
True if a Nan is present in this tuple.
Definition: Tuple.h:133
value_type * asV()
Exposes the internal array. Be careful when using this function.
Definition: Tuple.h:99
std::string str() const
Definition: Tuple.h:109
bool isFinite(const Tuple< SIZE, T > &t)
Return true if no Nan or Inf values are present.
Definition: Tuple.h:219
value_type const * asV() const
Exposes the internal array. Be careful when using this function.
Definition: Tuple.h:103
bool isInfinite() const
True if an Inf is present in this tuple.
Definition: Tuple.h:141
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h.in:121
void write(std::ostream &os) const
Definition: Tuple.h:125
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h.in:218
T & operator[](IdxT i)
Definition: Tuple.h:74
bool isFinite() const
True if no Nan or Inf values are present.
Definition: Tuple.h:149