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

vlVoxelOpValue Class Reference

This class is used to pass output of voxel operators to the user. More...

#include <vlvoxelopvalue.h>

List of all members.

Public Member Functions

 vlVoxelOpValue ()
 Default constructor.

 ~vlVoxelOpValue ()
 Default destructor.

int32 i () const
uint32 ui () const
double dl () const
vlVector3f vector3f () const
vlNormal3f normal3f () const
vlColor4f color4f () const
vlColor4ub color4ub () const
vlColor4us color4us () const
uint8ptr (bool autoDelete=true) const
 Returns the pointer stored.

void setI (const int32 &value)
void setUi (const uint32 &value)
void setDl (const double &value)
void setVector3f (const vlVector3f &value)
void setNormal3f (const vlNormal3f &value)
void setColor4f (const vlColor4f &value)
void setColor4ub (const vlColor4ub &value)
void setColor4us (const vlColor4us &value)
void setPtr (uint8 *ptr)

Protected Types

enum  ReturnType {
  Int32 = 0x0001, UInt32 = 0x0002, Double = 0x0004, Vector3f = 0x0008,
  Normal3f = 0x0010, Color4f = 0x0020, Color4ub = 0x0040, Color4us = 0x0080,
  Pointer = 0x0100
}
 The type of data stored in the class. More...


Protected Attributes

vlVoxelOpValue::ReturnData_ m_realValue
 Use union to save some space.

vlVector3f m_vector3f
vlNormal3f m_normal3f
vlColor4f m_color4f
vlColor4ub m_color4ub
vlColor4us m_color4us
int m_datatype
bool m_autoDelete
 Decides if to delete pointer or not when this object is deleted. Default is true.


Detailed Description

The voxel operators are used inside iterators, and the iterators need to have a consistant API. Voxel operators cannot be forced to return data of the same type. Each voxel operator may have its own data to return to the user. We thus have a problem where we want to keep the iterator API consistant and allow voxel operators to pass whatever data they want in an effecient manner. To solve these two problems, we came up with this class. Each voxel operator will store its output data in this class. When the user accesses the data, he/she will use the API of this class to get the data. Before accessing the data, the user has to know what type of data the voxel operator is returning. For example, if an operator is returning double, then the user would used value->dl() function call to get the data stored in the object.

If you are now thinking this is a hack: Yes, it is a hack.. but a pretty good one I think. This is the best solution I thought of to overcome this C++ limitation. It ofcourse has the drawback that the return value is not typesafe and thus it is easy for the user to access the wrong data. To solve this problem to a certain extent, we return a 0 if the user is trying to access wrong datatype. For example, if the voxel operator stores an int value and the user uses dl() function to access the value, a 0 will be returned. We ofcourse assume that the user knows what data the operator is returning. This is a fair assumption because unless the user knows the datatype of the data being returned by the operator, he/she cannot really use it anyway.

Author:
Sarang Lakare <sarang#users.sourceforge.net>

Todo:
Add debug macro which will print that the user is accessing wrong datatype.

Definition at line 63 of file vlvoxelopvalue.h.


Member Enumeration Documentation

enum vlVoxelOpValue::ReturnType [protected]
 

Enumeration values:
Int32 
UInt32 
Double 
Vector3f 
Normal3f 
Color4f 
Color4ub 
Color4us 
Pointer 

Definition at line 182 of file vlvoxelopvalue.h.


Constructor & Destructor Documentation

vlVoxelOpValue::vlVoxelOpValue  )  [inline]
 

Definition at line 66 of file vlvoxelopvalue.h.

References m_autoDelete, m_color4ub, m_color4us, and m_datatype.

vlVoxelOpValue::~vlVoxelOpValue  )  [inline]
 

Definition at line 73 of file vlvoxelopvalue.h.

References m_autoDelete, m_datatype, m_realValue, Pointer, and vlVoxelOpValue::ReturnData_::ptr.


Member Function Documentation

vlColor4f vlVoxelOpValue::color4f  )  const [inline]
 

Definition at line 112 of file vlvoxelopvalue.h.

References m_color4f.

vlColor4ub vlVoxelOpValue::color4ub  )  const [inline]
 

Definition at line 117 of file vlvoxelopvalue.h.

References m_color4ub.

vlColor4us vlVoxelOpValue::color4us  )  const [inline]
 

Definition at line 122 of file vlvoxelopvalue.h.

References m_color4us.

double vlVoxelOpValue::dl  )  const [inline]
 

Definition at line 94 of file vlvoxelopvalue.h.

References vlVoxelOpValue::ReturnData_::dl, Double, m_datatype, and m_realValue.

Referenced by vlVolProcessorSobel::runT(), and vlVolProcessorCentralDiff::runT().

int32 vlVoxelOpValue::i  )  const [inline]
 

Definition at line 78 of file vlvoxelopvalue.h.

References vlVoxelOpValue::ReturnData_::i32, Int32, int32, m_datatype, and m_realValue.

vlNormal3f vlVoxelOpValue::normal3f  )  const [inline]
 

Definition at line 107 of file vlvoxelopvalue.h.

References m_normal3f.

uint8* vlVoxelOpValue::ptr bool  autoDelete = true  )  const [inline]
 

If no pointer is stored, returns 0L.

Parameters:
autoDelete Set this to true if you want to autodelete the pointer when this object is destructed. Default value is true.

Definition at line 135 of file vlvoxelopvalue.h.

References m_autoDelete, m_datatype, m_realValue, Pointer, vlVoxelOpValue::ReturnData_::ptr, and uint8.

void vlVoxelOpValue::setColor4f const vlColor4f value  )  [inline]
 

Definition at line 154 of file vlvoxelopvalue.h.

References Color4f, m_color4f, and m_datatype.

void vlVoxelOpValue::setColor4ub const vlColor4ub value  )  [inline]
 

Definition at line 156 of file vlvoxelopvalue.h.

References Color4ub, m_color4ub, and m_datatype.

void vlVoxelOpValue::setColor4us const vlColor4us value  )  [inline]
 

Definition at line 158 of file vlvoxelopvalue.h.

References Color4us, m_color4us, and m_datatype.

void vlVoxelOpValue::setDl const double &  value  )  [inline]
 

Definition at line 148 of file vlvoxelopvalue.h.

References vlVoxelOpValue::ReturnData_::dl, Double, m_datatype, and m_realValue.

Referenced by vlVoxelOpSobel< DataType, Layout >::getValue(), and vlVoxelOpCentralDiff< DataType, Layout >::getValue().

void vlVoxelOpValue::setI const int32 value  )  [inline]
 

Definition at line 144 of file vlvoxelopvalue.h.

References vlVoxelOpValue::ReturnData_::i32, Int32, m_datatype, and m_realValue.

void vlVoxelOpValue::setNormal3f const vlNormal3f value  )  [inline]
 

Definition at line 152 of file vlvoxelopvalue.h.

References m_datatype, m_normal3f, and Normal3f.

Referenced by vlVoxelOpSobel< DataType, Layout >::getValue(), and vlVoxelOpCentralDiff< DataType, Layout >::getValue().

void vlVoxelOpValue::setPtr uint8 ptr  )  [inline]
 

Definition at line 160 of file vlvoxelopvalue.h.

References m_datatype, m_realValue, Pointer, and vlVoxelOpValue::ReturnData_::ptr.

void vlVoxelOpValue::setUi const uint32 value  )  [inline]
 

Definition at line 146 of file vlvoxelopvalue.h.

References m_datatype, m_realValue, vlVoxelOpValue::ReturnData_::ui32, and UInt32.

void vlVoxelOpValue::setVector3f const vlVector3f value  )  [inline]
 

Definition at line 150 of file vlvoxelopvalue.h.

References m_datatype, m_vector3f, and Vector3f.

uint32 vlVoxelOpValue::ui  )  const [inline]
 

Definition at line 86 of file vlvoxelopvalue.h.

References m_datatype, m_realValue, vlVoxelOpValue::ReturnData_::ui32, UInt32, and uint32.

vlVector3f vlVoxelOpValue::vector3f  )  const [inline]
 

Definition at line 102 of file vlvoxelopvalue.h.

References m_vector3f.


Member Data Documentation

bool vlVoxelOpValue::m_autoDelete [mutable, protected]
 

Definition at line 197 of file vlvoxelopvalue.h.

Referenced by ptr(), vlVoxelOpValue(), and ~vlVoxelOpValue().

vlColor4f vlVoxelOpValue::m_color4f [protected]
 

Definition at line 177 of file vlvoxelopvalue.h.

Referenced by color4f(), and setColor4f().

vlColor4ub vlVoxelOpValue::m_color4ub [protected]
 

Definition at line 178 of file vlvoxelopvalue.h.

Referenced by color4ub(), setColor4ub(), and vlVoxelOpValue().

vlColor4us vlVoxelOpValue::m_color4us [protected]
 

Definition at line 179 of file vlvoxelopvalue.h.

Referenced by color4us(), setColor4us(), and vlVoxelOpValue().

int vlVoxelOpValue::m_datatype [protected]
 

Definition at line 194 of file vlvoxelopvalue.h.

Referenced by dl(), i(), ptr(), setColor4f(), setColor4ub(), setColor4us(), setDl(), setI(), setNormal3f(), setPtr(), setUi(), setVector3f(), ui(), vlVoxelOpValue(), and ~vlVoxelOpValue().

vlNormal3f vlVoxelOpValue::m_normal3f [protected]
 

Definition at line 176 of file vlvoxelopvalue.h.

Referenced by normal3f(), and setNormal3f().

union vlVoxelOpValue::ReturnData_ vlVoxelOpValue::m_realValue [protected]
 

Other datatypes cannot be kept here because C++ does not allow storage of user defined datatypes with non-trivial constructor, destrcutor inside unions.

Referenced by dl(), i(), ptr(), setDl(), setI(), setPtr(), setUi(), ui(), and ~vlVoxelOpValue().

vlVector3f vlVoxelOpValue::m_vector3f [protected]
 

Definition at line 175 of file vlvoxelopvalue.h.

Referenced by setVector3f(), and vector3f().


The documentation for this class was generated from the following file:
Generated on Fri Mar 18 11:33:24 2005 for OpenVL by doxygen 1.3.3