Horus Doc || C++ Reference || Class Overview   Pixels   Images   Detector   Geometry   Registry || Doxygen's 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 
00020 template<class PixelT, class ArithT>
00021 class HxDataPtr2dTem {
00022 public:
00023                             HxDataPtr2dTem(PixelT* data, int width);
00024                             HxDataPtr2dTem(PixelT* data, size_t* size);
00025                             HxDataPtr2dTem(const HxDataPtr2dTem& rhs);
00026 
00027     HxDataPtr2dTem&         operator=(const HxDataPtr2dTem& rhs);
00028 
00029     void                    incX(); // will increase y when x > width
00030     void                    decX(); // will decrease y when x < 0
00031     void                    incY();
00032     void                    decY();
00033     void                    incZ();
00034     void                    decZ();
00035     void                    incX(int off);
00036     void                    decX(int off);
00037     void                    incY(int off);
00038     void                    decY(int off);
00039 
00040     void                    incXYZ(int xOff, int yOff, int zOff = 0);
00041     void                    decXYZ(int xOff, int yOff, int zOff = 0);
00042 
00043     ArithT                  read();
00044     void                    write(const ArithT& val);
00045     ArithT                  readIncX() { return ArithT(*_ptr++); }
00046     void                    writeIncX(const ArithT& val)
00047                                 { *_ptr++ = PixelT(val); }
00048 
00049     PixelT*                 data();
00050 
00051     void                    vprint();
00052     void                    vprint(HxDataPtr2dTem reference);
00053 
00054 private:
00055     int                     _width;
00056     PixelT*                 _ptr;
00057 };
00058 
00059 template<class PixelT, class ArithT>
00060 inline
00061 HxDataPtr2dTem<PixelT,ArithT>::HxDataPtr2dTem(PixelT* data, int width)
00062 {
00063     _width = width;
00064     _ptr = data;
00065 }
00066 
00067 template<class PixelT, class ArithT>
00068 inline
00069 HxDataPtr2dTem<PixelT,ArithT>::HxDataPtr2dTem(
00070     PixelT* data, size_t* size)
00071 {
00072     _width = size[0];
00073     _ptr = data;
00074 }
00075 
00076 template<class PixelT, class ArithT>
00077 inline
00078 HxDataPtr2dTem<PixelT,ArithT>::HxDataPtr2dTem(const HxDataPtr2dTem& rhs)
00079 {
00080     _width = rhs._width;
00081     _ptr = rhs._ptr;
00082 }
00083 
00084 template<class PixelT, class ArithT>
00085 inline HxDataPtr2dTem<PixelT,ArithT>&
00086 HxDataPtr2dTem<PixelT,ArithT>::operator=(const HxDataPtr2dTem& 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 HxDataPtr2dTem<PixelT,ArithT>::incX()
00096 {
00097     _ptr++;
00098 }
00099 
00100 template<class PixelT, class ArithT>
00101 inline void
00102 HxDataPtr2dTem<PixelT,ArithT>::decX()
00103 {
00104     _ptr--;
00105 }
00106 
00107 template<class PixelT, class ArithT>
00108 inline void
00109 HxDataPtr2dTem<PixelT,ArithT>::incY()
00110 {
00111     _ptr += _width;
00112 }
00113 
00114 template<class PixelT, class ArithT>
00115 inline void
00116 HxDataPtr2dTem<PixelT,ArithT>::decY()
00117 {
00118     _ptr -= _width;
00119 }
00120 
00121 template<class PixelT, class ArithT>
00122 inline void
00123 HxDataPtr2dTem<PixelT,ArithT>::incZ()
00124 {
00125 }
00126 
00127 template<class PixelT, class ArithT>
00128 inline void
00129 HxDataPtr2dTem<PixelT,ArithT>::decZ()
00130 {
00131 }
00132 
00133 template<class PixelT, class ArithT>
00134 inline void
00135 HxDataPtr2dTem<PixelT,ArithT>::incX(int off)
00136 {
00137     _ptr += off;
00138 }
00139 
00140 template<class PixelT, class ArithT>
00141 inline void
00142 HxDataPtr2dTem<PixelT,ArithT>::decX(int off)
00143 {
00144     _ptr -= off;
00145 }
00146 
00147 template<class PixelT, class ArithT>
00148 inline void
00149 HxDataPtr2dTem<PixelT,ArithT>::incY(int off)
00150 {
00151     _ptr += off * _width;
00152 }
00153 
00154 template<class PixelT, class ArithT>
00155 inline void
00156 HxDataPtr2dTem<PixelT,ArithT>::decY(int off)
00157 {
00158     _ptr -= off * _width;
00159 }
00160 
00161 template<class PixelT, class ArithT>
00162 inline void
00163 HxDataPtr2dTem<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 HxDataPtr2dTem<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 HxDataPtr2dTem<PixelT,ArithT>::read()
00178 {
00179     return ArithT(*_ptr);
00180 }
00181 
00182 template<class PixelT, class ArithT>
00183 inline void
00184 HxDataPtr2dTem<PixelT,ArithT>::write(const ArithT& val)
00185 {
00186     *_ptr = PixelT(val);
00187 }
00188 
00189 template<class PixelT, class ArithT>
00190 inline PixelT*
00191 HxDataPtr2dTem<PixelT,ArithT>::data()
00192 {
00193     return _ptr;
00194 }
00195 
00196 #ifdef INC_TEMPLATE_SRC
00197 #include "HxDataPtr2dTem.c"
00198 #endif
00199 
00200 #endif

Generated on Tue Feb 3 14:18:33 2004 for C++Reference by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001