Main Page   Class Overview   Pixels   Images   Geometry   Quick Index  

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

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