00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef __GEO_AttributeHandle__
00020 #define __GEO_AttributeHandle__
00021
00022 #include "GEO_API.h"
00023 #include <GB/GB_AttributeHandle.h>
00024 #include "GEO_AttributeOwner.h"
00025 #include "GEO_Point.h"
00026 #include "GEO_Vertex.h"
00027 #include "GEO_Primitive.h"
00028
00029 class GEO_Detail;
00030 class GEO_Primitive;
00031 class GEO_Vertex;
00032
00033 class GEO_API GEO_AttributeHandle : public GB_AttributeHandle {
00034 public:
00035 GEO_AttributeHandle();
00036 GEO_AttributeHandle(const GEO_AttributeHandle &gah);
00037 GEO_AttributeHandle(const GEO_Detail *gdp, GEO_AttributeOwner owner,
00038 GB_Attribute *attrib, int64 offset,
00039 int size_in_bytes, GB_AttribType type);
00040
00041
00042
00043 GEO_AttributeHandle(const GEO_Detail *gdp);
00044
00045 virtual GB_AttributeHandle *clone() const;
00046 virtual const char *getName() const;
00047
00048 virtual ~GEO_AttributeHandle();
00049
00050 virtual GEO_AttributeHandle &operator=(const GEO_AttributeHandle &gah);
00051
00052 virtual void invalidate();
00053
00054 virtual bool isAttributeValid() const;
00055 virtual bool isSourceAttributeValid() const;
00056 void clearElement()
00057 { setRawElement((GB_AttributeElem *)0); }
00058
00059
00060
00061
00062
00063
00064
00065 void clearSourceMap()
00066 { setSourceMap(GEO_INVALID_DICT, -1); }
00067 void setSourceMap(GEO_AttributeOwner dict, int64 o);
00068 void setSourceMap(const GB_AttributeDict &dict,
00069 GEO_AttributeOwner owner);
00070 void setSourceMap(const GEO_AttributeHandle &h);
00071
00072
00073 virtual void setElement(GEO_Vertex *v);
00074 virtual void setElement(GEO_Point *pt);
00075 virtual void setElement(GEO_Primitive *prim);
00076 virtual void setElement(GEO_Detail *gdp);
00077
00078 virtual void setElement(const GEO_Vertex *v);
00079 virtual void setElement(const GEO_Point *pt);
00080 virtual void setElement(const GEO_Primitive *prim);
00081 virtual void setElement(const GEO_Detail *gdp);
00082
00083 virtual void setElement(GEO_Primitive *p, GEO_Vertex *v);
00084 virtual void setElement(const GEO_Primitive *p, const GEO_Vertex *v);
00085
00086 GEO_AttributeOwner getDictionary() const { return myDictType; }
00087 bool isP() const { return myIsPointP; }
00088 GEO_AttributeOwner getSourceDictionary() const
00089 { return mySourceDictType; }
00090
00091 int getFloatCount(bool includePw) const
00092 {
00093 if (myIsPointP)
00094 return includePw ? 4 : 3;
00095 return isFloatOrVectorAttribute() ? entries() : 0;
00096 }
00097
00098
00099 void multiply(fpreal w)
00100 { GB_AttributeHandle::multiply(w); }
00101 void homogenize(fpreal w);
00102 void dehomogenize(fpreal w) { homogenize(1.0/w); }
00103
00104
00105 void addScale(const GEO_Primitive *p, const GEO_Vertex *v, fpreal s);
00106 void lerp(const GEO_Primitive *p, const GEO_Vertex *v, fpreal w);
00107 void lerp(const GEO_Primitive *p0, const GEO_Vertex *v0,
00108 const GEO_Primitive *p1, const GEO_Vertex *v1,
00109 fpreal w);
00110 void multiply(const GEO_Primitive *p, const GEO_Vertex *v);
00111 void divide(const GEO_Primitive *p, const GEO_Vertex *v);
00112 void copyDataFrom(const GEO_Primitive *p, const GEO_Vertex *v);
00113 void copyDataTo(GEO_Primitive *p, GEO_Vertex *v) const;
00114 bool equalData(const GEO_Primitive *p,
00115 const GEO_Vertex *v, fpreal64 t) const;
00116
00117 void addScale(const GEO_Point *elem, fpreal w)
00118 { addScaleRaw(elem, w, GEO_POINT_DICT); }
00119 void lerp(const GEO_Point *elem, fpreal w)
00120 { lerpRaw(elem, w, GEO_POINT_DICT); }
00121 void lerp(const GEO_Point *p0, const GEO_Point *p1, fpreal w)
00122 { lerpRaw(p0, p1, w, GEO_POINT_DICT); }
00123 void multiply(const GEO_Point *elem)
00124 { multiplyRaw(elem, GEO_POINT_DICT); }
00125 void divide(const GEO_Point *elem)
00126 { divideRaw(elem, GEO_POINT_DICT); }
00127 void copyDataFrom(const GEO_Point *elem)
00128 { copyDataFromRaw(elem, GEO_POINT_DICT); }
00129 void copyDataTo(GEO_Point *elem) const
00130 { copyDataToRaw(elem, GEO_POINT_DICT); }
00131 bool equalData(const GEO_Point *elem, fpreal64 tol) const
00132 { return equalDataRaw(elem, tol, GEO_POINT_DICT); }
00133
00134 void addScale(const GEO_Vertex *elem, fpreal w)
00135 { addScaleRaw(elem, w, GEO_VERTEX_DICT); }
00136 void lerp(const GEO_Vertex *elem, fpreal w)
00137 { lerpRaw(elem, w, GEO_VERTEX_DICT); }
00138 void lerp(const GEO_Vertex *p0, const GEO_Vertex *p1, fpreal w)
00139 { lerpRaw(p0, p1, w, GEO_VERTEX_DICT); }
00140 void multiply(const GEO_Vertex *elem)
00141 { multiplyRaw(elem, GEO_VERTEX_DICT); }
00142 void divide(const GEO_Vertex *elem)
00143 { divideRaw(elem, GEO_VERTEX_DICT); }
00144 void copyDataFrom(const GEO_Vertex *elem)
00145 { copyDataFromRaw(elem, GEO_VERTEX_DICT); }
00146 void copyDataTo(GEO_Vertex *elem) const
00147 { copyDataToRaw(elem, GEO_VERTEX_DICT); }
00148 bool equalData(const GEO_Vertex *elem, fpreal64 tol) const
00149 { return equalDataRaw(elem, tol, GEO_VERTEX_DICT); }
00150
00151 void addScale(const GEO_Primitive *elem, fpreal w)
00152 { addScaleRaw(elem, w, GEO_PRIMITIVE_DICT); }
00153 void lerp(const GEO_Primitive *elem, fpreal w)
00154 { lerpRaw(elem, w, GEO_PRIMITIVE_DICT); }
00155 void lerp(const GEO_Primitive *p0, const GEO_Primitive *p1, fpreal w)
00156 { lerpRaw(p0, p1, w, GEO_PRIMITIVE_DICT); }
00157 void multiply(const GEO_Primitive *elem)
00158 { multiplyRaw(elem, GEO_PRIMITIVE_DICT); }
00159 void divide(const GEO_Primitive *elem)
00160 { divideRaw(elem, GEO_PRIMITIVE_DICT); }
00161 void copyDataFrom(const GEO_Primitive *elem)
00162 { copyDataFromRaw(elem, GEO_PRIMITIVE_DICT); }
00163 void copyDataTo(GEO_Primitive *elem) const
00164 { copyDataToRaw(elem, GEO_PRIMITIVE_DICT); }
00165 bool equalData(const GEO_Primitive *elem, fpreal64 tol) const
00166 { return equalDataRaw(elem, tol, GEO_PRIMITIVE_DICT); }
00167
00168
00169 void addScale(const GEO_Detail *elem, fpreal w);
00170 void lerp(const GEO_Detail *elem, fpreal w);
00171 void lerp(const GEO_Detail *gdp0, const GEO_Detail *gdp1, fpreal w);
00172 void multiply(const GEO_Detail *elem);
00173 void divide(const GEO_Detail *elem);
00174 void copyDataFrom(const GEO_Detail *elem);
00175 void copyDataTo(GEO_Detail *elem) const;
00176 bool equalData(const GEO_Detail *elem, fpreal64 tol) const;
00177
00178 void dump(const char *msg="") const;
00179
00180 protected:
00181 virtual void setRawElement(GB_AttributeElem *elem);
00182 virtual void setRawElement(const GB_AttributeElem *elem);
00183
00184
00185
00186
00187
00188
00189
00190 void addScaleRaw(const GB_AttributeElem *elem, fpreal w,
00191 GEO_AttributeOwner owner);
00192 void lerpRaw(const GB_AttributeElem *elem, fpreal w,
00193 GEO_AttributeOwner owner);
00194 void lerpRaw(const GB_AttributeElem *p0,
00195 const GB_AttributeElem *p1, fpreal w,
00196 GEO_AttributeOwner owner);
00197 void multiplyRaw(const GB_AttributeElem *elem,
00198 GEO_AttributeOwner owner);
00199 void divideRaw(const GB_AttributeElem *elem,
00200 GEO_AttributeOwner owner);
00201 void copyDataFromRaw(const GB_AttributeElem *elem,
00202 GEO_AttributeOwner owner);
00203 void copyDataToRaw(GB_AttributeElem *elem,
00204 GEO_AttributeOwner owner) const;
00205 bool equalDataRaw(const GB_AttributeElem *elem, fpreal64 tol,
00206 GEO_AttributeOwner owner) const;
00207
00208 GEO_Point *getPoint(GB_AttributeElem *elem)
00209 { return static_cast<GEO_Point *>(elem); }
00210 const GEO_Point *getPoint(const GB_AttributeElem *elem) const
00211 { return static_cast<const GEO_Point *>(elem); }
00212 UT_Vector4 &getPos(GB_AttributeElem *elem)
00213 { return getPoint(elem)->getPos(); }
00214 const UT_Vector4 &getPos(const GB_AttributeElem *elem) const
00215 { return getPoint(elem)->getPos(); }
00216
00217 bool myIsPointP;
00218 int64 myOffset, mySourceOffset;
00219 GEO_AttributeOwner myDictType;
00220 GEO_AttributeOwner mySourceDictType;
00221 };
00222
00223 #endif