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 <SYS/SYS_Types.h>
18 
20 {
21 public:
23  : myAttrib(0), myIndexPair(0)
24  {
25  }
26 
29  {
30  reset(gdp, type);
31  }
32 
33  void reset(const GEO_Detail *gdp,
35 
36  bool isValid() const { return myAttrib && myIndexPair; }
37  int getNumPaths() const;
38  const char *getPath(int i) const;
39  int getIndex(const char *path) const;
40  void clear(void);
41 
42 protected:
45 };
46 
48 {
49 public:
51  GEO_Detail *gdp,
54  {
55  }
56  void setPath(int i, const char *path) const;
57 };
58 
59 /// @brief This class provides a convenient abstraction of the contents of an
60 /// index pair attribute for a single element.
61 ///
62 /// It is important to note that this class does not perform any sort of bounds
63 /// checking.
64 ///
65 /// @warning This is being used internally by Side Effects to simplify forward
66 /// compatibility issues. The lifetime of this class is not well known and
67 /// code should not rely on any methods herein.
69 {
70 public:
71  /// No Default constructor. An instance must always be bound.
72  /// @pre ref.isValid() == true
74  const GA_RWAttributeRef &ref) { bind(elem_off, ref); }
76  const GA_AIFIndexPair *aifindexpair)
77  { bind(elem_off, attrib, aifindexpair); }
78 
79  /// Destructor
80  ~GEO_AttributeIndexPairs() { /* NOP */ }
81 
82  /// Bind a element
83  /// @pre ref.isValid() == true
84  /// @{
85  void bind(GA_Offset elem_off, GA_Attribute *attrib,
86  const GA_AIFIndexPair *aifindexpair)
87  {
88  myOffset = elem_off;
89  myAttribute = attrib;
90  myIndexPair = aifindexpair;
91  }
92  void bind(GA_Offset elem_off, const GA_RWAttributeRef &ref);
93  /// @}
94 
95  int32 getEntryIndex(int n) const;
96  fpreal32 getEntryValue(int n, int component=0) const;
97  void getEntry(int n, int32 &index, fpreal32 &value) const
98  {
99  index = getEntryIndex(n);
100  value = getEntryValue(n);
101  }
102 
103  void setEntryIndex(int n, int32 index);
104  void setEntryValue(int n, fpreal32 value, int component=0);
106  {
107  setEntryIndex(n, index);
108  setEntryValue(n, value);
109  }
110 
111  void offsetEntryValue(int n, fpreal32 o, int component=0)
112  { setEntryValue(n, getEntryValue(n, component) + o, component); }
113  void scaleEntryValue(int n, fpreal32 s, int component=0)
114  { setEntryValue(n, getEntryValue(n, component) * s, component); }
115 
116 private:
117  /// Copy constructor - not available (copying not permitted)
119 
120  /// Assignment operator - not available (copying not permitted)
122 
123  GA_Attribute *myAttribute;
124  const GA_AIFIndexPair *myIndexPair;
125  GA_Offset myOffset;
126 };
127 
128 /// @brief This class provides a convenient abstraction of the contents of an
129 /// index pair attribute for a single const element.
130 ///
131 /// @warning This is being used internally by Side Effects to simplify forward
132 /// compatibility issues. The lifetime of this class is not well known and
133 /// code should not rely on any methods herein.
135 {
136 public:
137  /// No Default constructor. An instance must always be bound.
138  /// @pre ref.isValid() == true
140  const GA_ROAttributeRef &ref) { bind(elem_off, ref); }
142  GA_Offset elem_off, const GA_Attribute *attrib,
143  const GA_AIFIndexPair *aifindexpair)
144  { bind(elem_off, attrib, aifindexpair); }
145 
146  /// Destructor
148 
149  /// Bind a element
150  /// @pre ref.isValid() == true
151  /// @{
152  void bind(GA_Offset elem_off, const GA_Attribute *attrib,
153  const GA_AIFIndexPair *aifindexpair)
154  {
155  myOffset = elem_off;
156  myAttribute = attrib;
157  myIndexPair = aifindexpair;
158  }
159  void bind(GA_Offset elem_off, const GA_ROAttributeRef &ref);
160  /// @}
161 
162  int32 getEntryIndex(int n) const;
163  fpreal32 getEntryValue(int n, int component=0) const;
164  void getEntry(int n, int32 &index, fpreal32 &value) const
165  { index = getEntryIndex(n); value = getEntryValue(n); }
166 
167 private:
168  /// Copy constructor - not available (copying not permitted)
170 
171  /// Assignment operator - not available (copying not permitted)
173 
174  const GA_Attribute *myAttribute;
175  const GA_AIFIndexPair *myIndexPair;
176  GA_Offset myOffset;
177 };
178 
179 #endif
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.
GEO_ConstAttributeIndexPairs(GA_Offset elem_off, const GA_Attribute *attrib, const GA_AIFIndexPair *aifindexpair)
GLsizei const GLchar *const * path
Definition: glcorearb.h:3340
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)
png_uint_32 i
Definition: png.h:2877
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:617
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:2007
CaptureType
Methods for manipulating capture weights (GEO_CaptureWeight.C)
Definition: GEO_Detail.h:942
GLint ref
Definition: glcorearb.h:123
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...
#define GEO_API
Definition: GEO_API.h:10
int int32
Definition: SYS_Types.h:35
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 ...
GLsizei const GLfloat * value
Definition: glcorearb.h:823
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:785
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:107
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)
float fpreal32
Definition: SYS_Types.h:191