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();
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
void getEntry(int n, int32 &index, fpreal32 &value) const
Definition of a geometry attribute.
Definition: GA_Attribute.h:198
int int32
Definition: SYS_Types.h:39
Generic Attribute Interface class to get/set data as index pairs.
GEO_ConstAttributeIndexPairs(GA_Offset elem_off, const GA_Attribute *attrib, const GA_AIFIndexPair *aifindexpair)
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
GEO_AttributeIndexPairs(GA_Offset elem_off, GA_Attribute *attrib, const GA_AIFIndexPair *aifindexpair)
GLdouble s
Definition: glad.h:3009
GEO_RWAttributeCapturePath(GEO_Detail *gdp, GEO_Detail::CaptureType type=GEO_Detail::CAPTURE_BONE)
void setEntry(int n, int32 index, fpreal32 value)
float fpreal32
Definition: SYS_Types.h:200
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:641
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...
GLdouble n
Definition: glcorearb.h:2008
CaptureType
Methods for manipulating capture weights (GEO_CaptureWeight.C)
Definition: GEO_Detail.h:996
GLboolean reset
Definition: glad.h:5138
UT_StringRef getPathRef(int i) const
GLint ref
Definition: glcorearb.h:124
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
#define GEO_API
Definition: GEO_API.h:14
GEO_ConstAttributeIndexPairs(GA_Offset elem_off, const GA_ROAttributeRef &ref)
This class provides a convenient abstraction of the contents of an index pair attribute for a single ...
void scaleEntryValue(int n, fpreal32 s, int component=0)
void offsetEntryValue(int n, fpreal32 o, int component=0)
const GA_AIFIndexPair * myIndexPair
GLuint index
Definition: glcorearb.h:786
This class provides a convenient abstraction of the contents of an index pair attribute for a single ...
Definition: core.h:1131
void bind(GA_Offset elem_off, const GA_Attribute *attrib, const GA_AIFIndexPair *aifindexpair)
type
Definition: core.h:1059