HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GEO_AttributeIndexPairs.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: GEO_AttributeIndexPairs.h ( GEO Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __GEO_AttributeIndexPairs__
12 #define __GEO_AttributeIndexPairs__
13 
14 #include "GEO_API.h"
15 #include "GEO_Detail.h"
16 #include <GA/GA_Types.h>
17 #include <UT/UT_StringHolder.h>
18 #include <SYS/SYS_Types.h>
19 
21 {
22 public:
24  : myAttrib(0), myIndexPair(0)
25  {
26  }
27 
30  {
31  reset(gdp, type);
32  }
33 
34  void reset(const GEO_Detail *gdp,
36 
37  bool isValid() const { return myAttrib && myIndexPair; }
38  int getNumPaths() const;
39  const char *getPath(int i) const
40  {
41  if (!isValid())
42  return nullptr;
43  return getPathImpl(i).c_str();
44  }
45  UT_StringRef getPathRef(int i) const
46  {
47  if (!isValid())
48  return nullptr;
49  return getPathImpl(i);
50  }
51 
52  int getIndex(const char *path) const;
53  void clear(void);
54 
55 private:
56  UT_StringRef getPathImpl(int i) const;
57 protected:
60 };
61 
63 {
64 public:
66  GEO_Detail *gdp,
69  {
70  }
71  void setPath(int i, const char *path) const;
72 };
73 
74 /// @brief This class provides a convenient abstraction of the contents of an
75 /// index pair attribute for a single element.
76 ///
77 /// It is important to note that this class does not perform any sort of bounds
78 /// checking.
79 ///
80 /// @warning This is being used internally by Side Effects to simplify forward
81 /// compatibility issues. The lifetime of this class is not well known and
82 /// code should not rely on any methods herein.
84 {
85 public:
86  /// No Default constructor. An instance must always be bound.
87  /// @pre ref.isValid() == true
89  const GA_RWAttributeRef &ref) { bind(elem_off, ref); }
91  const GA_AIFIndexPair *aifindexpair)
92  { bind(elem_off, attrib, aifindexpair); }
93 
94  /// Destructor
95  ~GEO_AttributeIndexPairs() { /* NOP */ }
96 
97  /// Bind a element
98  /// @pre ref.isValid() == true
99  /// @{
100  void bind(GA_Offset elem_off, GA_Attribute *attrib,
101  const GA_AIFIndexPair *aifindexpair)
102  {
103  myOffset = elem_off;
104  myAttribute = attrib;
105  myIndexPair = aifindexpair;
106  }
107  void bind(GA_Offset elem_off, const GA_RWAttributeRef &ref);
108  /// @}
109 
110  int32 getEntryIndex(int n) const;
111  fpreal32 getEntryValue(int n, int component=0) const;
112  void getEntry(int n, int32 &index, fpreal32 &value) const
113  {
114  index = getEntryIndex(n);
115  value = getEntryValue(n);
116  }
117 
118  void setEntryIndex(int n, int32 index);
119  void setEntryValue(int n, fpreal32 value, int component=0);
121  {
122  setEntryIndex(n, index);
123  setEntryValue(n, value);
124  }
125 
126  void offsetEntryValue(int n, fpreal32 o, int component=0)
127  { setEntryValue(n, getEntryValue(n, component) + o, component); }
128  void scaleEntryValue(int n, fpreal32 s, int component=0)
129  { setEntryValue(n, getEntryValue(n, component) * s, component); }
130 
131 private:
132  /// Copy constructor - not available (copying not permitted)
134 
135  /// Assignment operator - not available (copying not permitted)
137 
138  GA_Attribute *myAttribute;
139  const GA_AIFIndexPair *myIndexPair;
140  GA_Offset myOffset;
141 };
142 
143 /// @brief This class provides a convenient abstraction of the contents of an
144 /// index pair attribute for a single const element.
145 ///
146 /// @warning This is being used internally by Side Effects to simplify forward
147 /// compatibility issues. The lifetime of this class is not well known and
148 /// code should not rely on any methods herein.
150 {
151 public:
152  /// No Default constructor. An instance must always be bound.
153  /// @pre ref.isValid() == true
155  const GA_ROAttributeRef &ref) { bind(elem_off, ref); }
157  GA_Offset elem_off, const GA_Attribute *attrib,
158  const GA_AIFIndexPair *aifindexpair)
159  { bind(elem_off, attrib, aifindexpair); }
160 
161  /// Destructor
163 
164  /// Bind a element
165  /// @pre ref.isValid() == true
166  /// @{
167  void bind(GA_Offset elem_off, const GA_Attribute *attrib,
168  const GA_AIFIndexPair *aifindexpair)
169  {
170  myOffset = elem_off;
171  myAttribute = attrib;
172  myIndexPair = aifindexpair;
173  }
174  void bind(GA_Offset elem_off, const GA_ROAttributeRef &ref);
175  /// @}
176 
177  int32 getEntryIndex(int n) const;
178  fpreal32 getEntryValue(int n, int component=0) const;
179  void getEntry(int n, int32 &index, fpreal32 &value) const
180  { index = getEntryIndex(n); value = getEntryValue(n); }
181 
182 private:
183  /// Copy constructor - not available (copying not permitted)
185 
186  /// Assignment operator - not available (copying not permitted)
188 
189  const GA_Attribute *myAttribute;
190  const GA_AIFIndexPair *myIndexPair;
191  GA_Offset myOffset;
192 };
193 
194 #endif
GLdouble s
Definition: glew.h:1390
void getEntry(int n, int32 &index, fpreal32 &value) const
Definition of a geometry attribute.
Definition: GA_Attribute.h:190
Generic Attribute Interface class to get/set data as index pairs.
GLenum GLint ref
Definition: glew.h:1845
GEO_ConstAttributeIndexPairs(GA_Offset elem_off, const GA_Attribute *attrib, const GA_AIFIndexPair *aifindexpair)
GLuint index
Definition: glew.h:1814
GEO_AttributeIndexPairs(GA_Offset elem_off, GA_Attribute *attrib, const GA_AIFIndexPair *aifindexpair)
GEO_RWAttributeCapturePath(GEO_Detail *gdp, GEO_Detail::CaptureType type=GEO_Detail::CAPTURE_BONE)
void setEntry(int n, int32 index, fpreal32 value)
GLboolean reset
Definition: glew.h:4959
void getEntry(int n, int32 &index, fpreal32 &value) const
GEO_AttributeIndexPairs(GA_Offset elem_off, const GA_RWAttributeRef &ref)
GA_Size GA_Offset
Definition: GA_Types.h:637
void bind(GA_Offset elem_off, GA_Attribute *attrib, const GA_AIFIndexPair *aifindexpair)
This class provides a way to manage a reference to an attribute permitting Read-Write access...
CaptureType
Methods for manipulating capture weights (GEO_CaptureWeight.C)
Definition: GEO_Detail.h:982
UT_StringRef getPathRef(int i) const
GEO_AttributeCapturePath(const GEO_Detail *gdp, GEO_Detail::CaptureType type=GEO_Detail::CAPTURE_BONE)
This class provides a way to manage a reference to an attribute permitting Read-Only access...
const char * getPath(int i) const
GLsizei n
Definition: glew.h:4040
#define GEO_API
Definition: GEO_API.h:14
int int32
Definition: SYS_Types.h:39
GEO_ConstAttributeIndexPairs(GA_Offset elem_off, const GA_ROAttributeRef &ref)
GLuint GLuint GLsizei GLenum type
Definition: glew.h:1253
This class provides a convenient abstraction of the contents of an index pair attribute for a single ...
GLsizei const GLchar *const * path
Definition: glew.h:6461
void scaleEntryValue(int n, fpreal32 s, int component=0)
void offsetEntryValue(int n, fpreal32 o, int component=0)
const GA_AIFIndexPair * myIndexPair
This class provides a convenient abstraction of the contents of an index pair attribute for a single ...
void bind(GA_Offset elem_off, const GA_Attribute *attrib, const GA_AIFIndexPair *aifindexpair)
GLsizei const GLfloat * value
Definition: glew.h:1849
float fpreal32
Definition: SYS_Types.h:195