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_StringRef;
28 
29 
31 {
32 public:
34  virtual ~GA_AIFIndexPairObjects();
35 
36  virtual int64 getMemoryUsage(bool inclusive) const = 0;
37 
38  /// @{
39  /// Query and set data about the objects each index references.
40  virtual int getObjectCount() const = 0;
41  virtual void setObjectCount(int nobj) = 0;
42 
43  virtual int getPropertyCount() const = 0;
44  virtual bool getProperty(int propid, const char *&name, GA_Storage &storage, int &size) const = 0;
45 
46  virtual int addProperty(const char *name, const UT_FloatArray &def) = 0;
47  virtual int addProperty(const char *name, const UT_IntArray &def) = 0;
48  virtual int addProperty(const char *name, const UT_StringArray &def) = 0;
49 
50  virtual bool getPropertyDefaults(int propid, UT_FloatArray &def) const = 0;
51  virtual bool getPropertyDefaults(int propid, UT_IntArray &def) const = 0;
52  virtual bool getPropertyDefaults(int propid, UT_StringArray &def) const = 0;
53 
54  virtual void getObjectValue(int objid, int propid, fpreal32 &v, int component = 0) const = 0;
55  virtual void getObjectValue(int objid, int propid, int32 &v, int component = 0) const = 0;
56  virtual void getObjectValue(int objid, int propid, const char *&v, int component = 0) const = 0;
57  virtual void getObjectValue(int objid, int propid, UT_StringRef &v, int component = 0) const = 0;
58 
59  virtual void getObjectValues(int objid, int propid, fpreal32 *v, int tuple_size) const = 0;
60  virtual void getObjectValues(int objid, int propid, int32 *v, int tuple_size) const = 0;
61  virtual void getObjectValues(int objid, int propid, UT_StringRef *v, int tuple_size) const = 0;
62 
63  virtual void setObjectValue(int objid, int propid, fpreal32 v, int component = 0) = 0;
64  virtual void setObjectValue(int objid, int propid, int32 v, int component = 0) = 0;
65  virtual void setObjectValue(int objid, int propid, const char *v, int component = 0) = 0;
66 
67  virtual void setObjectValues(int objid, int propid, const fpreal32 *v, int tuple_size) = 0;
68  virtual void setObjectValues(int objid, int propid, const int32 *v, int tuple_size) = 0;
69  virtual void setObjectValues(int objid, int propid, const char * const*v, int tuple_size) = 0;
70 
71  virtual bool jsonSave(UT_JSONWriter &w) const = 0;
72  virtual bool jsonLoad(UT_JSONParser &p) = 0;
73 
74  virtual bool copyProperties(const GA_AIFIndexPairObjects *src) = 0;
75  virtual bool hasSameProperties(const GA_AIFIndexPairObjects *other) const = 0;
76  virtual bool mergeAppendData(const GA_AIFIndexPairObjects *src, UT_IntArray &mapping) = 0;
77  virtual bool mergeAppendDataSecondary(const GA_AIFIndexPairObjects *src, int offset, UT_IntArray &mapping) = 0;
78  virtual void appendObject(const GA_AIFIndexPairObjects *src, int i) = 0;
79 
80  virtual void clear() = 0;
81  /// @}
82 
83  int findProperty(const char *name, GA_Storage storage, int size) const;
84  int findObjectValue(int propid, const char *value, int component=0) const;
85 };
86 
87 /// @brief Generic Attribute Interface class to get/set data as index
88 /// pairs.
89 ///
90 /// This class provides an interface to access attribute data. Each
91 /// attribute type may provide this interface if it makes sense.
92 ///
93 /// Index pair data can also contain a set of primary objects corresponding to
94 /// the indices. These objects should be used to hold information about the
95 /// capture region for the associated index. If the object contains a string
96 /// property, it should be unique (eg. capture path). Use s=0 to manipulate
97 /// primary objects. For example:
98 /// @code
99 /// // create primary object set
100 /// aif->setObjectSetCount(attrib, 1);
101 /// const GA_AIFIndexPairObjects *objects = aif->setObjects(attrib);
102 /// // create a string property for the objects called "path"
103 /// UT_StringArray sdef;
104 /// sdef.append("");
105 /// objects->addProperty("path", sdef);
106 /// // create a float16 property for the objects called "transform"
107 /// UT_FloatArray fdef;
108 /// for(int i = 0; i < 16; ++i)
109 /// fdef.append((i % 5 == 0) ? 1.0 : 0.0);
110 /// objects->addProperty("transform", fdef);
111 /// // add a new object
112 /// objects->setObjectCount(1);
113 /// @endcode
114 ///
115 /// Index pair data can also contain a secondary set of objects for holding
116 /// multiple bits of subdata per index. These objects should be used to hold
117 /// supplimentary data about objects such as the individual metaballs that make
118 /// up a muscle. These secondary objects should also contain an integer
119 /// property identifying the index of the primary object. Use s>0 to
120 /// manipulate secondary objects.
122 {
123 public:
124  GA_AIFIndexPair();
125  virtual ~GA_AIFIndexPair();
126 
127  /// @{
128  /// Query and set the number of object types (primary and secondary).
129  virtual int getObjectSetCount(const GA_Attribute *attrib) const = 0;
130  virtual void setObjectSetCount(GA_Attribute *attrib, int n) const = 0;
131  /// @}
132 
133  /// @{
134  /// Query and set data about the objects each index references.
135  virtual const GA_AIFIndexPairObjects *getObjects(const GA_Attribute *attrib, int s = 0) const = 0;
136  virtual GA_AIFIndexPairObjects *getObjects(GA_Attribute *attrib, int s = 0) const = 0;
137 
138  virtual bool hasSameProperties(const GA_Attribute *attrib, const GA_Attribute *sattrib) const = 0;
139  virtual bool copyProperties(GA_Attribute *attrib, const GA_Attribute *sattrib) const = 0;
140  virtual bool mergeObjectValues(GA_Attribute *attrib, const GA_Attribute *sattrib, UT_IntArray &new_indices) const = 0;
141  /// @}
142 
143  /// @{
144  /// Query and set the entry count.
145  virtual int getEntries(const GA_Attribute *attrib) const = 0;
146  virtual bool setEntries(GA_Attribute *attrib, int n) const = 0;
147  /// @}
148 
149  virtual int getDataTupleSize(const GA_Attribute *attrib) const = 0;
150  virtual bool setDataTupleSize(GA_Attribute *attrib, int size) const = 0;
151 
152  virtual GA_Storage getDataStorage(const GA_Attribute *attrib) const = 0;
153  //virtual bool setStorage(GA_Attribute *attrib, GA_Storage storage) const = 0;
154 
155  /// Get a specific (index, data[component]) pair from a given entry at a
156  /// specified offset.
157  /// @{
158  virtual bool getIndex(const GA_Attribute *attrib, GA_Offset ai, int entry, int32 &index) const = 0;
159  virtual bool getData(const GA_Attribute *attrib, GA_Offset ai, int entry, fpreal32 &data, int data_component = 0) const = 0;
160  virtual bool getData(const GA_Attribute *attrib, GA_Offset ai, int entry, fpreal64 &data, int data_component = 0) const = 0;
161  virtual bool getData(const GA_Attribute *attrib, GA_Offset ai, int entry, int32 &data, int data_component = 0) const = 0;
162  virtual bool getData(const GA_Attribute *attrib, GA_Offset ai, int entry, int64 &data, int data_component = 0) const = 0;
163  /// @}
164 
165  /// Set a specific (index, data[component]) pair from a given entry at a
166  /// specified offset.
167  /// @{
168  virtual bool setIndex(GA_Attribute *attrib, GA_Offset ai, int entry, int32 index) const = 0;
169  virtual bool setData(GA_Attribute *attrib, GA_Offset ai, int entry, fpreal32 data, int data_component = 0) const = 0;
170  virtual bool setData(GA_Attribute *attrib, GA_Offset ai, int entry, fpreal64 data, int data_component = 0) const = 0;
171  virtual bool setData(GA_Attribute *attrib, GA_Offset ai, int entry, int32 data, int data_component = 0) const = 0;
172  virtual bool setData(GA_Attribute *attrib, GA_Offset ai, int entry, int64 data, int data_component = 0) const = 0;
173  /// @}
174 
175  /// Removes all references to an index including per point references and
176  /// primary and secondary objects.
177  virtual bool removeIndex(GA_Attribute *attrib, int index) const = 0;
178 
179  /// Reset entries of specific offset to the default values starting at the
180  /// given entry index.
181  virtual void resetEntriesToDefaults(GA_Attribute *attrib,
182  GA_Offset ai, int start_entry = 0) const = 0;
183 
184 };
185 
186 #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
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
Definition: core.h:1131
GA_Storage
Definition: GA_Types.h:51
Definition: format.h:895
GLenum src
Definition: glcorearb.h:1793