HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HOM_Vector4.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * COMMENTS:
7  */
8 
9 #ifndef __HOM_Vector4_h__
10 #define __HOM_Vector4_h__
11 
12 #include "HOM_API.h"
13 #include "HOM_Defines.h"
14 #include "HOM_Errors.h"
15 #include "HOM_Module.h"
16 #include "HOM_Vector3.h"
17 #include "HOM_Matrix4.h"
18 #include "HOM_PtrOrNull.h"
19 #include <UT/UT_Vector4.h>
20 #include <vector>
21 #include <stdexcept>
22 class HOM_Vector4;
23 
25 
27 {
28 public:
30  : myVector4(0.0, 0.0, 0.0, 0.0)
31  { HOM_CONSTRUCT_OBJECT(this) }
32 
33  HOM_Vector4(double x, double y, double z, double w)
34  : myVector4(x, y, z, w)
35  { HOM_CONSTRUCT_OBJECT(this) }
36 
38  HOM_Vector4(const HOM_Vector4 &vector4)
39  : myVector4(vector4.myVector4)
40  { HOM_CONSTRUCT_OBJECT(this) }
41 
43  HOM_Vector4(const UT_Vector4D &vector4)
44  : myVector4(vector4)
45  { HOM_CONSTRUCT_OBJECT(this) }
46 
48  HOM_Vector4(const UT_Vector4F &vector4)
49  : myVector4(vector4)
50  { HOM_CONSTRUCT_OBJECT(this) }
51 
52  HOM_Vector4(const std::vector<double> &sequence)
53  {
55  setTo(sequence);
56  }
57 
58  HOM_Vector4(HOM_Vector3 &vector3);
59 
61  { HOM_DESTRUCT_OBJECT(this) }
62 
64  { return vector4.myPointer && myVector4 == vector4.myPointer->myVector4; }
65 
67  { return !operator==(vector4); }
68 
69  bool isAlmostEqual(HOM_Vector4 &vector4, double tolerance=0.00001);
70 
71  // This method is deprecated.
72  bool almostEqual(HOM_Vector4 &vector4, double tolerance=0.00001)
73  { return isAlmostEqual(vector4, tolerance); }
74 
75  int __hash__();
78 
79  double __getitem__(int index);
80  void __setitem__(int index, double value);
81  int __len__()
82  { return 4; }
83 
84  // operator[] exists only to make this class easier to use from C++,
85  // and isn't wrapped by swig.
86  SWIGOUT(%ignore operator[];)
87  double &operator[](int index);
88 
89  void setTo(const std::vector<double> &sequence);
90 
91  SWIGOUT(%ignore operator=;)
92  HOM_Vector4 &operator=(const HOM_Vector4& vector4)
93  {
94  myVector4 = vector4.myVector4;
95  return *this;
96  }
97 
99  { return HOM_Vector4(myVector4 + vector4.myVector4); }
101  { return HOM_Vector4(myVector4 - vector4.myVector4); }
102  HOM_Vector4 __mul__(double scalar)
103  { return HOM_Vector4(myVector4 * scalar); }
104  HOM_Vector4 __rmul__(double scalar)
105  { return HOM_Vector4(myVector4 * scalar); }
106  HOM_Vector4 __mul__(HOM_Matrix4 &matrix4);
107  HOM_Vector4 __div__(double scalar)
108  { return HOM_Vector4(myVector4 / scalar); }
109  HOM_Vector4 __truediv__(double scalar)
110  { return HOM_Vector4(myVector4 / scalar); }
111 
113  double length()
114  { return myVector4.length(); }
115  double lengthSquared()
116  { return myVector4.length2(); }
117 
118  double dot(HOM_Vector4 &vector4)
119  { return myVector4.dot(vector4.myVector4); }
120 
121  HOM_Vector4 ocio_transform(const std::string &src_space,
122  const std::string &dest_space) const;
123 
124  double x()
125  { return myVector4.x(); }
126  double y()
127  { return myVector4.y(); }
128  double z()
129  { return myVector4.z(); }
130  double w()
131  { return myVector4.w(); }
132 
134  { return &myVector4; }
135 
138 
139  // Pickle Support
140  //
141  // By design, pickle doesn't not call __init__() when unpickling. This is a
142  // problem for SWIG though because it requires this in order for the object
143  // to be properly wrapped to the C++ methods. So we need to wrap the
144  // __setstate__() implementation around something that calls __init__()
145  // first. For symmetry, we also wrap __getstate__() as well. So in the
146  // Python implementation, we define __getstate__()/__setstate__() that call
147  // the internal _getstate()/_setstate() C++ methods.
148  std::vector<double> _getstate();
149  void _setstate(std::vector<double>);
150  // NOTE: Be careful with the %pythoncode below which must be indented using
151  // spaces!
152 #ifdef SWIG
153 %extend {
154 %pythoncode {
155  def __getstate__(self):
156  return self._getstate()
157  def __setstate__(self, state):
158  try:
159  self.this
160  except:
161  self.__init__()
162  self._setstate(state)
163 }
164 };
165 #endif
166 };
167 
168 #endif
double x()
Definition: HOM_Vector4.h:124
#define HOM_DESTRUCT_OBJECT(pointer)
Definition: HOM_Module.h:1303
constexpr SYS_FORCE_INLINE T & y() noexcept
Definition: UT_Vector4.h:493
double dot(HOM_Vector4 &vector4)
Definition: HOM_Vector4.h:118
GLsizei const GLchar *const * string
Definition: glcorearb.h:814
GLdouble GLdouble GLdouble z
Definition: glcorearb.h:848
#define SWIGOUT(x)
Definition: HOM_Defines.h:24
double lengthSquared()
Definition: HOM_Vector4.h:115
string __repr__(VtArray< T > const &self)
Definition: wrapArray.h:349
**But if you need a or simply need to know when the task has note that the like this
Definition: thread.h:617
GLint y
Definition: glcorearb.h:103
HOM_Vector4 __truediv__(double scalar)
Definition: HOM_Vector4.h:109
int __hash__()
double __getitem__(int index)
constexpr SYS_FORCE_INLINE T & x() noexcept
Definition: UT_Vector4.h:491
HOM_Vector4 __div__(double scalar)
Definition: HOM_Vector4.h:107
HOM_Vector4(const std::vector< double > &sequence)
Definition: HOM_Vector4.h:52
HOM_Vector4 __mul__(double scalar)
Definition: HOM_Vector4.h:102
double length()
Definition: HOM_Vector4.h:113
HOM_Vector4 __rmul__(double scalar)
Definition: HOM_Vector4.h:104
HOM_Vector4(const UT_Vector4F &vector4)
Definition: HOM_Vector4.h:48
#define HOM_API
Definition: HOM_API.h:13
void ignore(T const &) VULKAN_HPP_NOEXCEPT
Definition: vulkan.hpp:6508
constexpr SYS_FORCE_INLINE T & z() noexcept
Definition: UT_Vector4.h:495
#define HOM_CONSTRUCT_OBJECT(pointer)
Definition: HOM_Module.h:1302
double y()
Definition: HOM_Vector4.h:126
Definition: Types.h:327
constexpr SYS_FORCE_INLINE T dot(const UT_Vector4T &b) const noexcept
Definition: UT_Vector4.h:512
void _setstate(std::vector< double >)
GLint GLenum GLboolean normalized
Definition: glcorearb.h:872
HOM_Vector4(double x, double y, double z, double w)
Definition: HOM_Vector4.h:33
GLint GLenum GLint x
Definition: glcorearb.h:409
void __setitem__(int index, double value)
bool isAlmostEqual(HOM_Vector4 &vector4, double tolerance=0.00001)
bool operator==(HOM_PtrOrNull< HOM_Vector4 > vector4)
Definition: HOM_Vector4.h:63
std::vector< double > _getstate()
UT_Vector4D myVector4
Definition: HOM_Vector4.h:137
double z()
Definition: HOM_Vector4.h:128
OIIO_UTIL_API bool rename(string_view from, string_view to, std::string &err)
bool almostEqual(HOM_Vector4 &vector4, double tolerance=0.00001)
Definition: HOM_Vector4.h:72
GLuint index
Definition: glcorearb.h:786
void * _asVoidPointer()
Definition: HOM_Vector4.h:133
void setTo(const std::vector< double > &sequence)
constexpr SYS_FORCE_INLINE T & w() noexcept
Definition: UT_Vector4.h:497
constexpr SYS_FORCE_INLINE T length2() const noexcept
Definition: UT_Vector4.h:284
HOM_Vector4(const HOM_Vector4 &vector4)
Definition: HOM_Vector4.h:38
HOM_Vector4 ocio_transform(const std::string &src_space, const std::string &dest_space) const
std::string __str__()
HOM_Vector4 __add__(HOM_Vector4 &vector4)
Definition: HOM_Vector4.h:98
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:857
double w()
Definition: HOM_Vector4.h:130
Definition: core.h:1131
HOM_Vector4(const UT_Vector4D &vector4)
Definition: HOM_Vector4.h:43
int __len__()
Definition: HOM_Vector4.h:81
bool operator==(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Equality operator, does exact floating point comparisons.
Definition: Mat3.h:542
constexpr SYS_FORCE_INLINE T length() const noexcept
Definition: UT_Vector4.h:289
HOM_Vector4 __sub__(HOM_Vector4 &vector4)
Definition: HOM_Vector4.h:100
bool operator!=(HOM_PtrOrNull< HOM_Vector4 > vector4)
Definition: HOM_Vector4.h:66