HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GA_AIFStdMath.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  * NAME: GA_AIFStdMath.h ( GA Library, C++)
7  *
8  * COMMENTS: Simple implementation of AIFMath. This method simply calls
9  * the generic methods which use AIFTuple to get/set data
10  * in the attribute.
11  *
12  * Although convenient, this class may perform worse than
13  * specialized versions which know more about the internal
14  * attribute structure.
15  */
16 
17 #ifndef __GA_AIFMathDev__
18 #define __GA_AIFMathDev__
19 
20 #include "GA_API.h"
21 #include "GA_AIFMath.h"
22 
23 #include <UT/UT_VectorTypes.h>
24 
25 
27 
28 
29 /// @brief Generic implmentation of the AIFMath implementation using AIFTuple
30 ///
31 /// The GA_AIFMath class provides a pure virtual interface requiring developers
32 /// to implement all specializations of the arithmetic operations. However,
33 /// there are a lot of methods to implement. If your attribute provides an
34 /// AIFTuple numeric interface, AIFStdMath will use this interface to perform
35 /// many operations. If you sub-class from AIFStdMath instead of AIFMath you
36 /// can still specialize bottleneck operations while providing a complete
37 /// interface.
38 ///
39 /// However, <b>be warned</b>, if the AIFMath interface changes, you may
40 /// end up missing opportunities for specialization.
42 {
43 public:
45  ~GA_AIFStdMath() override;
46  /// Use the define from GA_AIFMath to declare binary methods
51  // Specializations for transform
54  GA_MATH_SPEC_TRANSFORM(UT_DMatrix4, UT_Matrix4, rowVecMult3)
55  GA_MATH_SPEC_TRANSFORM(UT_DMatrix4, UT_Matrix4, colVecMult)
56  GA_MATH_SPEC_TRANSFORM(UT_DMatrix3, UT_Matrix3, colVecMult)
57  GA_MATH_SPEC_TRANSFORM(UT_DMatrix4, UT_Matrix4, colVecMult3)
58 
59  /// @{
60  /// Operand based implementations
61  bool add(GA_AttributeOperand &dest,
64  int component = -1) const;
65  bool mul(GA_AttributeOperand &dest,
68  int component = -1) const;
69  bool sub(GA_AttributeOperand &dest,
72  int component = -1) const;
73  bool madd(GA_AttributeOperand &dest,
76  int component = -1) const;
77  bool normalize(GA_AttributeOperand &dest,
78  GA_AttributeOperand &src) const;
81  const UT_Matrix4 &xform) const;
84  const UT_DMatrix4 &xform) const;
87  const UT_Matrix3 &xform) const;
90  const UT_DMatrix3 &xform) const;
93  const UT_Matrix4 &xform) const;
96  const UT_DMatrix4 &xform) const;
99  const UT_Matrix3 &xform) const;
100  bool colVecMult(GA_AttributeOperand &dest,
101  GA_AttributeOperand &src,
102  const UT_DMatrix3 &xform) const;
103  bool rowVecMult3(GA_AttributeOperand &dest,
104  GA_AttributeOperand &src,
105  const UT_Matrix4 &xform) const;
106  bool rowVecMult3(GA_AttributeOperand &dest,
107  GA_AttributeOperand &src,
108  const UT_DMatrix4 &xform) const;
109  bool colVecMult3(GA_AttributeOperand &dest,
110  GA_AttributeOperand &src,
111  const UT_Matrix4 &xform) const;
112  bool colVecMult3(GA_AttributeOperand &dest,
113  GA_AttributeOperand &src,
114  const UT_DMatrix4 &xform) const;
115  template <typename MTYPE>
116  bool ptransform(GA_AttributeOperand &dest,
117  GA_AttributeOperand &src,
118  const MTYPE &xform) const
119  { return rowVecMult(dest, src, xform); }
120  template <typename MTYPE>
123  const MTYPE &xform) const
124  { return rowVecMult3(dest, src, xform); }
125  template <typename MTYPE>
128  const MTYPE &xform) const
129  { return colVecMult3(dest, src, xform); }
130 };
131 
132 #endif
UT_Vector3T< T > rowVecMult(const UT_Vector3T< T > &v, const UT_Matrix3T< S > &m)
Definition: UT_Matrix3.h:1516
Attribute Interface class to perform numeric operations on attributes.
Definition: GA_AIFMath.h:88
bool vtransform(GA_AttributeOperand &dest, GA_AttributeOperand &src, const MTYPE &xform) const
Use the define from GA_AIFMath to declare binary methods.
GLboolean GLboolean GLboolean GLboolean a
Definition: glcorearb.h:1222
#define GA_API
Definition: GA_API.h:14
bool ntransform(GA_AttributeOperand &dest, GA_AttributeOperand &src, const MTYPE &xform) const
Use the define from GA_AIFMath to declare binary methods.
ImageBuf OIIO_API sub(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
OIIO_FORCEINLINE OIIO_HOSTDEVICE float madd(float a, float b, float c)
Fused multiply and add: (a*b + c)
Definition: fmath.h:413
#define GA_MATH_SPEC_BINARY(NAME)
Convenience define for sub-class implementations.
Definition: GA_AIFMath.h:121
GLboolean GLboolean GLboolean b
Definition: glcorearb.h:1222
UT_Vector3T< T > colVecMult3(const UT_Matrix4T< S > &m, const UT_Vector3T< T > &v)
Definition: UT_Matrix4.h:1948
UT_Vector3T< T > rowVecMult3(const UT_Vector3T< T > &v, const UT_Matrix4T< S > &m)
Definition: UT_Matrix4.h:1926
Generic implmentation of the AIFMath implementation using AIFTuple.
Definition: GA_AIFStdMath.h:41
UT_Vector3T< T > colVecMult(const UT_Matrix3T< S > &m, const UT_Vector3T< T > &v)
Definition: UT_Matrix3.h:1534
ImageBuf OIIO_API add(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
constexpr T normalize(UT_FixedVector< T, D > &a) noexcept
#define GA_MATH_SPEC_TRANSFORM(DTYPE, FTYPE, NAME)
Definition: GA_AIFMath.h:155
ImageBuf OIIO_API mul(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
GLenum src
Definition: glcorearb.h:1793