HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GA_AIFNumericArray.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_AIFNumericArray.h ( GA Library, C++)
7  *
8  * COMMENTS: Array Data Attribute Interface
9  */
10 
11 #ifndef __GA_AIFNumericArrayTuple__
12 #define __GA_AIFNumericArrayTuple__
13 
14 #include "GA_API.h"
15 #include "GA_Types.h"
16 
17 #include <SYS/SYS_Types.h>
19 
20 
21 class GA_Attribute;
22 class GA_Range;
23 
24 /// @brief Generic Attribute Interface class to access an attribute as a
25 /// array.
26 ///
27 /// This class provides the interface to access attribute data. Each
28 /// attribute type may provide this interface if it makes sense.
30 {
31 public:
33  virtual ~GA_AIFNumericArray();
34 
35  /// @{
36  /// Query and set some tuple intrisics.
37  virtual int getTupleSize(const GA_Attribute *attrib) const = 0;
38  virtual bool setTupleSize(GA_Attribute *attrib, int size) const = 0;
39 
40  virtual GA_Storage getStorage(const GA_Attribute *attrib) const = 0;
41  virtual bool setStorage(GA_Attribute *attrib,
42  GA_Storage storage) const = 0;
43  /// @}
44 
45  /// @{
46  /// Erase all arrays
47  virtual bool clear(GA_Attribute *attrib) const = 0;
48  /// @}
49 
50  /// @{
51  /// Return the length of longest array
52  virtual exint findMaximumArrayLength(const GA_Attribute *attrib) const = 0;
53  /// @}
54 
55  /// @{
56  /// Get a single value from a single offset in an attribute array.
57  virtual bool get(const GA_Attribute *attrib,
58  GA_Offset ai, UT_Array<fpreal16> &data) const = 0;
59  virtual bool get(const GA_Attribute *attrib,
60  GA_Offset ai, UT_Array<fpreal32> &data) const = 0;
61  virtual bool get(const GA_Attribute *attrib,
62  GA_Offset ai, UT_Array<fpreal64> &data) const = 0;
63  virtual bool get(const GA_Attribute *attrib,
64  GA_Offset ai, UT_Array<uint8> &data) const = 0;
65  virtual bool get(const GA_Attribute *attrib,
66  GA_Offset ai, UT_Array<int8> &data) const = 0;
67  virtual bool get(const GA_Attribute *attrib,
68  GA_Offset ai, UT_Array<int16> &data) const = 0;
69  virtual bool get(const GA_Attribute *attrib,
70  GA_Offset ai, UT_Array<int32> &data) const = 0;
71  virtual bool get(const GA_Attribute *attrib,
72  GA_Offset ai, UT_Array<int64> &data) const = 0;
73  /// @}
74 
75  /// @{
76  /// Appends a value from a single offset into a packed array.
77  virtual bool append(const GA_Attribute *attrib,
79  virtual bool append(const GA_Attribute *attrib,
80  GA_Offset ai, UT_PackedArrayOfArrays<fpreal32> &data) const = 0;
81  virtual bool append(const GA_Attribute *attrib,
82  GA_Offset ai, UT_PackedArrayOfArrays<fpreal64> &data) const = 0;
83  virtual bool append(const GA_Attribute *attrib,
84  GA_Offset ai, UT_PackedArrayOfArrays<uint8> &data) const = 0;
85  virtual bool append(const GA_Attribute *attrib,
86  GA_Offset ai, UT_PackedArrayOfArrays<int8> &data) const = 0;
87  virtual bool append(const GA_Attribute *attrib,
88  GA_Offset ai, UT_PackedArrayOfArrays<int16> &data) const = 0;
89  virtual bool append(const GA_Attribute *attrib,
90  GA_Offset ai, UT_PackedArrayOfArrays<int32> &data) const = 0;
91  virtual bool append(const GA_Attribute *attrib,
92  GA_Offset ai, UT_PackedArrayOfArrays<int64> &data) const = 0;
93  /// @}
94 
95  /// @{
96  /// Stream in a block representation of the array.
97  /// The index array will have nelements+1. Each array will go
98  /// from [index[i] .. index[i+1]) in the data array.
99 #define GETBLOCKFROMINDEX(ITYPE, DTYPE) \
100  virtual bool getBlockFromIndices(const GA_Attribute *attrib, \
101  GA_Index start, GA_Size nelem, \
102  UT_Array<ITYPE> &index, \
103  UT_Array<DTYPE> &data) const = 0;
120 #undef GETBLOCKFROMINDEX
121  /// @}
122 
123  /// @{
124  /// Stream in a packed array representation of the array.
125 #define GETBLOCKFROMINDEX(DTYPE) \
126  bool getPackedArrayFromIndices(const GA_Attribute *attrib, \
127  GA_Index start, GA_Size nelem, \
128  UT_PackedArrayOfArrays<DTYPE> &array) const \
129  { return getBlockFromIndices(attrib, start, nelem, array.rawOffsets(), array.rawData()); }
138 #undef GETBLOCKFROMINDEX
139 
140  /// @}
141 
142  /// @{
143  /// Test if any elements are NAN's
144  virtual bool isNan(const GA_Attribute *attrib, GA_Offset ai) const=0;
145  virtual bool isNan(const GA_Attribute *attrib,
146  const GA_Range &it) const = 0;
147  /// @}
148 
149  /// Return the size of the array for the GA_Offset
150  virtual exint arraySize(const GA_Attribute *atr, GA_Offset off) const = 0;
151 
152  // ----------------------------------------------------------------------
153 
154  /// @{
155  /// Set a single array of the array.
156  virtual bool set(GA_Attribute *attrib, GA_Offset ai,
157  const UT_Array<fpreal16> &data) const = 0;
158  virtual bool set(GA_Attribute *attrib, GA_Offset ai,
159  const UT_Array<fpreal32> &data) const = 0;
160  virtual bool set(GA_Attribute *attrib, GA_Offset ai,
161  const UT_Array<fpreal64> &data) const = 0;
162  virtual bool set(GA_Attribute *attrib, GA_Offset ai,
163  const UT_Array<uint8> &data) const = 0;
164  virtual bool set(GA_Attribute *attrib, GA_Offset ai,
165  const UT_Array<int8> &data) const = 0;
166  virtual bool set(GA_Attribute *attrib, GA_Offset ai,
167  const UT_Array<int16> &data) const = 0;
168  virtual bool set(GA_Attribute *attrib, GA_Offset ai,
169  const UT_Array<int32> &data) const = 0;
170  virtual bool set(GA_Attribute *attrib, GA_Offset ai,
171  const UT_Array<int64> &data) const = 0;
172  /// @}
173 };
174 
175 #endif
Definition of a geometry attribute.
Definition: GA_Attribute.h:196
GLsizeiptr size
Definition: glew.h:1681
Generic Attribute Interface class to access an attribute as a array.
int int32
Definition: SYS_Types.h:39
int64 exint
Definition: SYS_Types.h:125
#define GA_API
Definition: GA_API.h:12
float fpreal32
Definition: SYS_Types.h:200
A range of elements in an index-map.
Definition: GA_Range.h:42
double fpreal64
Definition: SYS_Types.h:201
unsigned char uint8
Definition: SYS_Types.h:36
GA_Size GA_Offset
Definition: GA_Types.h:639
GLint GLenum GLsizei GLint GLsizei const void * data
Definition: glew.h:1379
#define GETBLOCKFROMINDEX(ITYPE, DTYPE)
bool isNan(const float x)
Return true if x is a NaN (Not-A-Number) value.
Definition: Math.h:386
long long int64
Definition: SYS_Types.h:116
signed char int8
Definition: SYS_Types.h:35
short int16
Definition: SYS_Types.h:37
getOption("OpenEXR.storage") storage
Definition: HDK_Image.dox:276
GA_Storage
Definition: GA_Types.h:49