Main Page   Class Overview   Pixels   Images   Geometry   Quick Index  

HxDataPtr2dTem.h

00001 /*
00002  *  Copyright (c) 1996, University of Amsterdam, The Netherlands.
00003  *  All rights reserved.
00004  *
00005  *
00006  *  Author(s):
00007  *  Dennis Koelma (koelma@wins.uva.nl)
00008  *  Edo Poll (poll@wins.uva.nl)
00009  */
00010 
00011 #ifndef HxDataPtr2dTem_h
00012 #define HxDataPtr2dTem_h
00013 
00014 #include <stddef.h>
00015 #include "HxIncludedNonnative.h"
00016 
00017 template<class PixelT, class ArithT>
00018 class HxDataPtr2dTem {
00019 public:
00020                             HxDataPtr2dTem(PixelT* data, int width);
00021                             HxDataPtr2dTem(PixelT* data, size_t* size);
00022                             HxDataPtr2dTem(const HxDataPtr2dTem& rhs);
00023 
00024     HxDataPtr2dTem&         operator=(const HxDataPtr2dTem& rhs);
00025 
00026     void                    incX(); // will increase y when x > width
00027     void                    decX(); // will decrease y when x < 0
00028     void                    incY();
00029     void                    decY();
00030     void                    incZ();
00031     void                    decZ();
00032     void                    incX(int off);
00033     void                    decX(int off);
00034     void                    incY(int off);
00035     void                    decY(int off);
00036 
00037     void                    incXYZ(int xOff, int yOff, int zOff = 0);
00038     void                    decXYZ(int xOff, int yOff, int zOff = 0);
00039 
00040     ArithT                  read();
00041     void                    write(const ArithT& val);
00042     ArithT                  readIncX() { return ArithT(*_ptr++); }
00043     void                    writeIncX(const ArithT& val)
00044                                 { *_ptr++ = PixelT(val); }
00045 
00046     void                    vprint();
00047 
00048     PixelT*                 data() { return _ptr; }
00049 
00050 private:
00051     int                     _width;
00052     PixelT*                 _ptr;
00053 };
00054 
00055 template<class PixelT, class ArithT>
00056 inline
00057 HxDataPtr2dTem<PixelT,ArithT>::HxDataPtr2dTem(PixelT* data, int width)
00058 {
00059     _width = width;
00060     _ptr = data;
00061 }
00062 
00063 template<class PixelT, class ArithT>
00064 inline
00065 HxDataPtr2dTem<PixelT,ArithT>::HxDataPtr2dTem(
00066     PixelT* data, size_t* size)
00067 {
00068     _width = size[0];
00069     _ptr = data;
00070 }
00071 
00072 template<class PixelT, class ArithT>
00073 inline
00074 HxDataPtr2dTem<PixelT,ArithT>::HxDataPtr2dTem(const HxDataPtr2dTem& rhs)
00075 {
00076     _width = rhs._width;
00077     _ptr = rhs._ptr;
00078 }
00079 
00080 template<class PixelT, class ArithT>
00081 inline HxDataPtr2dTem<PixelT,ArithT>&
00082 HxDataPtr2dTem<PixelT,ArithT>::operator=(const HxDataPtr2dTem& rhs)
00083 {
00084     _width = rhs._width;
00085     _ptr = rhs._ptr;
00086     return *this;
00087 }
00088 
00089 template<class PixelT, class ArithT>
00090 inline void
00091 HxDataPtr2dTem<PixelT,ArithT>::incX()
00092 {
00093     _ptr++;
00094 }
00095 
00096 template<class PixelT, class ArithT>
00097 inline void
00098 HxDataPtr2dTem<PixelT,ArithT>::decX()
00099 {
00100     _ptr--;
00101 }
00102 
00103 template<class PixelT, class ArithT>
00104 inline void
00105 HxDataPtr2dTem<PixelT,ArithT>::incY()
00106 {
00107     _ptr += _width;
00108 }
00109 
00110 template<class PixelT, class ArithT>
00111 inline void
00112 HxDataPtr2dTem<PixelT,ArithT>::decY()
00113 {
00114     _ptr -= _width;
00115 }
00116 
00117 template<class PixelT, class ArithT>
00118 inline void
00119 HxDataPtr2dTem<PixelT,ArithT>::incZ()
00120 {
00121 }
00122 
00123 template<class PixelT, class ArithT>
00124 inline void
00125 HxDataPtr2dTem<PixelT,ArithT>::decZ()
00126 {
00127 }
00128 
00129 template<class PixelT, class ArithT>
00130 inline void
00131 HxDataPtr2dTem<PixelT,ArithT>::incX(int off)
00132 {
00133     _ptr += off;
00134 }
00135 
00136 template<class PixelT, class ArithT>
00137 inline void
00138 HxDataPtr2dTem<PixelT,ArithT>::decX(int off)
00139 {
00140     _ptr -= off;
00141 }
00142 
00143 template<class PixelT, class ArithT>
00144 inline void
00145 HxDataPtr2dTem<PixelT,ArithT>::incY(int off)
00146 {
00147     _ptr += off * _width;
00148 }
00149 
00150 template<class PixelT, class ArithT>
00151 inline void
00152 HxDataPtr2dTem<PixelT,ArithT>::decY(int off)
00153 {
00154     _ptr -= off * _width;
00155 }
00156 
00157 template<class PixelT, class ArithT>
00158 inline void
00159 HxDataPtr2dTem<PixelT,ArithT>::incXYZ(int xOff, int yOff, int)
00160 {
00161     _ptr += yOff * _width + xOff;
00162 }
00163 
00164 template<class PixelT, class ArithT>
00165 inline void
00166 HxDataPtr2dTem<PixelT,ArithT>::decXYZ(int xOff, int yOff, int)
00167 {
00168     _ptr -= yOff * _width + xOff;
00169 }
00170 
00171 template<class PixelT, class ArithT>
00172 inline ArithT
00173 HxDataPtr2dTem<PixelT,ArithT>::read()
00174 {
00175     return ArithT(*_ptr);
00176 }
00177 
00178 template<class PixelT, class ArithT>
00179 inline void
00180 HxDataPtr2dTem<PixelT,ArithT>::write(const ArithT& val)
00181 {
00182     *_ptr = PixelT(val);
00183 }
00184 
00185 #endif

Generated on Tue Jan 8 13:59:11 2002 for C++Reference by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001