34 #ifndef OPENVDB_MATH_TUPLE_HAS_BEEN_INCLUDED 35 #define OPENVDB_MATH_TUPLE_HAS_BEEN_INCLUDED 52 template<
int SIZE,
typename T>
58 static const int size = SIZE;
67 for (
int i = 0; i < SIZE; ++i) {
77 for (
int i = 0; i < SIZE; ++i) {
90 template <
int src_size,
typename src_valtype>
92 enum { COPY_END = (SIZE < src_size ? SIZE : src_size) };
94 for (
int i = 0; i < COPY_END; ++i) {
97 for (
int i = COPY_END; i < SIZE; ++i) {
120 template <
typename S>
123 for (
int i = 0; i < SIZE; ++i) {
133 value_type
const *
asV()
const {
141 std::ostringstream buffer;
146 for (
unsigned j(0); j < SIZE; j++) {
147 if (j) buffer <<
", ";
156 void write(std::ostream& os)
const {
157 os.write(reinterpret_cast<const char*>(&mm),
sizeof(T)*SIZE);
160 is.read(reinterpret_cast<char*>(&mm),
sizeof(T)*SIZE);
172 template<
int SIZE,
typename T0,
typename T1>
176 for (
int i = 0; i < SIZE-1; ++i) {
179 return t0[SIZE-1] < t1[SIZE-1];
184 template<
int SIZE,
typename T0,
typename T1>
188 for (
int i = 0; i < SIZE-1; ++i) {
191 return t0[SIZE-1] > t1[SIZE-1];
199 template<
int SIZE,
typename T>
204 for (
int i = 0; i < SIZE; ++i) result[i] =
math::Abs(t[i]);
213 template <
int SIZE,
typename T>
214 std::ostream& operator<<(std::ostream& ostr, const Tuple<SIZE, T>& classname)
216 ostr << classname.
str();
224 #endif // OPENVDB_MATH_TUPLE_HAS_BEEN_INCLUDED Tuple(Tuple< src_size, src_valtype > const &src)
Conversion constructor.
Definition: Tuple.h:91
General-purpose arithmetic and comparison routines, most of which accept arbitrary value types (or at...
T ValueType
Definition: Tuple.h:56
Tuple()
Default ctor. Does nothing.
Definition: Tuple.h:63
T mm[SIZE]
Definition: Tuple.h:164
std::string str() const
Definition: Tuple.h:140
value_type * asV()
Exposes the internal array. Be careful when using this function.
Definition: Tuple.h:129
T value_type
Definition: Tuple.h:55
Tuple & operator=(Tuple const &src)
Assignment operator.
Definition: Tuple.h:75
#define OPENVDB_VERSION_NAME
Definition: version.h:43
Dummy class for tag dispatch of conversion constructors.
Definition: Tuple.h:47
Tuple(Tuple const &src)
Copy constructor. Used when the class signature matches exactly.
Definition: Tuple.h:66
value_type const * asV() const
Exposes the internal array. Be careful when using this function.
Definition: Tuple.h:133
Definition: Exceptions.h:39
T operator[](int i) const
Definition: Tuple.h:102
Tuple< SIZE, T > Abs(const Tuple< SIZE, T > &t)
Definition: Tuple.h:201
bool isExactlyEqual(const T0 &a, const T1 &b)
Return true if a is exactly equal to b.
Definition: Math.h:407
T & operator[](int i)
Definition: Tuple.h:110
void toV(S *v) const
Copies this tuple into an array of a compatible type.
Definition: Tuple.h:122
void read(std::istream &is)
Definition: Tuple.h:159
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:71
bool operator>(const Tuple< SIZE, T0 > &t0, const Tuple< SIZE, T1 > &t1)
Definition: Tuple.h:186
void write(std::ostream &os) const
Definition: Tuple.h:156