00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __GB_AttributeHandle_h__
00021 #define __GB_AttributeHandle_h__
00022
00023 #include "GB_API.h"
00024 #include <SYS/SYS_Types.h>
00025 #include <UT/UT_Vector2.h>
00026 #include <UT/UT_Vector3.h>
00027 #include <UT/UT_Vector4.h>
00028 #include <UT/UT_Matrix3.h>
00029 #include <UT/UT_Matrix4.h>
00030 #include <UT/UT_Quaternion.h>
00031
00032 #include "GB_AttributeDefines.h"
00033 #include "GB_GenericData.h"
00034 #include "GB_AttributeHandleBase.h"
00035
00036 class UT_StringArray;
00037 class GB_Detail;
00038 class GB_AttributeElem;
00039 class GB_AttributeTable;
00040
00041 class GB_API GB_AttributeHandle : public GB_AttributeHandleBase
00042 {
00043 public:
00044
00045 GB_AttributeHandle();
00046
00047
00048
00049 GB_AttributeHandle(const GB_AttributeHandle &gah);
00050
00051
00052 GB_AttributeHandle(const GB_Detail *gdp,
00053 const GB_AttributeDict *dict,
00054 GB_Attribute *attrib,
00055 int size_in_bytes,
00056 GB_AttribType type);
00057
00058 virtual ~GB_AttributeHandle();
00059
00060 virtual GB_AttributeHandle *clone() const = 0;
00061 virtual const char *getName() const;
00062
00063
00064
00065
00066 virtual void setRawElement(GB_AttributeElem *element) = 0;
00067 virtual void setRawElement(const GB_AttributeElem *element) = 0;
00068
00069
00070 int entries() const { return myData.entries(); }
00071
00072
00073
00074 virtual GB_AttributeHandle &operator=(const GB_AttributeHandle &gah);
00075
00076
00077 void setF(fpreal val, int index=0)
00078 { myData.setF(val,index); }
00079 fpreal getF(int index=0) const
00080 { return myData.getF(index); }
00081
00082 void setI(int val, int index=0)
00083 { myData.setI(val, index); }
00084 int getI(int index=0) const
00085 { return myData.getI(index); }
00086
00087 void setV2(const UT_Vector2 &val, int index=0)
00088 { myData.setV2(val, index); }
00089 UT_Vector2 getV2(int index=0) const
00090 { return myData.getV2(index); }
00091
00092 void setV3(const UT_Vector3 &val, int index=0)
00093 { myData.setV3(val, index); }
00094 UT_Vector3 getV3(int index=0) const
00095 { return myData.getV3(index); }
00096
00097 void setV4(const UT_Vector4 &val, int index=0)
00098 { myData.setV4(val, index); }
00099 UT_Vector4 getV4(int index=0) const
00100 { return myData.getV4(index); }
00101
00102 void setM3(const UT_Matrix3 &val, int index=0)
00103 { myData.setM3(val, index); }
00104 UT_Matrix3 getM3(int index=0) const
00105 { return myData.getM3(index); }
00106
00107 void setM4(const UT_Matrix4 &val, int index=0)
00108 { myData.setM4(val, index); }
00109 UT_Matrix4 getM4(int index=0) const
00110 { return myData.getM4(index); }
00111
00112 template<typename T> bool import(T &result) const
00113 { return myData.import(result); }
00114
00115
00116 void setP4(const UT_Vector4 &val, int index=0)
00117 { myData.setP4(val, index); }
00118 UT_Vector4 getP4(int index=0) const
00119 { return myData.getP4(index); }
00120
00121
00122 void setQ(const UT_Quaternion &val, int index=0)
00123 { myData.setQ(val, index); }
00124 UT_Quaternion getQ(int index=0) const
00125 { return myData.getQ(index); }
00126
00127 template<typename T>
00128 T *getPointer(int index=0)
00129 { return myData.getPointer<T>(index); }
00130 template<typename T>
00131 const T *getPointer(int index=0) const
00132 { return myData.getPointer<T>(index); }
00133
00134
00135
00136 bool setString(const UT_String &str, int index=0)
00137 { return myData.setString(str, index); }
00138 bool getString(UT_String &str, int index=0,
00139 bool harden=true) const
00140 { return myData.getString(str, index); }
00141
00142
00143 void multiply(fpreal val) { myData.multiply(val); }
00144 void setValue(fpreal val) { myData.setValue(val); }
00145 void transform(const UT_Matrix4 &xform,
00146 const UT_Matrix4 &inverse,
00147 bool keeplengths=false)
00148 {
00149 myData.transform(xform, inverse, keeplengths);
00150 }
00151
00152
00153 void addScale(const GB_AttributeHandle &gah, fpreal w)
00154 { myData.addScale(gah.myData, w); }
00155
00156
00157 void multiply(const GB_AttributeHandle &gah)
00158 { myData.multiply(gah.myData); }
00159
00160 void divide(const GB_AttributeHandle &gah)
00161 { myData.divide(gah.myData); }
00162
00163
00164 void lerp(const GB_AttributeHandle &gah, fpreal w)
00165 { myData.lerp(gah.myData, w); }
00166
00167
00168 void copyDataFrom(const GB_AttributeHandle &src)
00169 { myData.copyDataFrom(src.myData); }
00170
00171
00172
00173 bool equalData(const GB_AttributeHandle &src,
00174 fpreal64 tol)
00175 { return myData.equalData(src.myData, tol); }
00176
00177
00178
00179 void resetData() { myData.resetData(); }
00180
00181
00182
00183
00184 virtual bool isAttributeValid() const = 0;
00185 virtual bool isSourceAttributeValid() const = 0;
00186
00187
00188
00189 bool isFloatOrVectorAttribute() const;
00190
00191
00192
00193 bool getDefinedStrings(UT_StringArray &list,
00194 bool harden=true) const;
00195
00196
00197
00198 int getNumDefinedStrings() const;
00199
00200
00201 const char *getDefinedString(int idx) const;
00202
00203
00204
00205
00206
00207
00208 int addDefinedString(const char *name);
00209
00210
00211 virtual void invalidate();
00212
00213
00214
00215
00216 const GB_Attribute *getAttribute() const { return myData.getAttribute(); }
00217 GB_Attribute *getAttribute() { return myData.getAttribute(); }
00218
00219 protected:
00220
00221
00222 bool isValid() const;
00223 bool isSourceValid() const;
00224
00225 friend class GB_AttributeListHandle;
00226 friend class GEO_AttributeHandleList;
00227
00228 protected:
00229 GB_GenericData myData;
00230 };
00231
00232 #endif