00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef _vlVoxelOpValue_h
00028 #define _vlVoxelOpValue_h
00029
00030 #include "vlenums.h"
00031 #include "vlvector.h"
00032 #include "vlnormal.h"
00033 #include "vlcolor.h"
00034
00063 class vlVoxelOpValue {
00064 public:
00066 vlVoxelOpValue()
00067 : m_color4ub(0,0,0,0),
00068 m_color4us(0,0,0,0),
00069 m_datatype(0x0000),
00070 m_autoDelete(true) { };
00071
00073 ~vlVoxelOpValue() {
00074 if((m_datatype & Pointer) && m_autoDelete)
00075 delete [] m_realValue.ptr;
00076 };
00077
00078 int32 i() const
00079 {
00080 if(m_datatype & Int32)
00081 return m_realValue.i32;
00082 else
00083 return 0;
00084 };
00085
00086 uint32 ui() const
00087 {
00088 if(m_datatype & UInt32)
00089 return m_realValue.ui32;
00090 else
00091 return 0;
00092 };
00093
00094 double dl() const
00095 {
00096 if(m_datatype & Double)
00097 return m_realValue.dl;
00098 else
00099 return 0.0;
00100 };
00101
00102 vlVector3f vector3f() const
00103 {
00104 return m_vector3f;
00105 };
00106
00107 vlNormal3f normal3f() const
00108 {
00109 return m_normal3f;
00110 };
00111
00112 vlColor4f color4f() const
00113 {
00114 return m_color4f;
00115 };
00116
00117 vlColor4ub color4ub() const
00118 {
00119 return m_color4ub;
00120 };
00121
00122 vlColor4us color4us() const
00123 {
00124 return m_color4us;
00125 };
00126
00135 uint8 * ptr(bool autoDelete=true) const
00136 {
00137 m_autoDelete = autoDelete;
00138 if(m_datatype & Pointer)
00139 return m_realValue.ptr;
00140 else
00141 return 0;
00142 };
00143
00144 void setI(const int32 & value) { m_datatype |= Int32; m_realValue.i32 = value; };
00145
00146 void setUi(const uint32 & value) { m_datatype |= UInt32; m_realValue.ui32 = value; };
00147
00148 void setDl(const double & value) { m_datatype |= Double; m_realValue.dl = value; };
00149
00150 void setVector3f(const vlVector3f & value) { m_datatype |= Vector3f; m_vector3f = value; };
00151
00152 void setNormal3f(const vlNormal3f & value) { m_datatype |= Normal3f; m_normal3f = value; };
00153
00154 void setColor4f(const vlColor4f & value) { m_datatype |= Color4f; m_color4f = value; };
00155
00156 void setColor4ub(const vlColor4ub & value) { m_datatype |= Color4ub; m_color4ub = value; };
00157
00158 void setColor4us(const vlColor4us & value) { m_datatype |= Color4us; m_color4us = value; };
00159
00160 void setPtr(uint8 * ptr) { m_datatype |= Pointer; m_realValue.ptr = ptr; };
00161
00162 protected:
00168 union ReturnData_ {
00169 int32 i32;
00170 uint32 ui32;
00171 double dl;
00172 uint8 * ptr;
00173 } m_realValue;
00174
00175 vlVector3f m_vector3f;
00176 vlNormal3f m_normal3f;
00177 vlColor4f m_color4f;
00178 vlColor4ub m_color4ub;
00179 vlColor4us m_color4us;
00180
00182 enum ReturnType {
00183 Int32 = 0x0001,
00184 UInt32 = 0x0002,
00185 Double = 0x0004,
00186 Vector3f = 0x0008,
00187 Normal3f = 0x0010,
00188 Color4f = 0x0020,
00189 Color4ub = 0x0040,
00190 Color4us = 0x0080,
00191 Pointer = 0x0100
00192 };
00193
00194 int m_datatype;
00195
00197 mutable bool m_autoDelete;
00198 };
00199
00200
00201 #endif // _vlVoxelOpValue_h