Isis 3.0 Programmer Reference
Back | Home
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 {
68  class Buffer {
69  public:
70  Buffer();
71  Buffer(const int nsamps, const int nlines, const int nbands,
72  const Isis::PixelType type);
73 
74  ~Buffer();
75 
76  Buffer(const Buffer &);
77 
78  Buffer &operator=(const double &d);
79 
85  inline int SampleDimension() const {
86  return (p_nsamps);
87  }
88 
94  inline int LineDimension() const {
95  return (p_nlines);
96  }
97 
103  inline int BandDimension() const {
104  return (p_nbands);
105  }
106 
112  inline int size() const {
113  return (p_npixels);
114  }
115 
116  // Methods which return absolute coordinates relative to the buffer
117  int Sample(const int index = 0) const;
118  int Line(const int index = 0) const;
119  int Band(const int index = 0) const;
120  void Position(const int index, int &i_samp, int &i_line, int &i_band) const;
121  int Index(const int i_samp, const int i_line, const int i_band) const;
122 
123  // Methods which give info about the buffer or its contents
124  double at(const int index) const;
125 
133  inline double &operator[](const int index) {
134  return (p_buf[index]);
135  }
136 
144  const double &operator[](const int index) const {
145  return (p_buf[index]);
146  }
147 
153  inline double *DoubleBuffer() const {
154  return (p_buf);
155  };
156  void Copy(const Buffer &in, bool includeRawBuf = true);
157 
158  bool CopyOverlapFrom(const Buffer &in);
159 
166  void *RawBuffer() const {
167  return p_rawbuf;
168  };
169 
176  return p_pixelType;
177  };
178 
179  protected:
180  void SetBasePosition(const int start_sample, const int start_line,
181  const int start_band);
182 
188  inline void SetBaseSample(const int start_samp) {
189  p_sample = start_samp;
190  return;
191  }
192 
198  inline void SetBaseLine(const int start_line) {
199  p_line = start_line;
200  return;
201  }
202 
208  inline void SetBaseBand(const int start_band) {
209  p_band = start_band;
210  return;
211  }
212 
213  int p_sample;
214  int p_nsamps;
215 
216  int p_line;
217  int p_nlines;
218 
219  int p_band;
220  int p_nbands;
221 
222  int p_npixels;
223  double *p_buf;
227  void *p_rawbuf;
228 
229  void Allocate();
230 
239  Buffer &operator=(const Buffer &rvalue) {
240  return const_cast<Buffer &>(rvalue);
241  };
242 
243  };
244 };
245 
246 #endif
void Allocate()
Size or resize the memory buffer.
Definition: Buffer.cpp:354
Buffer for reading and writing cube data.
Definition: Buffer.h:68
int Line(const int index=0) const
Returns the line position associated with a shape buffer index.
Definition: Buffer.cpp:161
int LineDimension() const
Returns the number of lines in the shape buffer.
Definition: Buffer.h:94
int BandDimension() const
Returns the number of bands in the shape buffer.
Definition: Buffer.h:103
void SetBaseBand(const int start_band)
This method is used to set the base band position of the shape buffer.
Definition: Buffer.h:208
const Isis::PixelType p_pixelType
The pixel type of the raw buffer.
Definition: Buffer.h:226
void * p_rawbuf
The raw dm read from the disk.
Definition: Buffer.h:227
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 * DoubleBuffer() const
Returns the value of the shape buffer.
Definition: Buffer.h:153
void Copy(const Buffer &in, bool includeRawBuf=true)
Allows copying of the buffer contents to another Buffer.
Definition: Buffer.cpp:269
int p_line
Starting line to read/write.
Definition: Buffer.h:216
int Sample(const int index=0) const
Returns the sample position associated with a shape buffer index.
Definition: Buffer.cpp:143
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:133
~Buffer()
Destroys the Buffer object and frees shape buffer.
Definition: Buffer.cpp:84
void * RawBuffer() const
Returns a void pointer to the raw buffer.
Definition: Buffer.h:166
int p_sample
Starting sample to read/write.
Definition: Buffer.h:213
int p_npixels
Number of pixels (nsamps * nlines * nbands)
Definition: Buffer.h:222
int Band(const int index=0) const
Returns the band position associated with a shape buffer index.
Definition: Buffer.cpp:178
double * p_buf
Shape buffer allocated to the size of npixels for handling reads/writes.
Definition: Buffer.h:223
Isis::PixelType PixelType() const
Returns the raw buffer pixel type.
Definition: Buffer.h:175
int p_nbands
Number of bands to read/write.
Definition: Buffer.h:220
void SetBaseSample(const int start_samp)
This method is used to set the base sample position of the shape buffer.
Definition: Buffer.h:188
int p_band
Starting band to read/write.
Definition: Buffer.h:219
int p_nlines
Number of lines to read/write.
Definition: Buffer.h:217
void SetBaseLine(const int start_line)
This method is used to set the base line position of the shape buffer.
Definition: Buffer.h:198
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
int size() const
Returns the total number of pixels in the shape buffer.
Definition: Buffer.h:112
Buffer & operator=(const Buffer &rvalue)
Copy operator.
Definition: Buffer.h:239
Buffer()
Default constructor for proper initialization purposes.
Definition: Buffer.cpp:41
const double & operator[](const int index) const
Returns the value in the shape buffer at given index.
Definition: Buffer.h:144
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:214
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:299
int SampleDimension() const
Returns the number of samples in the shape buffer.
Definition: Buffer.h:85
Buffer & operator=(const double &d)
Assign the entire buffer to a constant double value.
Definition: Buffer.cpp:105
double at(const int index) const
Returns the value in the shape buffer at the given index.
Definition: Buffer.cpp:247

U.S. Department of the Interior | U.S. Geological Survey
ISIS | Privacy & Disclaimers | Astrogeology Research Program
To contact us, please post comments and questions on the ISIS Support Center
File Modified: 07/12/2023 23:14:56