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 
20 class GA_ROAttributeRef;
21 class GA_RWAttributeRef;
22 
24 {
25 public:
27  : myAttrib(nullptr), myIndexPair(nullptr)
28  {
29  }
30 
33  const UT_StringRef &attrib_name = UT_StringHolder::theEmptyString)
34  {
35  reset(gdp, type, attrib_name);
36  }
37 
38  void reset(
39  const GA_Attribute *capt_attrib,
41 
42  void reset(
43  const GEO_Detail *gdp,
45  const UT_StringRef &attrib_name = UT_StringHolder::theEmptyString);
46 
47  bool isValid() const { return myAttrib && myIndexPair; }
48  int getNumPaths() const;
49  const char *getPath(int i) const
50  {
51  if (!isValid())
52  return nullptr;
53  return getPathImpl(i).c_str();
54  }
55  UT_StringRef getPathRef(int i) const
56  {
57  if (!isValid())
58  return nullptr;
59  return getPathImpl(i);
60  }
61 
62  int getIndex(const char *path) const;
63  void clear();
64 
65 private:
66  UT_StringRef getPathImpl(int i) const;
67 protected:
70 };
71 
73 {
74 public:
76  GEO_Detail *gdp,
78  const UT_StringRef &attrib_name = UT_StringHolder::theEmptyString)
79  : GEO_AttributeCapturePath(gdp, type, attrib_name)
80  {
81  }
82  void setPath(int i, const char *path) const;
83 };
84 
85 /// @brief This class provides a convenient abstraction of the contents of an
86 /// index pair attribute for a single element.
87 ///
88 /// It is important to note that this class does not perform any sort of bounds
89 /// checking.
90 ///
91 /// @warning This is being used internally by Side Effects to simplify forward
92 /// compatibility issues. The lifetime of this class is not well known and
93 /// code should not rely on any methods herein.
95 {
96 public:
97  /// No Default constructor. An instance must always be bound.
98  /// @pre ref.isValid() == true
100  const GA_RWAttributeRef &ref) { bind(elem_off, ref); }
102  const GA_AIFIndexPair *aifindexpair)
103  { bind(elem_off, attrib, aifindexpair); }
104 
105  /// Destructor
106  ~GEO_AttributeIndexPairs() { /* NOP */ }
107 
108  /// Bind a element
109  /// @pre ref.isValid() == true
110  /// @{
111  void bind(GA_Offset elem_off, GA_Attribute *attrib,
112  const GA_AIFIndexPair *aifindexpair)
113  {
114  myOffset = elem_off;
115  myAttribute = attrib;
116  myIndexPair = aifindexpair;
117  }
118  void bind(GA_Offset elem_off, const GA_RWAttributeRef &ref);
119  /// @}
120 
121  int32 getEntryIndex(int n) const;
122  fpreal32 getEntryValue(int n, int component=0) const;
123  void getEntry(int n, int32 &index, fpreal32 &value) const
124  {
125  index = getEntryIndex(n);
126  value = getEntryValue(n);
127  }
128 
129  void setEntryIndex(int n, int32 index);
130  void setEntryValue(int n, fpreal32 value, int component=0);
132  {
133  setEntryIndex(n, index);
134  setEntryValue(n, value);
135  }
136 
137  void offsetEntryValue(int n, fpreal32 o, int component=0)
138  { setEntryValue(n, getEntryValue(n, component) + o, component); }
139  void scaleEntryValue(int n, fpreal32 s, int component=0)
140  { setEntryValue(n, getEntryValue(n, component) * s, component); }
141 
142 private:
143  /// Copy constructor - not available (copying not permitted)
145 
146  /// Assignment operator - not available (copying not permitted)
148 
149  GA_Attribute *myAttribute;
150  const GA_AIFIndexPair *myIndexPair;
151  GA_Offset myOffset;
152 };
153 
154 /// @brief This class provides a convenient abstraction of the contents of an
155 /// index pair attribute for a single const element.
156 ///
157 /// @warning This is being used internally by Side Effects to simplify forward
158 /// compatibility issues. The lifetime of this class is not well known and
159 /// code should not rely on any methods herein.
161 {
162 public:
163  /// No Default constructor. An instance must always be bound.
164  /// @pre ref.isValid() == true
166  const GA_ROAttributeRef &ref) { bind(elem_off, ref); }
168  GA_Offset elem_off, const GA_Attribute *attrib,
169  const GA_AIFIndexPair *aifindexpair)
170  { bind(elem_off, attrib, aifindexpair); }
171 
172  /// Destructor
174 
175  /// Bind a element
176  /// @pre ref.isValid() == true
177  /// @{
178  void bind(GA_Offset elem_off, const GA_Attribute *attrib,
179  const GA_AIFIndexPair *aifindexpair)
180  {
181  myOffset = elem_off;
182  myAttribute = attrib;
183  myIndexPair = aifindexpair;
184  }
185  void bind(GA_Offset elem_off, const GA_ROAttributeRef &ref);
186  /// @}
187 
188  int32 getEntryIndex(int n) const;
189  fpreal32 getEntryValue(int n, int component=0) const;
190  void getEntry(int n, int32 &index, fpreal32 &value) const
191  { index = getEntryIndex(n); value = getEntryValue(n); }
192 
193 private:
194  /// Copy constructor - not available (copying not permitted)
196 
197  /// Assignment operator - not available (copying not permitted)
199 
200  const GA_Attribute *myAttribute;
201  const GA_AIFIndexPair *myIndexPair;
202  GA_Offset myOffset;
203 };
204 
205 #endif
void getEntry(int n, int32 &index, fpreal32 &value) const
Definition of a geometry attribute.
Definition: GA_Attribute.h:203
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)
GEO_RWAttributeCapturePath(GEO_Detail *gdp, GEO_Detail::CaptureType type=GEO_Detail::CAPTURE_BONE, const UT_StringRef &attrib_name=UT_StringHolder::theEmptyString)
GLsizei const GLfloat * value
Definition: glcorearb.h:824
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
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:653
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
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:108
CaptureType
Methods for manipulating capture weights (GEO_CaptureWeight.C)
Definition: GEO_Detail.h:1016
GLboolean reset
Definition: glad.h:5138
UT_StringRef getPathRef(int i) const
GLint ref
Definition: glcorearb.h:124
This class provides a way to manage a reference to an attribute permitting Read-Only access...
static const UT_StringHolder theEmptyString
const char * getPath(int i) const
#define GEO_API
Definition: GEO_API.h:14
GEO_AttributeCapturePath(const GEO_Detail *gdp, GEO_Detail::CaptureType type=GEO_Detail::CAPTURE_BONE, const UT_StringRef &attrib_name=UT_StringHolder::theEmptyString)
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
LeafData & operator=(const LeafData &)=delete
GLuint index
Definition: glcorearb.h:786
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)