USGS

Isis 3.0 Developer's Reference (API)

Home

Isis::SampleManager Class Reference
[Low Level Cube I/O]

Buffer manager, for moving through a cube in samples. More...

#include <SampleManager.h>

Inherits Isis::BufferManager.

List of all members.

Public Member Functions

 SampleManager (const Isis::Cube &cube, const bool reverse=false)
 Constructs a SampleManager object.
 ~SampleManager ()
 Destroys the SampleManager object.
bool SetSample (const int sample, const int band=1)
 Positions the buffer at the requested line and returns a status indicator if the set was succesful or not.
bool operator++ (int)
 Moves the shape buffer to the next position.
bool begin ()
 Moves the shape buffer to the first position.
bool next ()
 Moves the shape buffer to the next position.
bool end () const
 Returns true if the shape buffer has accessed the end of the cube.
int SampleDimension () const
 Returns the number of samples in the shape buffer.
int LineDimension () const
 Returns the number of lines in the shape buffer.
int BandDimension () const
 Returns the number of bands in the shape buffer.
int size () const
 Returns the total number of pixels in the shape buffer.
int Sample (const int index=0) const
 Returns the sample position associated with a shape buffer index.
int Line (const int index=0) const
 Returns the line position associated with a shape buffer index.
int Band (const int index=0) const
 Returns the band position associated with a shape buffer index.
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.
int Index (const int i_samp, const int i_line, const int i_band) const throw (Isis::iException &)
 Given a sample, line, and band position, this returns the appropriate index in the shape buffer.
double at (const int index) const
 Returns the value in the shape buffer at the given index.
double & operator[] (const int index)
 Returns the value in the shape buffer at given index.
const double & operator[] (const int index) const
 Returns the value in the shape buffer at given index.
double * DoubleBuffer () const
 Returns the value of the shape buffer.
void Copy (const Buffer &in)
 Allows copying of the buffer contents to another Buffer.
void * RawBuffer () const
 Returns a void pointer to the raw buffer.
Isis::PixelType PixelType () const
 Returns the raw buffer pixel type.

Protected Member Functions

bool setpos (const BigInt map)
 Sets the position of the shape in the cube.
int MaxSamples () const
 Returns the number of samples in the cube.
int MaxLines () const
 Returns the number of lines in the cube.
int MaxBands () const
 Returns the number of bands in the cube.
BigInt MaxMaps () const
 Returns the maximum number of positions the shape buffer needs to cover the entire image (see setpos method for more info).
void SetIncrements (const int sinc, const int linc, const int binc)
 Sets how the shape is incremented through the cube.
void SetOffsets (const int soff, const int loff, const int boff)
 Sets the offset of the buffer.
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.
void SetBaseSample (const int start_samp)
 This method is used to set the base sample position of the shape buffer.
void SetBaseLine (const int start_line)
 This method is used to set the base line position of the shape buffer.
void SetBaseBand (const int start_band)
 This method is used to set the base band position of the shape buffer.
void Allocate ()
 Size or resize the memory buffer.

Protected Attributes

int p_sample
 Starting sample to read/write.
int p_nsamps
 Number of samples to read/write.
int p_line
 Starting line to read/write.
int p_nlines
 Number of lines to read/write.
int p_band
 Starting band to read/write.
int p_nbands
 Number of bands to read/write.
int p_npixels
 Number of pixels (nsamps * nlines * nbands).
double * p_buf
 Shape buffer allocated to the size of npixels for handling reads/writes.
const Isis::PixelType p_pixelType
 The pixel type of the raw buffer.
void * p_rawbuf
 The raw dm read from the disk.

Detailed Description

Buffer manager, for moving through a cube in samples.

This class is used as a manager for moving through a cube one sample buffer at a time. A sample buffer is defined as a one dimensional sub-area of a cube. That is, the number of lines by 1 sample by 1 band (1,nl,1). The manager moves this (1,nl,1) shape through the cube sequentially accessing all the sample buffer in the first band before proceeding to the second band.

Author:
2007-12-06 Christopher Austin

Constructor & Destructor Documentation

Isis::SampleManager::SampleManager ( const Isis::Cube cube,
const bool  reverse = false 
)

Constructs a SampleManager object.

Parameters:
cube The cube this buffer manager will be associated with.
reverse Modifies the order of progression SampleManager takes through the cube. By default, progresses samples first then bands. If reverse = true, then the buffer progresses bands first, then samples.
Isis::SampleManager::~SampleManager (  )  [inline]

Destroys the SampleManager object.


Member Function Documentation

void Isis::Buffer::Allocate (  )  [protected, inherited]
double Isis::Buffer::at ( const int  index  )  const [inherited]

Returns the value in the shape buffer at the given index.

Parameters:
index Index position in buffer. Out of bounds index is trapped.
Returns:
double Buffer value at index
Exceptions:
Isis::iException::Programmer - Array Subscript not in range

References _FILEINFO_, Isis::Message::ArraySubscriptNotInRange(), Isis::iException::Message(), Isis::Buffer::p_buf, Isis::Buffer::p_npixels, and Isis::iException::Programmer.

int Isis::Buffer::Band ( const int  index = 0  )  const [inherited]

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.

Parameters:
index Shape buffer index to map to a band position. Defaults to 0.
Returns:
int The absolute band number based on the buffer index.

References Isis::Buffer::p_band, Isis::Buffer::p_nlines, and Isis::Buffer::p_nsamps.

Referenced by Isis::Average::operator()(), Isis::Equalization::ApplyFunctor::operator()(), Isis::Buffer::Position(), Isis::CubeIoHandler::read(), and Isis::CubeIoHandler::write().

int Isis::Buffer::BandDimension (  )  const [inline, inherited]

Returns the number of bands in the shape buffer.

Returns:
int

References Isis::Buffer::p_nbands.

Referenced by Isis::CubeIoHandler::read(), Isis::RegionalCachingAlgorithm::recommendChunksToFree(), and Isis::CubeIoHandler::write().

bool Isis::BufferManager::begin (  )  [inline, inherited]

Moves the shape buffer to the first position.

Returns:
bool

References Isis::BufferManager::setpos().

Referenced by Isis::ProcessExport::StartProcess(), and Isis::ProcessExport::StartProcessBIP().

void Isis::Buffer::Copy ( const Buffer in  )  [inherited]

Allows copying of the buffer contents to another Buffer.

Parameters:
in The Buffer to be copied.
Exceptions:
Isis::iException::Programmer - Input and Output buffers are not the same size

References _FILEINFO_, Isis::iException::Message(), Isis::Buffer::p_buf, Isis::Buffer::p_npixels, Isis::Buffer::p_pixelType, Isis::Buffer::p_rawbuf, Isis::Buffer::PixelType(), Isis::iException::Programmer, Isis::Buffer::size(), and Isis::SizeOf().

Referenced by Isis::Buffer::Buffer().

double* Isis::Buffer::DoubleBuffer (  )  const [inline, inherited]

Returns the value of the shape buffer.

Returns:
double* The shape buffer

References Isis::Buffer::p_buf.

Referenced by Isis::Sensor::DemRadius().

bool Isis::BufferManager::end (  )  const [inline, inherited]

Returns true if the shape buffer has accessed the end of the cube.

Returns:
bool

Referenced by Isis::BufferManager::setpos(), and Isis::ProcessExport::StartProcess().

int Isis::Buffer::Index ( const int  i_samp,
const int  i_line,
const int  i_band 
) const throw (Isis::iException &) [inherited]

Given a sample, line, and band position, this returns the appropriate index in the shape buffer.

Parameters:
i_samp Sample position.
i_line Line position.
i_band Band position.
Returns:
int Index at the specified sample, line and band.
Exceptions:
Isis::iException::Programmer - Array Subscript not in range

References _FILEINFO_, Isis::Message::ArraySubscriptNotInRange(), Isis::iException::Message(), and Isis::iException::Programmer.

int Isis::Buffer::Line ( const int  index = 0  )  const [inherited]

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.

Parameters:
index Shape buffer index to map to a line position. Defaults to 0
Returns:
int The absolute line number based on the buffer index

References Isis::Buffer::p_line, Isis::Buffer::p_nlines, and Isis::Buffer::p_nsamps.

Referenced by Isis::Average::operator()(), Isis::Nearest::operator()(), Isis::Buffer::Position(), Isis::CubeIoHandler::read(), and Isis::CubeIoHandler::write().

int Isis::Buffer::LineDimension (  )  const [inline, inherited]
int Isis::BufferManager::MaxBands (  )  const [inline, protected, inherited]

Returns the number of bands in the cube.

Returns:
int

Referenced by Isis::BandManager::SetBand().

int Isis::BufferManager::MaxLines (  )  const [inline, protected, inherited]

Returns the number of lines in the cube.

Returns:
int
BigInt Isis::BufferManager::MaxMaps (  )  const [inline, protected, inherited]

Returns the maximum number of positions the shape buffer needs to cover the entire image (see setpos method for more info).

Returns:
int
int Isis::BufferManager::MaxSamples (  )  const [inline, protected, inherited]

Returns the number of samples in the cube.

Returns:
int

Referenced by SetSample().

bool Isis::BufferManager::next (  )  [inline, inherited]

Moves the shape buffer to the next position.

Returns true if the next position is valid.

Returns:
bool

References Isis::BufferManager::setpos().

Referenced by Isis::BufferManager::operator++(), and Isis::ProcessExport::StartProcess().

bool Isis::BufferManager::operator++ ( int   )  [inline, inherited]

Moves the shape buffer to the next position.

Returns true if the next position is valid.

Returns:
bool

References Isis::BufferManager::next().

const double& Isis::Buffer::operator[] ( const int  index  )  const [inline, inherited]

Returns the value in the shape buffer at given index.

Parameters:
index Index position in buffer. No out of bounds index is checked
Returns:
double

References Isis::Buffer::p_buf.

double& Isis::Buffer::operator[] ( const int  index  )  [inline, inherited]

Returns the value in the shape buffer at given index.

Parameters:
index Index position in buffer. No out of bounds index is checked
Returns:
double&

References Isis::Buffer::p_buf.

Isis::PixelType Isis::Buffer::PixelType (  )  const [inline, inherited]

Returns the raw buffer pixel type.

Returns:
Isis::PixelType

References Isis::Buffer::p_pixelType.

Referenced by Isis::Buffer::Copy().

void Isis::Buffer::Position ( const int  index,
int &  i_samp,
int &  i_line,
int &  i_band 
) const [inherited]

Returns the sample, line, and band position associated with a shape buffer index.

Performs the same function as the Sample, Line, and Band methods.

Parameters:
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.

References Isis::Buffer::Band(), Isis::Buffer::Line(), and Isis::Buffer::Sample().

void* Isis::Buffer::RawBuffer (  )  const [inline, inherited]

Returns a void pointer to the raw buffer.

Cast this void pointer using information from the PixelType() method

Returns:
void* Pointer to the raw buffer

References Isis::Buffer::p_rawbuf.

int Isis::Buffer::Sample ( const int  index = 0  )  const [inherited]

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.

Parameters:
index Shape buffer index to map to a sample position. Defaults to 0.
Returns:
int The absolute sample number based on the buffer index.

References Isis::Buffer::p_nsamps, and Isis::Buffer::p_sample.

Referenced by Isis::Buffer::Position(), Isis::CubeIoHandler::read(), and Isis::CubeIoHandler::write().

int Isis::Buffer::SampleDimension (  )  const [inline, inherited]

Returns the number of samples in the shape buffer.

Returns:
int

References Isis::Buffer::p_nsamps.

Referenced by Isis::CubeIoHandler::read(), Isis::RegionalCachingAlgorithm::recommendChunksToFree(), and Isis::CubeIoHandler::write().

void Isis::Buffer::SetBaseBand ( const int  start_band  )  [inline, protected, inherited]

This method is used to set the base band position of the shape buffer.

Parameters:
start_band Starting band to set

References Isis::Buffer::p_band.

Referenced by Isis::Buffer::SetBasePosition().

void Isis::Buffer::SetBaseLine ( const int  start_line  )  [inline, protected, inherited]

This method is used to set the base line position of the shape buffer.

Parameters:
start_line Starting line to set

References Isis::Buffer::p_line.

Referenced by Isis::Buffer::SetBasePosition().

void Isis::Buffer::SetBasePosition ( const int  start_sample,
const int  start_line,
const int  start_band 
) [protected, inherited]

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.

Parameters:
start_sample Starting sample to set.
start_line Starting line to set.
start_band Starting band to set.

References Isis::Buffer::SetBaseBand(), Isis::Buffer::SetBaseLine(), and Isis::Buffer::SetBaseSample().

Referenced by Isis::BufferManager::setpos(), and Isis::Portal::SetPosition().

void Isis::Buffer::SetBaseSample ( const int  start_samp  )  [inline, protected, inherited]

This method is used to set the base sample position of the shape buffer.

Parameters:
start_samp Starting sample to set

References Isis::Buffer::p_sample.

Referenced by Isis::Buffer::SetBasePosition().

void Isis::BufferManager::SetIncrements ( const int  sinc,
const int  linc,
const int  binc 
) [protected, inherited]

Sets how the shape is incremented through the cube.

By default (if this method is not invoked) shapes are moved sequentially through the cube with no overlap. For example, assume a 3 sample by 3 line tile buffer. It would first move across the image from left-to-right starting at sample 1, line 1, and band 1. Upon an increment it would be positioned at sample 4, line 1, and band 1. Each successive increment would cause the sample position to increase by 3 until it exceeds the number of samples in the cube. At that point the shape buffer would be positioned at sample 1, line 4, and band 1 (effectively moving to the next row of tiles). The shape would then continue moving across the cube until it reaches the edge again. Then the next row of tiles would be accessed until the shape reached the bottom of the cube. This default management can be overridden using this method. For example, by setting the increments to (6,3,1) we effectively skip every other tile. By setting them to (6,6,1) we skip every other tile and every other row of tiles. By setting them to (1,1,1) we essentially have NSxNLxNB positions in the cube and the 3x3 tile is managed such that the top left corner of the tile is moved over by 1 sample until it reaches the end of the line then down 1 line and so on until the end of the cube is reached.

Parameters:
sinc Sample increment
linc Line increment
binc Band increment

Referenced by Isis::BufferManager::BufferManager().

void Isis::BufferManager::SetOffsets ( const int  soff,
const int  loff,
const int  boff 
) [protected, inherited]

Sets the offset of the buffer.

By default (if this method is not invoked) the offsets are (0,0,0). Offsets are applied when computing the top-left corner of the shape buffer. When used in conjunction with the SetIncrements method, this allows for centering shape buffers around a pixel when passing in negative offsets. For example,with a 3x3x1 shape and offsets of (-1,-1,0) and increments of (1,1,1) would cause the manager to walk a 3x3 buffer through the entire image. Setting the manager position the beginning causes the 3x3 window to be positioned such that sample 1, line 1 of the cube would be at the center of the window and increment would cause sample 2, line 1 to be at the center of the window. Successive increments will move the window in the sample direction until the end of line is reached at which time the buffer would be centered on sample 1, line 2.

Parameters:
soff Sample offset
loff Line offset
boff Band offset
bool Isis::BufferManager::setpos ( const BigInt  map  )  [protected, inherited]

Sets the position of the shape in the cube.

This shape fits into the cube a specific number of times.

When p_reverse is left false: (default) For example, a line shape on a 100 sample, 200 line, and 2 band cube would have 200*2 or 400 different positions as there are 400 total lines in the cube. Performing setpos(0) would position the shape at sample 1, line 1, and band 1. While setpos(200) would position the shape at sample 1, line 1, and band 2. Finally, setpos(399) would position the shape at sample 1, line 400, and band 2. Setpos returns true if it was sucessfully in setting the position, and false if the shape is at the end of the cube (beyond index 399 in the case of our example).

When p_reverse is set to true: Following the above cube with 100 samples, 200 lines, and 2 bands, performing the setpos(0) would still position othe shape at sample 1, line 1, and band 1. However, setpos(1) would position the shape at sample 1, line 1, band 2, while setpos(200) would position the spame at sample 1, line 100, band 1. Setpos returns true of it was sucessfully in setting the position, and false if the shape is at the end of the cube(beyond final index).

Parameters:
map Shape buffer position value
Returns:
bool True or False depending on whether the shape is at the end of the cube or not.
Exceptions:
Isis::iException::Programmer - Invalid value for map argument

References _FILEINFO_, Isis::BufferManager::end(), Isis::iException::Message(), Isis::iException::Programmer, and Isis::Buffer::SetBasePosition().

Referenced by Isis::BufferManager::begin(), Isis::BufferManager::next(), Isis::BandManager::SetBand(), and SetSample().

bool Isis::SampleManager::SetSample ( const int  sample,
const int  band = 1 
)

Positions the buffer at the requested line and returns a status indicator if the set was succesful or not.

Parameters:
sample The sample number within a band (1-based).
band The band number within the cube (1-based). Defaults to 1
Returns:
bool Status indicator of the set being successful or not

References _FILEINFO_, Isis::BufferManager::MaxSamples(), Isis::iException::Message(), Isis::iException::Programmer, and Isis::BufferManager::setpos().

int Isis::Buffer::size (  )  const [inline, inherited]

Member Data Documentation

int Isis::Buffer::p_band [protected, inherited]

Starting band to read/write.

Referenced by Isis::Buffer::Band(), Isis::Buffer::Buffer(), and Isis::Buffer::SetBaseBand().

double* Isis::Buffer::p_buf [protected, inherited]
int Isis::Buffer::p_line [protected, inherited]

Starting line to read/write.

Referenced by Isis::Buffer::Buffer(), Isis::Buffer::Line(), and Isis::Buffer::SetBaseLine().

int Isis::Buffer::p_nbands [protected, inherited]

Number of bands to read/write.

Referenced by Isis::Buffer::BandDimension(), and Isis::Buffer::Buffer().

int Isis::Buffer::p_nlines [protected, inherited]
int Isis::Buffer::p_npixels [protected, inherited]
int Isis::Buffer::p_nsamps [protected, inherited]
const Isis::PixelType Isis::Buffer::p_pixelType [protected, inherited]

The pixel type of the raw buffer.

Referenced by Isis::Buffer::Allocate(), Isis::Buffer::Copy(), and Isis::Buffer::PixelType().

void* Isis::Buffer::p_rawbuf [protected, inherited]
int Isis::Buffer::p_sample [protected, inherited]

Starting sample to read/write.

Referenced by Isis::Buffer::Buffer(), Isis::Buffer::Sample(), and Isis::Buffer::SetBaseSample().


The documentation for this class was generated from the following files: