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

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