casa
5.7.016

A helper class for stepping through Lattices. More...
#include <LatticeIndexer.h>
Public Member Functions  
LatticeIndexer ()  
Default constructor (one dimensional, unitlength instance). More...  
LatticeIndexer (const IPosition &shape)  
Specify the size of the Lattice. More...  
LatticeIndexer (const IPosition &shape, const IPosition &blc, const IPosition &trc, const IPosition &inc)  
Specify a Lattice and define a subLattice within it. More...  
LatticeIndexer (const LatticeIndexer &other)  
The copy constructor uses copy semantics. More...  
~LatticeIndexer ()  
LatticeIndexer &  operator= (const LatticeIndexer &other) 
The assignment operator uses copy semantics. More...  
void  resize (const IPosition &newShape) 
Function to change the shape of the Lattice. More...  
const IPosition &  fullShape () const 
Returns the length of each axis (or the requested one) in the parent Lattice. More...  
uInt  fullShape (uInt axis) const 
const IPosition &  shape () const 
Returns the length of each axis (or the requested one) in the subLattice. More...  
uInt  shape (uInt axis) const 
const IPosition &  increment () const 
Function to return the increments along each axis (or the requested one) of the Lattice. More...  
uInt  increment (uInt axis) const 
const IPosition &  offset () const 
Function to return the offset (on a specified axis) between the subLattice and the parent one. More...  
uInt  offset (uInt axis) const 
uInt  ndim () const 
Function which returns the number of dimensions in the Lattice (or subLattice). More...  
void  fullSize () 
Revert from a subLattice description back to the main Lattice. More...  
size_t  nelements () const 
Function which returns the number of elements in the subLattice; this value is equal to the product of shape(). More...  
Bool  tiledCursorMove (Bool incr, IPosition &cursorPos, const IPosition &cursorShape, const IPosition &cursorHeading) const 
Function which increments (incr=True) or decrements (incr=False) the cursor position (the first IPosition argument) by a cursor shape (the second IPosition argument), tiling to the next/previous axis if necessary. More...  
Bool  isInside (const IPosition &index) const 
Function which returns a value of True if the IPosition argument is within the subLattice. More...  
void  subSection (const IPosition &blc, const IPosition &trc, const IPosition &inc) 
Function which subsections a LatticeIndexer. More...  
void  subSection (const IPosition &blc, const IPosition &trc) 
IPosition  absolutePosition (const IPosition &position) const 
Function which returns an IPosition in the parent Lattice given an IPostion in the subLattice. More...  
Bool  ok () const 
Is this LatticeIndexer consistent, i.e. More...  
Private Attributes  
IPosition  itsFullShape 
uInt  itsNdim 
IPosition  itsShape 
IPosition  itsAxisInc 
IPosition  itsOffset 
A helper class for stepping through Lattices.
Internal
This class does various calculations involved with indexing in Lattices. LatticeIndexer is not a good name, but it is better than the previous name of LatticeLayout.
A LatticeIndexer contains all the information necessary to define the shape of a Lattice or subLattice. It is currently a repository of functions that provide indexing calculations.
A subLattice is a section of a Lattice defined by a bottom left corner (blc), a top right corner (trc), and a step size or increment on each axis. The blc and trc pixels will always be included in the subLattice if the step increment is one. If the step increment is greater than one, the pixel in top right corner may not be included in the subLattice.
This class knows the shape of the parent Lattice (including all degenerate axes), and allows the user to specify a subLattice that is embedded in the parent Lattice. The default subLattice, if none is specified, is one identical in shape to the main Lattice.
A subLattice can be defined on the Lattice by specifying a trc, blc, and step increment using the subSection
function, or the appropriate constructor. A subLattice must be smaller than (or the same size as) the Lattice that it is derived from. A subLattice can be further created from an already existing subLattice eg.
If we have a 128 by 128 Lattice, we can specify the centre quarter by using blc=[32,32] and trc=[95,95]. Then specifying a subLattice of blc=[0,0] and trc = [31,31] results in a subLattice that has a blc of [32,32] and trc of [63,63] with respect to the parent Lattice.
The only way to increase the size of a subLattice is to first revert to the parent Lattice (using the fullSize
function) and then generate the new, bigger subLattice.
Indexing calculations (eg. the tiledCursorMove
or the isInside
function) are performed on the specified subLattice.
The role of this class is to centralise the information and functions needed to operate on subLattices. It will normally be used by other Lattice classes, and is currently used by navigator classes like LatticeStepper.
The shape, structure or geometry of a lattice is quite separable from its actual contents, and the operations you can do on the contents. Also, there are operations which apply only to the layout such as subsectioning.
Definition at line 108 of file LatticeIndexer.h.
casacore::LatticeIndexer::LatticeIndexer  (  ) 
Default constructor (one dimensional, unitlength instance).

explicit 
Specify the size of the Lattice.
Assume a full size subLattice.
casacore::LatticeIndexer::LatticeIndexer  (  const IPosition &  shape, 
const IPosition &  blc,  
const IPosition &  trc,  
const IPosition &  inc  
) 
Specify a Lattice and define a subLattice within it.
casacore::LatticeIndexer::LatticeIndexer  (  const LatticeIndexer &  other  ) 
The copy constructor uses copy semantics.
casacore::LatticeIndexer::~LatticeIndexer  (  ) 

inline 
Returns the length of each axis (or the requested one) in the parent Lattice.
Definition at line 239 of file LatticeIndexer.h.
References itsFullShape.
void casacore::LatticeIndexer::fullSize  (  ) 
Revert from a subLattice description back to the main Lattice.
This is the only way to "increase" the the size of the subLattice used by the LatticeIndexer.

inline 
Function to return the increments along each axis (or the requested one) of the Lattice.
Definition at line 247 of file LatticeIndexer.h.
References itsAxisInc.
Function which returns a value of True if the IPosition argument is within the subLattice.
Returns False if the IPosition argument is outside the subLattice or if the argument doesn't conform to the data members.
Warning: Due to zeroorigins, an index argument equal to the shape of this subLattice lies outside and returns False;

inline 
Function which returns the number of dimensions in the Lattice (or subLattice).
Definition at line 255 of file LatticeIndexer.h.
References itsNdim.

inline 
Function which returns the number of elements in the subLattice; this value is equal to the product of shape().
Definition at line 259 of file LatticeIndexer.h.
References itsShape, and casacore::IPosition::product().

inline 
Function to return the offset (on a specified axis) between the subLattice and the parent one.
Definition at line 251 of file LatticeIndexer.h.
References itsOffset.
Bool casacore::LatticeIndexer::ok  (  )  const 
Is this LatticeIndexer consistent, i.e.
are the class invariants valid? Returns True if every thing is fine otherwise returns False
LatticeIndexer& casacore::LatticeIndexer::operator=  (  const LatticeIndexer &  other  ) 
The assignment operator uses copy semantics.
void casacore::LatticeIndexer::resize  (  const IPosition &  newShape  ) 

inline 
Returns the length of each axis (or the requested one) in the subLattice.
Definition at line 243 of file LatticeIndexer.h.
References itsShape.
void casacore::LatticeIndexer::subSection  (  const IPosition &  blc, 
const IPosition &  trc,  
const IPosition &  inc  
) 
Function which subsections a LatticeIndexer.
The argument IPositions specify "bottom left" and "upper right" corners and axis increments (which default to one). The origins are cumulative. i.e. specifying a blc of (2,2), and then (1,1) results in the subLattice having an origin at pixel (3,3) in the parent Lattice. Similarly the increment is cumulative, i.e. an increment of 2 on top of an increment of 3 results in a total increment of 6. This function can only decrease the size of the subLattice (i.e. blc >= 0, and trc <= shape(), and inc >= 1). The fullSize() function should be used to revert back to the maximum possible Lattice size. Also note that the trc might not be used if an integral number of increments does not end on the trc (in which case the last position below the trc will be used).
Bool casacore::LatticeIndexer::tiledCursorMove  (  Bool  incr, 
IPosition &  cursorPos,  
const IPosition &  cursorShape,  
const IPosition &  cursorHeading  
)  const 
Function which increments (incr=True) or decrements (incr=False) the cursor position (the first IPosition argument) by a cursor shape (the second IPosition argument), tiling to the next/previous axis if necessary.
The path of movement is based upon the third IPosition argument (a cursor heading) that is zerobased e.g. IPosition(3,0,2,1) implies starting movement along the xaxis, then the zaxis, and then the yaxis. Returns a value of False if the beginning/end of the subLattice is reached. The cursorPosition is relative to the origin of the subLattice. To get its location relative to the main Lattice use the absolutePosition() function.

private 
Definition at line 234 of file LatticeIndexer.h.
Referenced by increment().

private 
Definition at line 231 of file LatticeIndexer.h.
Referenced by fullShape().

private 
Definition at line 232 of file LatticeIndexer.h.
Referenced by ndim().

private 
Definition at line 235 of file LatticeIndexer.h.
Referenced by offset().

private 
Definition at line 233 of file LatticeIndexer.h.
Referenced by nelements(), and shape().