00001 /* 00002 * PROPRIETARY INFORMATION. This software is proprietary to 00003 * Side Effects Software Inc., and is not to be reproduced, 00004 * transmitted, or disclosed in any way without written permission. 00005 * 00006 * Produced by: 00007 * George ElKoura 00008 * Side Effects 00009 * 477 Richmond Street West 00010 * Toronto, Ontario 00011 * Canada M5V 3E7 00012 * 416-504-9876 00013 * 00014 * NAME: GU Library. 00015 * 00016 * COMMENTS: A GU_FloatVectorWrapper is a useful abstraction to dealing with 00017 * point positions and float attribute arrays as it provides a 00018 * common interface to the two. 00019 * It currently does not support vertex attributes. 00020 */ 00021 #ifndef __GU_FloatVectorWrapper_h__ 00022 #define __GU_FloatVectorWrapper_h__ 00023 00024 #include "GU_API.h" 00025 #include <UT/UT_Vector4.h> 00026 00027 class GEO_Point; 00028 class GEO_Vertex; 00029 00030 class GU_API GU_FloatVectorWrapper 00031 { 00032 public: 00033 GU_FloatVectorWrapper() {} 00034 virtual ~GU_FloatVectorWrapper() {} 00035 00036 // Operators 00037 virtual GU_FloatVectorWrapper &operator =(float s) = 0; 00038 virtual GU_FloatVectorWrapper &operator*=(float s) = 0; 00039 virtual GU_FloatVectorWrapper &operator/=(float s) = 0; 00040 00041 // Add our data to the point or vertex 00042 virtual void addTo(GEO_Point &pt) = 0; 00043 virtual void addTo(GEO_Vertex &vtx) = 0; 00044 00045 // Add the scaled data of pt to our data 00046 virtual void addScaledData(GEO_Point &pt, float s) = 0; 00047 virtual void addScaledData(GEO_Vertex &vtx, float s)= 0; 00048 00049 // Subtract the data of pt from our data 00050 virtual void subtractData(GEO_Point &pt) = 0; 00051 virtual void subtractData(GEO_Vertex &vtx) = 0; 00052 }; 00053 00054 00055 // The point float attribute array wrapper 00056 class GU_API GU_AttribWrapper : public GU_FloatVectorWrapper 00057 { 00058 public: 00059 // ptattrib is 1 if it is a point attribute and 0 if it is a vertex 00060 // attribute. 00061 GU_AttribWrapper(int ptattrib, int attriboffset, int attribsize); 00062 virtual ~GU_AttribWrapper(); 00063 00064 // Operators 00065 virtual GU_FloatVectorWrapper &operator =(float s); 00066 virtual GU_FloatVectorWrapper &operator*=(float s); 00067 virtual GU_FloatVectorWrapper &operator/=(float s); 00068 00069 // The versions of the following methods that take GEO_Vertex will delegate 00070 // to the point versions if this is a point attribute, this saves the caller 00071 // from having to always check before calling the correct version. 00072 00073 // Add our data to the point 00074 virtual void addTo(GEO_Point &pt); 00075 virtual void addTo(GEO_Vertex &vtx); 00076 00077 // Add the scaled data of pt to our data 00078 virtual void addScaledData(GEO_Point &pt,float s); 00079 virtual void addScaledData(GEO_Vertex &vtx, float s); 00080 00081 // Subtract the data of pt from our data 00082 virtual void subtractData(GEO_Point &pt); 00083 virtual void subtractData(GEO_Vertex &vtx); 00084 00085 protected: 00086 void addTo(float *attribdata); 00087 void addScaledData(float *attribdata, float s); 00088 void subtractData(float *attribdata); 00089 00090 bool isPointAttrib() const 00091 { return myAttribOwner == 1; } 00092 00093 private: 00094 int myAttribOwner; // 0 = vertex, 1 = point 00095 int myAttribOffset; 00096 int myAttribSize; 00097 float *myData; 00098 }; 00099 00100 00101 // The point position array wrapper 00102 class GU_API GU_PointPosWrapper : public GU_FloatVectorWrapper 00103 { 00104 public: 00105 GU_PointPosWrapper() {} 00106 00107 // Operators 00108 virtual GU_FloatVectorWrapper &operator =(float s); 00109 virtual GU_FloatVectorWrapper &operator*=(float s); 00110 virtual GU_FloatVectorWrapper &operator/=(float s); 00111 00112 // Add our data to the point 00113 virtual void addTo(GEO_Point &pt); 00114 virtual void addTo(GEO_Vertex &vtx); 00115 00116 // Add the scaled data of pt to our data 00117 virtual void addScaledData(GEO_Point &pt,float s); 00118 virtual void addScaledData(GEO_Vertex &vtx, float s); 00119 00120 // Subtract the data of pt from our data 00121 virtual void subtractData(GEO_Point &pt); 00122 virtual void subtractData(GEO_Vertex &vtx); 00123 00124 private: 00125 UT_Vector4 myData; 00126 }; 00127 00128 #endif
1.5.9