HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GA_PwHandle.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_PwHandle.h (GA Library, C++)
7  *
8  * COMMENTS: Wrapper to be able to read P and Pw with a single handle.
9  * It is intentionally named inconsistently with GA_RWHandleXX
10  * and GA_ROHandleXX, so that it doesn't show up among them.
11  */
12 
13 #pragma once
14 
15 #ifndef __GA_PwHandle__
16 #define __GA_PwHandle__
17 
18 #include "GA_API.h"
19 #include "GA_Handle.h"
20 #include "GA_Types.h"
21 #include <UT/UT_Vector4.h>
22 #include <SYS/SYS_TypeTraits.h>
23 
24 template<bool isconst=true>
26 {
27 public:
31 
33  : myP()
34  , myW()
35  {}
37  : myP(gdp.getP())
38  , myW(gdp.getPwAttribute())
39  {}
40  GA_PwHandle(const HandleV3 &p, const HandleF &w)
41  : myP(p)
42  , myW(w)
43  {}
44  UT_Vector4 get(GA_Offset ptoff, int component=0) const
45  {
46  UT_ASSERT_P(component == 0);
47  return UT_Vector4(myP.get(ptoff), myW.isValid() ? myW.get(ptoff) : 1.0f);
48  }
49  const GA_Attribute *getAttribute() const
50  {
51  return myP.getAttribute();
52  }
53  bool isValid() const
54  {
55  return myP.isValid();
56  }
57 protected:
60 };
61 
63 
64 class GA_PwHandleRW : public GA_PwHandle<false>
65 {
66 public:
68 protected:
69  using Base::myP;
70  using Base::myW;
71 public:
72  using Base::Detail;
73  using Base::HandleV3;
74  using Base::HandleF;
75 
77  : Base()
78  {}
80  : Base(gdp)
81  {}
82  GA_PwHandleRW(const HandleV3 &p, const HandleF &w)
83  : Base(p, w)
84  {}
85  void set(GA_Offset ptoff, const UT_Vector4 &v) const
86  {
87  myP.set(ptoff, UT_Vector3(v));
88  if (myW.isValid())
89  myW.set(ptoff, v.w());
90  }
91  void set(GA_Offset ptoff, int component, const UT_Vector4 &v) const
92  {
93  UT_ASSERT_P(component == 0);
94  set(ptoff, v);
95  }
96 };
97 
98 #endif
GA_PwHandle< false > Base
Definition: GA_PwHandle.h:67
Definition of a geometry attribute.
Definition: GA_Attribute.h:198
const GLdouble * v
Definition: glcorearb.h:837
GA_PwHandleRW(Detail &gdp)
Definition: GA_PwHandle.h:79
SYS_SelectType< GA_RWHandleV3, GA_ROHandleV3, isconst >::type HandleV3
Definition: GA_PwHandle.h:29
HandleV3 myP
Definition: GA_PwHandle.h:58
UT_Vector3T< float > UT_Vector3
void set(GA_Offset ptoff, const UT_Vector4 &v) const
Definition: GA_PwHandle.h:85
SYS_SelectType< GA_RWHandleF, GA_ROHandleF, isconst >::type HandleF
Definition: GA_PwHandle.h:30
SYS_SelectType< GA_Detail, const GA_Detail, isconst >::type Detail
Definition: GA_PwHandle.h:28
GA_Size GA_Offset
Definition: GA_Types.h:641
void set(GA_Offset ptoff, int component, const UT_Vector4 &v) const
Definition: GA_PwHandle.h:91
UT_Vector4T< float > UT_Vector4
SYS_SelectType< GA_RWHandleF, GA_ROHandleF, isconst >::type HandleF
Definition: GA_PwHandle.h:30
#define UT_ASSERT_P(ZZ)
Definition: UT_Assert.h:155
SYS_SelectType< GA_Detail, const GA_Detail, isconst >::type Detail
Definition: GA_PwHandle.h:28
SYS_SelectType< GA_RWHandleV3, GA_ROHandleV3, isconst >::type HandleV3
Definition: GA_PwHandle.h:29
bool isValid() const
Definition: GA_PwHandle.h:53
GA_PwHandle(Detail &gdp)
Definition: GA_PwHandle.h:36
GA_PwHandleRW(const HandleV3 &p, const HandleF &w)
Definition: GA_PwHandle.h:82
constexpr SYS_FORCE_INLINE T & w() noexcept
Definition: UT_Vector4.h:497
GA_PwHandle(const HandleV3 &p, const HandleF &w)
Definition: GA_PwHandle.h:40
GA_PwHandle< true > GA_PwHandleRO
Definition: GA_PwHandle.h:62
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:857
HandleF myW
Definition: GA_PwHandle.h:59
const GA_Attribute * getAttribute() const
Definition: GA_PwHandle.h:49