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