|
Isis 3.0 Developer's Reference (API) |
Home |
00001 #ifndef Buffer_h 00002 #define Buffer_h 00003 00026 #include "PixelType.h" 00027 00028 namespace Isis { 00068 class Buffer { 00069 public: 00070 Buffer(); 00071 Buffer(const int nsamps, const int nlines, const int nbands, 00072 const Isis::PixelType type); 00073 00074 ~Buffer(); 00075 00076 Buffer(const Buffer &); 00077 00078 Buffer &operator=(const double &d); 00079 00085 inline int SampleDimension() const { 00086 return (p_nsamps); 00087 } 00088 00094 inline int LineDimension() const { 00095 return (p_nlines); 00096 } 00097 00103 inline int BandDimension() const { 00104 return (p_nbands); 00105 } 00106 00112 inline int size() const { 00113 return (p_npixels); 00114 } 00115 00116 // Methods which return absolute coordinates relative to the buffer 00117 int Sample(const int index = 0) const; 00118 int Line(const int index = 0) const; 00119 int Band(const int index = 0) const; 00120 void Position(const int index, int &i_samp, int &i_line, int &i_band) const; 00121 int Index(const int i_samp, const int i_line, const int i_band) const; 00122 00123 // Methods which give info about the buffer or its contents 00124 double at(const int index) const; 00125 00133 inline double &operator[](const int index) { 00134 return (p_buf[index]); 00135 } 00136 00144 const double &operator[](const int index) const { 00145 return (p_buf[index]); 00146 } 00147 00153 inline double *DoubleBuffer() const { 00154 return (p_buf); 00155 }; 00156 void Copy(const Buffer &in, bool includeRawBuf = true); 00157 00158 bool CopyOverlapFrom(const Buffer &in); 00159 00166 void *RawBuffer() const { 00167 return p_rawbuf; 00168 }; 00169 00175 Isis::PixelType PixelType() const { 00176 return p_pixelType; 00177 }; 00178 00179 protected: 00180 void SetBasePosition(const int start_sample, const int start_line, 00181 const int start_band); 00182 00188 inline void SetBaseSample(const int start_samp) { 00189 p_sample = start_samp; 00190 return; 00191 } 00192 00198 inline void SetBaseLine(const int start_line) { 00199 p_line = start_line; 00200 return; 00201 } 00202 00208 inline void SetBaseBand(const int start_band) { 00209 p_band = start_band; 00210 return; 00211 } 00212 00213 int p_sample; 00214 int p_nsamps; 00215 00216 int p_line; 00217 int p_nlines; 00218 00219 int p_band; 00220 int p_nbands; 00221 00222 int p_npixels; 00223 double *p_buf; 00226 const Isis::PixelType p_pixelType; 00227 void *p_rawbuf; 00228 00229 void Allocate(); 00230 00239 Buffer &operator=(const Buffer &rvalue) { 00240 return const_cast<Buffer &>(rvalue); 00241 }; 00242 00243 }; 00244 }; 00245 00246 #endif