7#ifndef OPENVDB_MATH_TUPLE_HAS_BEEN_INCLUDED
8#define OPENVDB_MATH_TUPLE_HAS_BEEN_INCLUDED
29template<
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 for (
int i = 0; i <
size; ++i) {
mm[i] = val; }
68 template <
typename IdxT,
69 typename std::enable_if<std::is_integral<IdxT>::value,
bool>::type =
true>
77 template <
typename IdxT,
78 typename std::enable_if<std::is_integral<IdxT>::value,
bool>::type =
true>
88 T
operator[](
int i)
const {
return this->
template operator[]<
int>(i); }
89 T&
operator[](
int i) {
return this->
template operator[]<
int>(i); }
97 void toV(S *v)
const {
98 for (
int i = 0; i < SIZE; ++i) {
116 Tuple r;
for (
int i = 0; i < SIZE; ++i) r[i] =
mm[i] + in[i];
return r;
119 Tuple r;
for (
int i = 0; i < SIZE; ++i) r[i] =
mm[i] - in[i];
return r;
122 Tuple r;
for (
int i = 0; i < SIZE; ++i) r[i] =
mm[i] * in[i];
return r;
125 Tuple r;
for (
int i = 0; i < SIZE; ++i) r[i] =
mm[i] / in[i];
return r;
128 Tuple r;
for (
int i = 0; i < SIZE; ++i) r[i] =
mm[i] & in[i];
return r;
131 Tuple r;
for (
int i = 0; i < SIZE; ++i) r[i] =
mm[i] | in[i];
return r;
142 Tuple<SIZE, bool> r;
for (
int i = 0; i < SIZE; ++i) r[i] = mm[i] >= in[i];
return r;
145 Tuple<SIZE, bool> r;
for (
int i = 0; i < SIZE; ++i) r[i] = mm[i] <= in[i];
return r;
148 Tuple<SIZE, bool> r;
for (
int i = 0; i < SIZE; ++i) r[i] = mm[i] > in[i];
return r;
151 Tuple<SIZE, bool> r;
for (
int i = 0; i < SIZE; ++i) r[i] = mm[i] < in[i];
return r;
164 std::ostringstream buffer;
169 for (
unsigned j(0); j < SIZE; j++) {
170 if (j) buffer <<
", ";
179 void write(std::ostream& os)
const {
180 os.write(
reinterpret_cast<const char*
>(&
mm),
sizeof(T)*SIZE);
183 is.read(
reinterpret_cast<char*
>(&
mm),
sizeof(T)*SIZE);
188 for (
int i = 0; i < SIZE; ++i) {
196 for (
int i = 0; i < SIZE; ++i) {
204 for (
int i = 0; i < SIZE; ++i) {
212 for (
int i = 0; i < SIZE; ++i) {
239template<
int SIZE,
typename T>
244 for (
int i = 0; i < SIZE; ++i) result[i] =
math::Abs(t[i]);
249template<
int SIZE,
typename T>
253template<
int SIZE,
typename T>
257template<
int SIZE,
typename T>
261template<
int SIZE,
typename T>
268template <
int SIZE,
typename T>
271 ostr << classname.
str();
#define OPENVDB_ASSERT(X)
Definition Assert.h:41
General-purpose arithmetic and comparison routines, most of which accept arbitrary value types (or at...
Tuple operator-(Tuple in) const
Copies this tuple into an array of a compatible type.
Definition Tuple.h:118
Tuple operator|(Tuple in) const
Copies this tuple into an array of a compatible type.
Definition Tuple.h:130
T operator[](IdxT i) const
Definition Tuple.h:70
Tuple & operator+=(Tuple in)
Copies this tuple into an array of a compatible type.
Definition Tuple.h:134
bool isZero() const
True if all elements are exactly zero.
Definition Tuple.h:211
Tuple operator*(Tuple in) const
Copies this tuple into an array of a compatible type.
Definition Tuple.h:121
void write(std::ostream &os) const
Copies this tuple into an array of a compatible type.
Definition Tuple.h:179
Tuple< SIZE, bool > operator==(Tuple in) const
Copies this tuple into an array of a compatible type.
Definition Tuple.h:153
Tuple(const T val)
Constructor that fills this tuple with a value.
Definition Tuple.h:62
bool isInfinite() const
True if an Inf is present in this tuple.
Definition Tuple.h:195
Tuple operator+(Tuple in) const
Copies this tuple into an array of a compatible type.
Definition Tuple.h:115
T & operator[](IdxT i)
Definition Tuple.h:79
Tuple & operator/=(Tuple in)
Copies this tuple into an array of a compatible type.
Definition Tuple.h:137
Tuple & operator-=(Tuple in)
Copies this tuple into an array of a compatible type.
Definition Tuple.h:135
Tuple< SIZE, bool > operator!=(Tuple in) const
Copies this tuple into an array of a compatible type.
Definition Tuple.h:156
value_type const * asV() const
Exposes the internal array. Be careful when using this function.
Definition Tuple.h:108
Tuple< SIZE, bool > operator>(Tuple in) const
Copies this tuple into an array of a compatible type.
Definition Tuple.h:147
Tuple< SIZE, bool > operator>=(Tuple in) const
Copies this tuple into an array of a compatible type.
Definition Tuple.h:141
T mm[SIZE]
Copies this tuple into an array of a compatible type.
Definition Tuple.h:219
static const int size
Definition Tuple.h:36
Tuple operator/(Tuple in) const
Copies this tuple into an array of a compatible type.
Definition Tuple.h:124
Tuple & operator|=(Tuple in)
Copies this tuple into an array of a compatible type.
Definition Tuple.h:139
Tuple & operator&=(Tuple in)
Copies this tuple into an array of a compatible type.
Definition Tuple.h:138
value_type * asV()
Exposes the internal array. Be careful when using this function.
Definition Tuple.h:104
Tuple & operator*=(Tuple in)
Copies this tuple into an array of a compatible type.
Definition Tuple.h:136
T operator[](int i) const
Definition Tuple.h:88
Tuple(Tuple< src_size, src_valtype > const &src)
Conversion constructor.
Definition Tuple.h:50
void toV(S *v) const
Copies this tuple into an array of a compatible type.
Definition Tuple.h:97
T & operator[](int i)
Definition Tuple.h:89
Tuple operator&(Tuple in) const
Copies this tuple into an array of a compatible type.
Definition Tuple.h:127
std::string str() const
Definition Tuple.h:163
T ValueType
Definition Tuple.h:34
bool isNan() const
True if a Nan is present in this tuple.
Definition Tuple.h:187
T value_type
Definition Tuple.h:33
void read(std::istream &is)
Copies this tuple into an array of a compatible type.
Definition Tuple.h:182
bool isFinite() const
True if no Nan or Inf values are present.
Definition Tuple.h:203
Tuple< SIZE, bool > operator&&(const Tuple< SIZE, bool > a, const Tuple< SIZE, bool > b)
Definition Tuple.h:225
bool isInfinite(const float x)
Return true if x is an infinity value (either positive infinity or negative infinity).
Definition Math.h:399
std::ostream & operator<<(std::ostream &os, const BBox< Vec3T > &b)
Definition BBox.h:413
bool isFinite(const float x)
Return true if x is finite.
Definition Math.h:385
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:950
Tuple< SIZE, bool > operator||(const Tuple< SIZE, bool > a, const Tuple< SIZE, bool > b)
Definition Tuple.h:231
bool isNan(const float x)
Return true if x is a NaN (Not-A-Number) value.
Definition Math.h:413
bool operator<(const Vec2< T1 > &a, const Vec2< T2 > &b)=delete
Coord Abs(const Coord &xyz)
Definition Coord.h:518
bool isZero(const Type &x)
Return true if x is exactly equal to zero.
Definition Math.h:350
Definition Exceptions.h:13
Dummy class for tag dispatch of conversion constructors.
Definition Tuple.h:24
#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:284