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