Isis 3 Programmer Reference
|
Buffer for reading and writing cube data. More...
#include <Buffer.h>
Public Member Functions | |
Buffer () | |
Default constructor for proper initialization purposes. More... | |
Buffer (const int nsamps, const int nlines, const int nbands, const Isis::PixelType type) | |
Creates a Buffer object. More... | |
~Buffer () | |
Destroys the Buffer object and frees shape buffer. More... | |
Buffer (const Buffer &) | |
The copy constructor. More... | |
Buffer & | operator= (const double &d) |
Assign the entire buffer to a constant double value. More... | |
int | SampleDimension () const |
Returns the number of samples in the shape buffer. More... | |
int | LineDimension () const |
Returns the number of lines in the shape buffer. More... | |
int | BandDimension () const |
Returns the number of bands in the shape buffer. More... | |
int | size () const |
Returns the total number of pixels in the shape buffer. More... | |
int | Sample (const int index=0) const |
Returns the sample position associated with a shape buffer index. More... | |
int | Line (const int index=0) const |
Returns the line position associated with a shape buffer index. More... | |
int | Band (const int index=0) const |
Returns the band position associated with a shape buffer index. More... | |
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. More... | |
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. More... | |
double | at (const int index) const |
Returns the value in the shape buffer at the given index. More... | |
double & | operator[] (const int index) |
Returns the value in the shape buffer at given index. More... | |
const double & | operator[] (const int index) const |
Returns the value in the shape buffer at given index. More... | |
double * | DoubleBuffer () const |
Returns the value of the shape buffer. More... | |
void | Copy (const Buffer &in, bool includeRawBuf=true) |
Allows copying of the buffer contents to another Buffer. More... | |
bool | CopyOverlapFrom (const Buffer &in) |
Allows copying of the buffer contents of a larger buffer to another same size or smaller Buffer, using their base positions to relate data. More... | |
void * | RawBuffer () const |
Returns a void pointer to the raw buffer. More... | |
Isis::PixelType | PixelType () const |
Returns the raw buffer pixel type. More... | |
Protected Member Functions | |
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. More... | |
void | SetBaseSample (const int start_samp) |
This method is used to set the base sample position of the shape buffer. More... | |
void | SetBaseLine (const int start_line) |
This method is used to set the base line position of the shape buffer. More... | |
void | SetBaseBand (const int start_band) |
This method is used to set the base band position of the shape buffer. More... | |
void | Allocate () |
Size or resize the memory buffer. More... | |
Buffer & | operator= (const Buffer &rvalue) |
Copy operator. More... | |
Protected Attributes | |
int | p_sample |
Starting sample to read/write. More... | |
int | p_nsamps |
Number of samples to read/write. More... | |
int | p_line |
Starting line to read/write. More... | |
int | p_nlines |
Number of lines to read/write. More... | |
int | p_band |
Starting band to read/write. More... | |
int | p_nbands |
Number of bands to read/write. More... | |
int | p_npixels |
Number of pixels (nsamps * nlines * nbands) More... | |
double * | p_buf |
Shape buffer allocated to the size of npixels for handling reads/writes. More... | |
const Isis::PixelType | p_pixelType |
The pixel type of the raw buffer. More... | |
void * | p_rawbuf |
The raw dm read from the disk. More... | |
Buffer for reading and writing cube data.
This is the base class for I/O on buffers of data from cubes. The programmer can define an arbitrary shape using this object and then read or write that shape from a cube. Some example shapes are lines, tiles, columns, cublets, and spectral pencils. Data which is read or written to a cube will always be contained within an internal buffer of type double. There are methods for querying the sample/line/band position based upon the buffer index. Note that this class does not read/write data but is used in conjunction with the class to read/write data. Even more powerful are the BufferManager classes which inherit this object and can step through cubes by line, tile, boxcar, column, etc.
If you would like to see Buffer being used in implementation, see circle.cpp
Isis::Buffer::Buffer | ( | ) |
Default constructor for proper initialization purposes.
This constructor is mostly useless but is needed so that it protects against improper usage.
Definition at line 25 of file Buffer.cpp.
Isis::Buffer::Buffer | ( | const int | nsamps, |
const int | nlines, | ||
const int | nbands, | ||
const Isis::PixelType | type | ||
) |
Creates a Buffer object.
Note that the number of pixels in the buffer can not exceed 2GB.
nsamps | Number of samples in shape. |
nlines | Number of lines in shape. |
nbands | Number of bands in shape. |
type | Raw buffer pixel type |
Isis::iException::Programmer | - Invalid value for a dimension |
Definition at line 41 of file Buffer.cpp.
References Allocate(), p_band, p_line, p_nbands, p_nlines, p_npixels, p_nsamps, p_sample, and Isis::IException::Programmer.
Isis::Buffer::~Buffer | ( | ) |
Destroys the Buffer object and frees shape buffer.
Definition at line 68 of file Buffer.cpp.
Isis::Buffer::Buffer | ( | const Buffer & | rhs | ) |
|
protected |
Size or resize the memory buffer.
Isis::iException::System | - Memory allocation failed |
Definition at line 340 of file Buffer.cpp.
References Isis::Message::MemoryAllocationFailed(), p_buf, p_npixels, p_pixelType, p_rawbuf, Isis::SizeOf(), and Isis::IException::Unknown.
Referenced by Buffer(), and Isis::Brick::Resize().
double Isis::Buffer::at | ( | const int | index | ) | const |
Returns the value in the shape buffer at the given index.
index | Index position in buffer. Out of bounds index is trapped. |
Isis::iException::Programmer | - Array Subscript not in range |
Definition at line 231 of file Buffer.cpp.
References Isis::Message::ArraySubscriptNotInRange(), p_buf, p_npixels, and Isis::IException::Programmer.
Referenced by Isis::CubeDataThreadTester::BrickChanged(), Isis::ViewportBuffer::DataReady(), Isis::ViewportBuffer::fillBuffer(), Isis::StatisticsTool::getStatistics(), Isis::CubeDataThreadTester::ReadBrick(), and Isis::CubeDataThreadTester::ReadWriteBrick().
int Isis::Buffer::Band | ( | const int | index = 0 | ) | const |
Returns the band position associated with a shape buffer index.
The shape buffer is one dimensional. Let us assume a nsamps=2, nlines=3, and nbands=2. Therefore the total size of the shape buffer is 12 and valid index values are 0-11. Indexes 0-5 will return band 1 and 6-11 will return band 2.
index | Shape buffer index to map to a band position. Defaults to 0. |
Definition at line 162 of file Buffer.cpp.
References p_band, p_nlines, and p_nsamps.
Referenced by Isis::CubeIoHandler::bufferLessThan(), CopyOverlapFrom(), Isis::CubeIoHandler::findIntersection(), Isis::SpectralDefinition2D::operator()(), Isis::ImageImporter::operator()(), Isis::ProcessByBrick::ProcessCubesFunctor< T >::operator()(), Isis::Average::operator()(), Isis::CubeDataThread::OverlapIndex(), Position(), Isis::CubeIoHandler::read(), Isis::ProcessRubberSheet::StartProcess(), Isis::CubeIoHandler::synchronousWrite(), Isis::CubeIoHandler::writeIntoDouble(), and Isis::CubeIoHandler::writeIntoRaw().
|
inline |
Returns the number of bands in the shape buffer.
Definition at line 88 of file Buffer.h.
References p_nbands.
Referenced by Isis::CubeIoHandler::bufferLessThan(), Isis::CubeIoHandler::findIntersection(), Isis::CubeIoHandler::read(), Isis::RegionalCachingAlgorithm::recommendChunksToFree(), Isis::Hillshade::shadedValue(), Isis::CubeIoHandler::synchronousWrite(), Isis::CubeIoHandler::writeIntoDouble(), and Isis::CubeIoHandler::writeIntoRaw().
void Isis::Buffer::Copy | ( | const Buffer & | in, |
bool | includeRawBuf = true |
||
) |
Allows copying of the buffer contents to another Buffer.
in | The Buffer to be copied. |
includeRawBuf | Whether to include raw dm read from disk |
Isis::iException::Programmer | - Input and Output buffers are not the same size |
Isis::iException::Programmer | - Input and Output buffers do not use the same pixel type |
Definition at line 255 of file Buffer.cpp.
References p_buf, p_npixels, p_pixelType, p_rawbuf, PixelType(), Isis::IException::Programmer, size(), and Isis::SizeOf().
Referenced by Buffer(), Isis::FileTool::copy(), Isis::Cube::copy(), and Isis::FileTool::saveAs_FullResolution().
bool Isis::Buffer::CopyOverlapFrom | ( | const Buffer & | in | ) |
Allows copying of the buffer contents of a larger buffer to another same size or smaller Buffer, using their base positions to relate data.
This does not copy the raw buffer.
in | The Buffer to be copied. |
Definition at line 285 of file Buffer.cpp.
References Band(), Index(), Line(), p_band, p_line, p_nbands, p_nlines, p_npixels, p_nsamps, p_sample, Sample(), and size().
|
inline |
Returns the value of the shape buffer.
Definition at line 138 of file Buffer.h.
References p_buf.
Referenced by Isis::AutoReg::ApplyGradientFilter(), Isis::Process::CalculateStatistics(), Isis::ControlPointEditWidget::demRadius(), Isis::QnetTool::demRadius(), Isis::Chip::Extract(), Isis::SpatialPlotTool::getSpatialStatistics(), Isis::SpectralPlotTool::getSpectralStatistics(), Isis::MosaicSceneItem::getStretch(), Isis::StretchTool::histFromCube(), Isis::Cube::histogram(), Isis::ImageHistogram::ImageHistogram(), Isis::DemShape::localRadius(), Isis::OverlapStatistics::OverlapStatistics(), Isis::Chip::Read(), Isis::HistogramTool::refreshPlot(), Isis::ProcessByQuickFilter::StartProcess(), Isis::Cube::statistics(), Isis::StretchTool::statsFromCube(), Isis::CubeIoHandler::writeIntoDouble(), and Isis::CubeIoHandler::writeIntoRaw().
int Isis::Buffer::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.
i_samp | Sample position. |
i_line | Line position. |
i_band | Band position. |
Isis::iException::Programmer | - Array Subscript not in range |
Definition at line 197 of file Buffer.cpp.
References Isis::Message::ArraySubscriptNotInRange(), p_band, p_line, p_nbands, p_nlines, p_nsamps, p_sample, and Isis::IException::Programmer.
Referenced by CopyOverlapFrom(), Isis::ViewportBuffer::fillBuffer(), Isis::CubeIoHandler::writeIntoDouble(), and Isis::CubeIoHandler::writeIntoRaw().
int Isis::Buffer::Line | ( | const int | index = 0 | ) | const |
Returns the line position associated with a shape buffer index.
The shape buffer is one dimensional. Let us assume a nsamps=2, nlines=3, and nbands=2. Therefore the total size of the shape buffer is 12 and valid index values are 0-11. Line(0), Line(1), Line(6) and Line(7), will return a 1, Line(2), Line(3), Line(8) and Line(9) will return a 2, and Line(4), Line(5), Line(10), and Line(11) will return a 3.
index | Shape buffer index to map to a line position. Defaults to 0 |
Definition at line 145 of file Buffer.cpp.
References p_line, p_nlines, and p_nsamps.
Referenced by Isis::CubeIoHandler::bufferLessThan(), CopyOverlapFrom(), Isis::CubeViewport::cubeDataChanged(), Isis::ViewportBuffer::DataReady(), Isis::Chip::Extract(), Isis::ViewportBuffer::fillBuffer(), Isis::CubeIoHandler::findIntersection(), Isis::ImageImporter::operator()(), Isis::Nearest::operator()(), Isis::Average::operator()(), Isis::CubeDataThread::OverlapIndex(), Position(), Isis::CubeIoHandler::read(), Isis::EditTool::redoEdit(), Isis::CubeIoHandler::synchronousWrite(), Isis::EditTool::undoEdit(), Isis::QtExporter::writeGrayscale(), Isis::StreamExporter::writeGrayscale(), Isis::QtExporter::writeRgb(), Isis::StreamExporter::writeRgb(), Isis::QtExporter::writeRgba(), Isis::StreamExporter::writeRgba(), and Isis::EditTool::writeToCube().
|
inline |
Returns the number of lines in the shape buffer.
Definition at line 79 of file Buffer.h.
References p_nlines.
Referenced by Isis::CubeIoHandler::bufferLessThan(), Isis::CubeViewport::cubeDataChanged(), Isis::ViewportBuffer::fillBuffer(), Isis::CubeIoHandler::findIntersection(), Isis::CubeIoHandler::read(), Isis::RegionalCachingAlgorithm::recommendChunksToFree(), Isis::EditTool::redoEdit(), Isis::Hillshade::shadedValue(), Isis::CubeIoHandler::synchronousWrite(), Isis::EditTool::undoEdit(), and Isis::EditTool::writeToCube().
Buffer & Isis::Buffer::operator= | ( | const double & | d | ) |
Assign the entire buffer to a constant double value.
d | Value to assign to the buffer |
Definition at line 89 of file Buffer.cpp.
|
inline |
|
inline |
|
inline |
Returns the raw buffer pixel type.
Definition at line 160 of file Buffer.h.
References p_pixelType.
Referenced by Copy().
void Isis::Buffer::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.
Performs the same function as the Sample, Line, and Band methods.
index | Shape buffer index to map to a band position. |
i_samp | Sample position in shape buffer at index. |
i_line | Line position in shape buffer at index |
i_band | Band position in shape buffer at index. |
Definition at line 177 of file Buffer.cpp.
|
inline |
Returns a void pointer to the raw buffer.
Cast this void pointer using information from the PixelType() method
Definition at line 151 of file Buffer.h.
References p_rawbuf.
Referenced by Isis::CubeIoHandler::writeIntoDouble().
int Isis::Buffer::Sample | ( | const int | index = 0 | ) | const |
Returns the sample position associated with a shape buffer index.
The shape buffer is one dimensional. Let us assume a nsamps=2, nlines=3, and nbands=2. Therefore the total size of the shape buffer is 12 and valid index values are 0-11. Sample(0), Sample(2), Sample(4), etc will return a 1 while Sample(1), Sample(3), Sample(5), etc will return a 2.
index | Shape buffer index to map to a sample position. Defaults to 0. |
Definition at line 127 of file Buffer.cpp.
References p_nsamps, and p_sample.
Referenced by Isis::CubeIoHandler::bufferLessThan(), CopyOverlapFrom(), Isis::CubeViewport::cubeDataChanged(), Isis::ViewportBuffer::DataReady(), Isis::Chip::Extract(), Isis::ViewportBuffer::fillBuffer(), Isis::CubeIoHandler::findIntersection(), Isis::SpectralDefinition2D::operator()(), Isis::CubeDataThread::OverlapIndex(), Position(), Isis::CubeIoHandler::read(), Isis::EditTool::redoEdit(), Isis::CubeIoHandler::synchronousWrite(), Isis::EditTool::undoEdit(), and Isis::EditTool::writeToCube().
|
inline |
Returns the number of samples in the shape buffer.
Definition at line 70 of file Buffer.h.
References p_nsamps.
Referenced by Isis::CubeIoHandler::bufferLessThan(), Isis::CubeViewport::cubeDataChanged(), Isis::ViewportBuffer::fillBuffer(), Isis::CubeIoHandler::findIntersection(), Isis::ImageImporter::operator()(), Isis::CubeIoHandler::read(), Isis::RegionalCachingAlgorithm::recommendChunksToFree(), Isis::EditTool::redoEdit(), Isis::Hillshade::shadedValue(), Isis::CubeIoHandler::synchronousWrite(), Isis::EditTool::undoEdit(), Isis::QtExporter::writeGrayscale(), Isis::StreamExporter::writeGrayscale(), Isis::QtExporter::writeRgb(), Isis::StreamExporter::writeRgb(), Isis::QtExporter::writeRgba(), Isis::StreamExporter::writeRgba(), and Isis::EditTool::writeToCube().
|
inlineprotected |
This method is used to set the base band position of the shape buffer.
start_band | Starting band to set |
Definition at line 193 of file Buffer.h.
References p_band.
Referenced by Isis::Brick::SetBaseBand(), and SetBasePosition().
|
inlineprotected |
This method is used to set the base line position of the shape buffer.
start_line | Starting line to set |
Definition at line 183 of file Buffer.h.
References p_line.
Referenced by Isis::Brick::SetBaseLine(), and SetBasePosition().
|
protected |
This method is used to set the base position of the shape buffer.
In general it is used by BufferManager objects to progress sequentially through a cube by line, tile, boxcar, etc.
start_sample | Starting sample to set. |
start_line | Starting line to set. |
start_band | Starting band to set. |
Definition at line 106 of file Buffer.cpp.
References SetBaseBand(), SetBaseLine(), and SetBaseSample().
Referenced by Isis::Brick::SetBasePosition(), Isis::BufferManager::setpos(), and Isis::Portal::SetPosition().
|
inlineprotected |
This method is used to set the base sample position of the shape buffer.
start_samp | Starting sample to set |
Definition at line 173 of file Buffer.h.
References p_sample.
Referenced by SetBasePosition(), and Isis::Brick::SetBaseSample().
|
inline |
Returns the total number of pixels in the shape buffer.
Definition at line 97 of file Buffer.h.
References p_npixels.
Referenced by Isis::ProcessMosaic::BandComparison(), Isis::CubeDataThreadTester::BrickChanged(), Isis::Process::CalculateStatistics(), Copy(), CopyOverlapFrom(), Isis::ViewportBuffer::DataReady(), Isis::Chip::Extract(), Isis::ViewportBuffer::fillBuffer(), Isis::ProcessMapMosaic::FillNull(), Isis::CubeIoHandler::getNullChunk(), Isis::MosaicSceneItem::getStretch(), Isis::Cube::histogram(), Isis::ImageHistogram::ImageHistogram(), Isis::ProcessExport::isisOut16s(), Isis::ProcessExport::isisOut16u(), Isis::ProcessExport::isisOut32(), Isis::ProcessExport::isisOut8(), Isis::Average::operator()(), Isis::CubeDataThread::OverlapIndex(), Isis::Calculator::Push(), Isis::CubeIoHandler::read(), Isis::CubeDataThreadTester::ReadBrick(), Isis::CubeDataThreadTester::ReadWriteBrick(), Isis::ProcessMosaic::ResetCountBands(), Isis::ScatterPlotData::ScatterPlotData(), Isis::Hillshade::shadedValue(), Isis::AutoReg::SobelGradient(), Isis::ProcessMosaic::StartProcess(), Isis::ProcessExport::StartProcess(), Isis::ProcessByBoxcar::StartProcess(), Isis::Cube::statistics(), and Isis::EditTool::writeToCube().
|
protected |
Starting band to read/write.
Definition at line 204 of file Buffer.h.
Referenced by Band(), Buffer(), CopyOverlapFrom(), Index(), and SetBaseBand().
|
protected |
Shape buffer allocated to the size of npixels for handling reads/writes.
Definition at line 208 of file Buffer.h.
Referenced by Allocate(), at(), Copy(), DoubleBuffer(), operator=(), operator[](), Isis::Brick::Resize(), and ~Buffer().
|
protected |
Starting line to read/write.
Definition at line 201 of file Buffer.h.
Referenced by Buffer(), CopyOverlapFrom(), Index(), Line(), and SetBaseLine().
|
protected |
Number of bands to read/write.
Definition at line 205 of file Buffer.h.
Referenced by BandDimension(), Buffer(), CopyOverlapFrom(), Index(), and Isis::Brick::Resize().
|
protected |
Number of lines to read/write.
Definition at line 202 of file Buffer.h.
Referenced by Band(), Buffer(), CopyOverlapFrom(), Index(), Line(), LineDimension(), and Isis::Brick::Resize().
|
protected |
Number of pixels (nsamps * nlines * nbands)
Definition at line 207 of file Buffer.h.
Referenced by Allocate(), at(), Buffer(), Copy(), CopyOverlapFrom(), operator=(), Isis::Brick::Resize(), and size().
|
protected |
Number of samples to read/write.
Definition at line 199 of file Buffer.h.
Referenced by Band(), Buffer(), CopyOverlapFrom(), Index(), Line(), Isis::Brick::Resize(), Sample(), and SampleDimension().
|
protected |
The pixel type of the raw buffer.
Definition at line 211 of file Buffer.h.
Referenced by Allocate(), Copy(), and PixelType().
|
protected |
The raw dm read from the disk.
Definition at line 212 of file Buffer.h.
Referenced by Allocate(), Copy(), RawBuffer(), Isis::Brick::Resize(), and ~Buffer().
|
protected |
Starting sample to read/write.
Definition at line 198 of file Buffer.h.
Referenced by Buffer(), CopyOverlapFrom(), Index(), Sample(), and SetBaseSample().