Isis 3 Developer Reference
Buffer.h
Go to the documentation of this file.
1 #ifndef Buffer_h
2 #define Buffer_h
3 
26 #include "PixelType.h"
27 
28 namespace Isis {
69  class Buffer {
70  public:
71  Buffer();
72  Buffer(const int nsamps, const int nlines, const int nbands,
73  const Isis::PixelType type);
74 
75  ~Buffer();
76 
77  Buffer(const Buffer &);
78 
79  Buffer &operator=(const double &d);
80 
86  inline int SampleDimension() const {
87  return (p_nsamps);
88  }
89 
95  inline int LineDimension() const {
96  return (p_nlines);
97  }
98 
104  inline int BandDimension() const {
105  return (p_nbands);
106  }
107 
113  inline int size() const {
114  return (p_npixels);
115  }
116 
117  // Methods which return absolute coordinates relative to the buffer
118  int Sample(const int index = 0) const;
119  int Line(const int index = 0) const;
120  int Band(const int index = 0) const;
121  void Position(const int index, int &i_samp, int &i_line, int &i_band) const;
122  int Index(const int i_samp, const int i_line, const int i_band) const;
123 
124  // Methods which give info about the buffer or its contents
125  double at(const int index) const;
126 
134  inline double &operator[](const int index) {
135  return (p_buf[index]);
136  }
137 
145  const double &operator[](const int index) const {
146  return (p_buf[index]);
147  }
148 
154  inline double *DoubleBuffer() const {
155  return (p_buf);
156  };
157  void Copy(const Buffer &in, bool includeRawBuf = true);
158 
159  bool CopyOverlapFrom(const Buffer &in);
160 
167  void *RawBuffer() const {
168  return p_rawbuf;
169  };
170 
177  return p_pixelType;
178  };
179 
180  protected:
181  void SetBasePosition(const int start_sample, const int start_line,
182  const int start_band);
183 
189  inline void SetBaseSample(const int start_samp) {
190  p_sample = start_samp;
191  return;
192  }
193 
199  inline void SetBaseLine(const int start_line) {
200  p_line = start_line;
201  return;
202  }
203 
209  inline void SetBaseBand(const int start_band) {
210  p_band = start_band;
211  return;
212  }
213 
214  int p_sample;
215  int p_nsamps;
216 
217  int p_line;
218  int p_nlines;
219 
220  int p_band;
221  int p_nbands;
222 
223  int p_npixels;
224  double *p_buf;
228  void *p_rawbuf;
229 
230  void Allocate();
231 
240  Buffer &operator=(const Buffer &rvalue) {
241  return const_cast<Buffer &>(rvalue);
242  };
243 
244  };
245 };
246 
247 #endif
void Allocate()
Size or resize the memory buffer.
Definition: Buffer.cpp:356
Buffer for reading and writing cube data.
Definition: Buffer.h:69
double * DoubleBuffer() const
Returns the value of the shape buffer.
Definition: Buffer.h:154
int Band(const int index=0) const
Returns the band position associated with a shape buffer index.
Definition: Buffer.cpp:178
void * RawBuffer() const
Returns a void pointer to the raw buffer.
Definition: Buffer.h:167
void SetBaseBand(const int start_band)
This method is used to set the base band position of the shape buffer.
Definition: Buffer.h:209
const Isis::PixelType p_pixelType
The pixel type of the raw buffer.
Definition: Buffer.h:227
void * p_rawbuf
The raw dm read from the disk.
Definition: Buffer.h:228
void SetBasePosition(const int start_sample, const int start_line, const int start_band)
This method is used to set the base position of the shape buffer.
Definition: Buffer.cpp:122
double at(const int index) const
Returns the value in the shape buffer at the given index.
Definition: Buffer.cpp:247
void Copy(const Buffer &in, bool includeRawBuf=true)
Allows copying of the buffer contents to another Buffer.
Definition: Buffer.cpp:271
int p_line
Starting line to read/write.
Definition: Buffer.h:217
int LineDimension() const
Returns the number of lines in the shape buffer.
Definition: Buffer.h:95
int size() const
Returns the total number of pixels in the shape buffer.
Definition: Buffer.h:113
PixelType
Enumerations for Isis Pixel Types.
Definition: PixelType.h:43
double & operator[](const int index)
Returns the value in the shape buffer at given index.
Definition: Buffer.h:134
~Buffer()
Destroys the Buffer object and frees shape buffer.
Definition: Buffer.cpp:84
int p_sample
Starting sample to read/write.
Definition: Buffer.h:214
int p_npixels
Number of pixels (nsamps * nlines * nbands)
Definition: Buffer.h:223
int Sample(const int index=0) const
Returns the sample position associated with a shape buffer index.
Definition: Buffer.cpp:143
Isis::PixelType PixelType() const
Returns the raw buffer pixel type.
Definition: Buffer.h:176
int BandDimension() const
Returns the number of bands in the shape buffer.
Definition: Buffer.h:104
double * p_buf
Shape buffer allocated to the size of npixels for handling reads/writes.
Definition: Buffer.h:224
int Line(const int index=0) const
Returns the line position associated with a shape buffer index.
Definition: Buffer.cpp:161
int p_nbands
Number of bands to read/write.
Definition: Buffer.h:221
const double & operator[](const int index) const
Returns the value in the shape buffer at given index.
Definition: Buffer.h:145
void SetBaseSample(const int start_samp)
This method is used to set the base sample position of the shape buffer.
Definition: Buffer.h:189
int p_band
Starting band to read/write.
Definition: Buffer.h:220
int p_nlines
Number of lines to read/write.
Definition: Buffer.h:218
void SetBaseLine(const int start_line)
This method is used to set the base line position of the shape buffer.
Definition: Buffer.h:199
int SampleDimension() const
Returns the number of samples in the shape buffer.
Definition: Buffer.h:86
Buffer & operator=(const Buffer &rvalue)
Copy operator.
Definition: Buffer.h:240
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
Buffer()
Default constructor for proper initialization purposes.
Definition: Buffer.cpp:41
int Index(const int i_samp, const int i_line, const int i_band) const
Given a sample, line, and band position, this returns the appropriate index in the shape buffer...
Definition: Buffer.cpp:213
void Position(const int index, int &i_samp, int &i_line, int &i_band) const
Returns the sample, line, and band position associated with a shape buffer index. ...
Definition: Buffer.cpp:193
int p_nsamps
Number of samples to read/write.
Definition: Buffer.h:215
bool CopyOverlapFrom(const Buffer &in)
Allows copying of the buffer contents of a larger buffer to another same size or smaller Buffer...
Definition: Buffer.cpp:301
Buffer & operator=(const double &d)
Assign the entire buffer to a constant double value.
Definition: Buffer.cpp:105