HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GA_AIFIndexPair.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_AIFIndexPair.h ( GA Library, C++)
7  *
8  * COMMENTS: Attribute Interface class for index pair access methods
9  */
10 
11 #ifndef __GA_AIFIndexPair__
12 #define __GA_AIFIndexPair__
13 
14 #include "GA_API.h"
15 #include "GA_Types.h"
16 
17 #include <UT/UT_VectorTypes.h>
18 
19 #include <SYS/SYS_Types.h>
20 
21 
22 class GA_Attribute;
23 
24 class UT_JSONParser;
25 class UT_JSONWriter;
26 class UT_StringArray;
27 class UT_StringHolder;
28 class UT_StringRef;
29 
30 
32 {
33 public:
35  virtual ~GA_AIFIndexPairObjects();
36 
37  virtual int64 getMemoryUsage(bool inclusive) const = 0;
38 
39  /// @{
40  /// Query and set data about the objects each index references.
41  virtual int getObjectCount() const = 0;
42  virtual void setObjectCount(int nobj) = 0;
43 
44  virtual int getPropertyCount() const = 0;
45  virtual bool getProperty(int propid, const char *&name, GA_Storage &storage, int &size) const = 0;
46 
47  virtual int addProperty(const char *name, const UT_FloatArray &def) = 0;
48  virtual int addProperty(const char *name, const UT_IntArray &def) = 0;
49  virtual int addProperty(const char *name, const UT_StringArray &def) = 0;
50 
51  virtual bool getPropertyDefaults(int propid, UT_FloatArray &def) const = 0;
52  virtual bool getPropertyDefaults(int propid, UT_IntArray &def) const = 0;
53  virtual bool getPropertyDefaults(int propid, UT_StringArray &def) const = 0;
54 
55  virtual void getObjectValue(int objid, int propid, fpreal32 &v, int component = 0) const = 0;
56  virtual void getObjectValue(int objid, int propid, int32 &v, int component = 0) const = 0;
57  virtual void getObjectValue(int objid, int propid, const char *&v, int component = 0) const = 0;
58  virtual void getObjectValue(int objid, int propid, UT_StringRef &v, int component = 0) const = 0;
59 
60  virtual void getObjectValues(int objid, int propid, fpreal32 *v, int tuple_size) const = 0;
61  virtual void getObjectValues(int objid, int propid, int32 *v, int tuple_size) const = 0;
62  virtual void getObjectValues(int objid, int propid, UT_StringRef *v, int tuple_size) const = 0;
63 
64  virtual void setObjectValue(int objid, int propid, fpreal32 v, int component = 0) = 0;
65  virtual void setObjectValue(int objid, int propid, int32 v, int component = 0) = 0;
66  virtual void setObjectValue(int objid, int propid, const UT_StringHolder &v, int component = 0) = 0;
67 
68  virtual void setObjectValues(int objid, int propid, const fpreal32 *v, int tuple_size) = 0;
69  virtual void setObjectValues(int objid, int propid, const int32 *v, int tuple_size) = 0;
70  virtual void setObjectValues(int objid, int propid, const char * const*v, int tuple_size) = 0;
71 
72  virtual bool jsonSave(UT_JSONWriter &w) const = 0;
73  virtual bool jsonLoad(UT_JSONParser &p) = 0;
74 
75  virtual bool copyProperties(const GA_AIFIndexPairObjects *src) = 0;
76  virtual bool hasSameProperties(const GA_AIFIndexPairObjects *other) const = 0;
77  virtual bool mergeAppendData(const GA_AIFIndexPairObjects *src, UT_IntArray &mapping) = 0;
78  virtual bool mergeAppendDataSecondary(const GA_AIFIndexPairObjects *src, int offset, UT_IntArray &mapping) = 0;
79  virtual void appendObject(const GA_AIFIndexPairObjects *src, int i) = 0;
80 
81  virtual void clear() = 0;
82  /// @}
83 
84  int findProperty(const char *name, GA_Storage storage, int size) const;
85  int findObjectValue(int propid, const char *value, int component=0) const;
86 };
87 
88 /// @brief Generic Attribute Interface class to get/set data as index
89 /// pairs.
90 ///
91 /// This class provides an interface to access attribute data. Each
92 /// attribute type may provide this interface if it makes sense.
93 ///
94 /// Index pair data can also contain a set of primary objects corresponding to
95 /// the indices. These objects should be used to hold information about the
96 /// capture region for the associated index. If the object contains a string
97 /// property, it should be unique (eg. capture path). Use s=0 to manipulate
98 /// primary objects. For example:
99 /// @code
100 /// // create primary object set
101 /// aif->setObjectSetCount(attrib, 1);
102 /// const GA_AIFIndexPairObjects *objects = aif->setObjects(attrib);
103 /// // create a string property for the objects called "path"
104 /// UT_StringArray sdef;
105 /// sdef.append("");
106 /// objects->addProperty("path", sdef);
107 /// // create a float16 property for the objects called "transform"
108 /// UT_FloatArray fdef;
109 /// for(int i = 0; i < 16; ++i)
110 /// fdef.append((i % 5 == 0) ? 1.0 : 0.0);
111 /// objects->addProperty("transform", fdef);
112 /// // add a new object
113 /// objects->setObjectCount(1);
114 /// @endcode
115 ///
116 /// Index pair data can also contain a secondary set of objects for holding
117 /// multiple bits of subdata per index. These objects should be used to hold
118 /// supplimentary data about objects such as the individual metaballs that make
119 /// up a muscle. These secondary objects should also contain an integer
120 /// property identifying the index of the primary object. Use s>0 to
121 /// manipulate secondary objects.
123 {
124 public:
125  GA_AIFIndexPair();
126  virtual ~GA_AIFIndexPair();
127 
128  /// @{
129  /// Query and set the number of object types (primary and secondary).
130  virtual int getObjectSetCount(const GA_Attribute *attrib) const = 0;
131  virtual void setObjectSetCount(GA_Attribute *attrib, int n) const = 0;
132  /// @}
133 
134  /// @{
135  /// Query and set data about the objects each index references.
136  virtual const GA_AIFIndexPairObjects *getObjects(const GA_Attribute *attrib, int s = 0) const = 0;
137  virtual GA_AIFIndexPairObjects *getObjects(GA_Attribute *attrib, int s = 0) const = 0;
138 
139  virtual bool hasSameProperties(const GA_Attribute *attrib, const GA_Attribute *sattrib) const = 0;
140  virtual bool copyProperties(GA_Attribute *attrib, const GA_Attribute *sattrib) const = 0;
141  virtual bool mergeObjectValues(GA_Attribute *attrib, const GA_Attribute *sattrib, UT_IntArray &new_indices) const = 0;
142  /// @}
143 
144  /// @{
145  /// Query and set the entry count.
146  virtual int getEntries(const GA_Attribute *attrib) const = 0;
147  virtual bool setEntries(GA_Attribute *attrib, int n) const = 0;
148  /// @}
149 
150  virtual int getDataTupleSize(const GA_Attribute *attrib) const = 0;
151  virtual bool setDataTupleSize(GA_Attribute *attrib, int size) const = 0;
152 
153  virtual GA_Storage getDataStorage(const GA_Attribute *attrib) const = 0;
154  //virtual bool setStorage(GA_Attribute *attrib, GA_Storage storage) const = 0;
155 
156  /// Get a specific (index, data[component]) pair from a given entry at a
157  /// specified offset.
158  /// @{
159  virtual bool getIndex(const GA_Attribute *attrib, GA_Offset ai, int entry, int32 &index) const = 0;
160  virtual bool getData(const GA_Attribute *attrib, GA_Offset ai, int entry, fpreal32 &data, int data_component = 0) const = 0;
161  virtual bool getData(const GA_Attribute *attrib, GA_Offset ai, int entry, fpreal64 &data, int data_component = 0) const = 0;
162  virtual bool getData(const GA_Attribute *attrib, GA_Offset ai, int entry, int32 &data, int data_component = 0) const = 0;
163  virtual bool getData(const GA_Attribute *attrib, GA_Offset ai, int entry, int64 &data, int data_component = 0) const = 0;
164  /// @}
165 
166  /// Set a specific (index, data[component]) pair from a given entry at a
167  /// specified offset.
168  /// @{
169  virtual bool setIndex(GA_Attribute *attrib, GA_Offset ai, int entry, int32 index) const = 0;
170  virtual bool setData(GA_Attribute *attrib, GA_Offset ai, int entry, fpreal32 data, int data_component = 0) const = 0;
171  virtual bool setData(GA_Attribute *attrib, GA_Offset ai, int entry, fpreal64 data, int data_component = 0) const = 0;
172  virtual bool setData(GA_Attribute *attrib, GA_Offset ai, int entry, int32 data, int data_component = 0) const = 0;
173  virtual bool setData(GA_Attribute *attrib, GA_Offset ai, int entry, int64 data, int data_component = 0) const = 0;
174  /// @}
175 
176  /// Removes all references to an index including per point references and
177  /// primary and secondary objects.
178  virtual bool removeIndex(GA_Attribute *attrib, int index) const = 0;
179 
180  /// Reset entries of specific offset to the default values starting at the
181  /// given entry index.
182  virtual void resetEntriesToDefaults(GA_Attribute *attrib,
183  GA_Offset ai, int start_entry = 0) const = 0;
184 
185 };
186 
187 #endif
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.
getFileOption("OpenEXR:storage") storage
Definition: HDK_Image.dox:276
const GLdouble * v
Definition: glcorearb.h:837
GLsizei const GLfloat * value
Definition: glcorearb.h:824
GLdouble s
Definition: glad.h:3009
JSON reader class which handles parsing of JSON or bJSON files.
Definition: UT_JSONParser.h:87
#define GA_API
Definition: GA_API.h:14
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:37
float fpreal32
Definition: SYS_Types.h:200
double fpreal64
Definition: SYS_Types.h:201
GA_Size GA_Offset
Definition: GA_Types.h:646
GLdouble n
Definition: glcorearb.h:2008
GLintptr offset
Definition: glcorearb.h:665
long long int64
Definition: SYS_Types.h:116
GLuint const GLchar * name
Definition: glcorearb.h:786
GLsizeiptr size
Definition: glcorearb.h:664
GLuint index
Definition: glcorearb.h:786
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:857
GA_Storage
Definition: GA_Types.h:51
Definition: format.h:1821
GLenum src
Definition: glcorearb.h:1793