File failed to load: https://isis.astrogeology.usgs.gov/dev/Object/assets/jax/output/NativeMML/config.js
Isis Developer Reference
Buffer.h
Go to the documentation of this file.
1#ifndef Buffer_h
2#define Buffer_h
7
8/* SPDX-License-Identifier: CC0-1.0 */
9
10#include "PixelType.h"
11
12namespace Isis {
53 class Buffer {
54 public:
55 Buffer();
56 Buffer(const int nsamps, const int nlines, const int nbands,
57 const Isis::PixelType type, const double scale = 1);
58
59 ~Buffer();
60
61 Buffer(const Buffer &);
62
63 Buffer &operator=(const double &d);
64
70 inline int SampleDimension() const {
71 return (p_nsamps);
72 }
73
79 inline int LineDimension() const {
80 return (p_nlines);
81 }
82
88 inline int SampleDimensionScaled() const {
89 return (p_nsampsScaled);
90 }
91
97 inline int LineDimensionScaled() const {
98 return (p_nlinesScaled);
99 }
100
106 inline int BandDimension() const {
107 return (p_nbands);
108 }
109
115 inline double scale() const {
116 return (p_scale);
117 }
118
124 inline int size() const {
125 return (p_npixels);
126 }
127
128 // Methods which return absolute coordinates relative to the buffer
129 int Sample(const int index = 0) const;
130 int Line(const int index = 0) const;
131 int Band(const int index = 0) const;
132 void Position(const int index, int &i_samp, int &i_line, int &i_band) const;
133 int Index(const int i_samp, const int i_line, const int i_band) const;
134
135 // Methods which give info about the buffer or its contents
136 double at(const int index) const;
137
145 inline double &operator[](const int index) {
146 return (p_buf[index]);
147 }
148
156 const double &operator[](const int index) const {
157 return (p_buf[index]);
158 }
159
165 inline double *DoubleBuffer() const {
166 return (p_buf);
167 };
168 void Copy(const Buffer &in, bool includeRawBuf = true);
169
170 bool CopyOverlapFrom(const Buffer &in);
171
178 void *RawBuffer() const {
179 return p_rawbuf;
180 };
181
188 return p_pixelType;
189 };
190
191 void SetBasePosition(const int start_sample, const int start_line,
192 const int start_band);
193
194 friend std::ostream &operator<<(std::ostream &os, Buffer &buffer);
195
196 protected:
202 inline void SetBaseSample(const int start_samp) {
203 p_sample = start_samp;
204 return;
205 }
206
212 inline void SetBaseLine(const int start_line) {
213 p_line = start_line;
214 return;
215 }
216
222 inline void SetBaseBand(const int start_band) {
223 p_band = start_band;
224 return;
225 }
226
230
231 int p_line;
234
235 int p_band;
237
239 double *p_buf;
241
243 void *p_rawbuf;
244
245 // Might need x and y scale
246 double p_scale;
247
248 void Allocate();
249
258 Buffer &operator=(const Buffer &rvalue) {
259 return const_cast<Buffer &>(rvalue);
260 };
261
262 };
263};
264
265#endif
Buffer for reading and writing cube data.
Definition Buffer.h:53
int size() const
Returns the total number of pixels in the shape buffer.
Definition Buffer.h:124
void * p_rawbuf
The raw dm read from the disk.
Definition Buffer.h:243
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:121
int Line(const int index=0) const
Returns the line position associated with a shape buffer index.
Definition Buffer.cpp:183
double * DoubleBuffer() const
Returns the value of the shape buffer.
Definition Buffer.h:165
void * RawBuffer() const
Returns a void pointer to the raw buffer.
Definition Buffer.h:178
int SampleDimensionScaled() const
Returns the number of samples in the shape buffer.
Definition Buffer.h:88
Buffer()
Default constructor for proper initialization purposes.
Definition Buffer.cpp:26
int p_npixels
Number of pixels (nsamps * nlines * scale ** 2) * bands.
Definition Buffer.h:238
int LineDimensionScaled() const
Returns the number of lines in the shape buffer.
Definition Buffer.h:97
int p_nlinesScaled
Definition Buffer.h:233
Buffer & operator=(const Buffer &rvalue)
Copy operator.
Definition Buffer.h:258
friend std::ostream & operator<<(std::ostream &os, Buffer &buffer)
This method is used to print out a buffer.
Definition Buffer.cpp:137
void Allocate()
Size or resize the memory buffer.
Definition Buffer.cpp:414
int LineDimension() const
Returns the number of lines in the shape buffer.
Definition Buffer.h:79
int p_nlines
Number of lines to read/write.
Definition Buffer.h:232
int p_nbands
Number of bands to read/write.
Definition Buffer.h:236
Buffer & operator=(const double &d)
Assign the entire buffer to a constant double value.
Definition Buffer.cpp:104
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:324
const double & operator[](const int index) const
Returns the value in the shape buffer at given index.
Definition Buffer.h:156
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:215
void SetBaseLine(const int start_line)
This method is used to set the base line position of the shape buffer.
Definition Buffer.h:212
double * p_buf
Shape buffer allocated to the size of npixels for handling reads/writes.
Definition Buffer.h:239
Isis::PixelType PixelType() const
Returns the raw buffer pixel type.
Definition Buffer.h:187
double scale() const
Returns the scale of the shape buffer.
Definition Buffer.h:115
double & operator[](const int index)
Returns the value in the shape buffer at given index.
Definition Buffer.h:145
int Band(const int index=0) const
Returns the band position associated with a shape buffer index.
Definition Buffer.cpp:200
int BandDimension() const
Returns the number of bands in the shape buffer.
Definition Buffer.h:106
int p_sample
Starting sample to read/write.
Definition Buffer.h:227
const Isis::PixelType p_pixelType
The pixel type of the raw buffer.
Definition Buffer.h:242
int SampleDimension() const
Returns the number of samples in the shape buffer.
Definition Buffer.h:70
int p_band
Starting band to read/write.
Definition Buffer.h:235
void Copy(const Buffer &in, bool includeRawBuf=true)
Allows copying of the buffer contents to another Buffer.
Definition Buffer.cpp:294
double at(const int index) const
Returns the value in the shape buffer at the given index.
Definition Buffer.cpp:270
int p_nsamps
Number of samples to read/write.
Definition Buffer.h:228
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:235
int p_line
Starting line to read/write.
Definition Buffer.h:231
int Sample(const int index=0) const
Returns the sample position associated with a shape buffer index.
Definition Buffer.cpp:165
void SetBaseBand(const int start_band)
This method is used to set the base band position of the shape buffer.
Definition Buffer.h:222
void SetBaseSample(const int start_samp)
This method is used to set the base sample position of the shape buffer.
Definition Buffer.h:202
~Buffer()
Destroys the Buffer object and frees shape buffer.
Definition Buffer.cpp:83
double p_scale
Amount to scale the buffers lines and samples, defaults to 1.
Definition Buffer.h:246
int p_nsampsScaled
Definition Buffer.h:229
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
PixelType
Enumerations for Isis Pixel Types.
Definition PixelType.h:29