Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members | Related Pages

vlvoxelopvalue.h

Go to the documentation of this file.
00001 // $Id: vlvoxelopvalue.h,v 1.6 2003/08/13 19:58:06 sarang Exp $
00002 //
00003 // OpenVL - A Library for working with volumetric datasets.
00004 //          http://openvl.sf.net
00005 //
00006 // Copyright (C) 2000-2003  Sarang Lakare <sarang#users.sf.net>
00007 //
00008 // This library is free software; you can redistribute it and/or
00009 // modify it under the terms of the GNU Library General Public
00010 // License as published by the Free Software Foundation; either
00011 // version 2 of the License, or (at your option) any later version.
00012 //
00013 // This library is distributed in the hope that it will be useful,
00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016 // Library General Public License for more details.
00017 //
00018 // You should have received a copy of the GNU Library General Public
00019 // License along with this library; if not, write to the Free Software
00020 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00021 // USA.
00022 //
00023 // Please report all bugs and problems to openvl-devel@lists.sf.net or
00024 // at the OpenVL website.
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

Generated on Fri Mar 18 11:33:16 2005 for OpenVL by doxygen 1.3.3