casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
CurvedLattice2D.h
Go to the documentation of this file.
00001 //# CurvedLattice2D.h: A lattice crosscut based on a curve in a plane
00002 //# Copyright (C) 2003
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have receied a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //# $Id: CurvedLattice2D.h 20229 2008-01-29 15:19:06Z gervandiepen $
00027 
00028 #ifndef LATTICES_CURVEDLATTICE2D_H
00029 #define LATTICES_CURVEDLATTICE2D_H
00030 
00031 
00032 //# Includes
00033 #include <lattices/Lattices/MaskedLattice.h>
00034 #include <lattices/Lattices/PixelCurve1D.h>
00035 #include <lattices/Lattices/CLInterpolator2D.h>
00036 #include <casa/Arrays/AxesMapping.h>
00037 
00038 namespace casa { //# NAMESPACE CASA - BEGIN
00039 
00040 //# Forward Declarations
00041 
00042 
00043 // <summary>
00044 // A lattice crosscut based on a curve in a plane.
00045 // </summary>
00046 
00047 // <use visibility=local>
00048 
00049 // <reviewed reviewer="" date="" tests="tCurvedLattice2D.cc">
00050 // </reviewed>
00051 
00052 // <prerequisite>
00053 //# Classes you should understand before using this one.
00054 //   <li> <linkto class=PixelCurve1D>PixelCurve1D</linkto>
00055 //   <li> <linkto class=CLInterpolator2D>CLInterpolator2D</linkto>
00056 // </prerequisite>
00057 
00058 // <synopsis>
00059 // Class CurvedImage2D can be used to make a crosscut through an image
00060 // with a dimensionality >= 2.
00061 // The crosscut is based on a curve defined by a
00062 // <linkto class=PixelCurve1D>PixelCurve1D</linkto> object. The curve
00063 // can be any 1-dim function (e.g. straight line, spline)
00064 // supported by the Functionals module. The curve must be in one of the
00065 // main planes of the image as defined by the axes arguments in the
00066 // constructor.
00067 // <br>See class <linkto class=CurvedImage2D>CurvedImage2D</linkto> for
00068 // a more detailed description.
00069 // </synopsis>
00070 
00071 // <example>
00072 // See example in <linkto class=CurvedImage2D>CurvedImage2D</linkto>.
00073 // </example>
00074 
00075 // <motivation>
00076 // Users like to view arbitrary image crosscuts.
00077 // </motivation>
00078 
00079 
00080 template<class T>
00081 class CurvedLattice2D: public MaskedLattice<T>
00082 {
00083 public:
00084 
00085   // Default constructor
00086   CurvedLattice2D();
00087 
00088   // Take a curved slice from the given MaskedLattice. For example, define
00089   // a spline in the RA-DEC plane and extend it in the FREQ direction.
00090   // The result is a 2D lattice with axes FREQ and 'spline'.
00091   // <br>
00092   // The <linkto class=PixelCurve1D>PixelCurve1D</linkto> object defines
00093   // the curve in one of the planes of the lattice. The arguments axis1
00094   // and axis2 define the plane the curve is in.
00095   // The <linkto class=CLInterpolator2D>CLInterpolator2D</linkto> object
00096   // defines the interpolation scheme for pixels that are not on grid points.
00097   // An example is CLIPNearest2D which takes the nearest neighbour.
00098   // The dimensionality of the CurvedLattice2D is one less than the
00099   // dimensionality of the given lattice. Two axes (axis1 and axis2) are
00100   // replaced by the new axis representing the curve. The argument
00101   // curveAxis defines the axis number of the new axis. It defaults to the
00102   // last axis.
00103   // An exception is thrown if the dimensionality of the input lattice is < 2
00104   // or if the given axes numbers are too high.
00105   CurvedLattice2D (const MaskedLattice<T>&, const CLInterpolator2D<T>&,
00106                    const PixelCurve1D&, uInt axis1, uInt axis2,
00107                    Int curveAxis=-1);
00108 
00109   // Copy constructor (reference semantics)
00110   CurvedLattice2D(const CurvedLattice2D<T>& other);
00111 
00112   // Destructor, does nothing
00113   virtual ~CurvedLattice2D();
00114 
00115   // Assignment (reference semantics)
00116   CurvedLattice2D<T>& operator=(const CurvedLattice2D<T>& other);
00117 
00118   // Make a copy of the object (reference semantics).
00119   virtual MaskedLattice<T>* cloneML() const;
00120 
00121   // Is the lattice masked?
00122   // It is if its parent lattice is masked.
00123   virtual Bool isMasked() const;
00124 
00125   // Is the lattice paged to disk?
00126   virtual Bool isPaged() const;
00127 
00128   // The lattice is not writable.
00129   virtual Bool isWritable() const;
00130 
00131   // Handle ocking of the lattice which is delegated to its parent.
00132   // <br>It is strongly recommended to use class
00133   // <linkto class=LatticeLocker>LatticeLocker</linkto> to
00134   // handle lattice locking. It also contains a more detailed
00135   // explanation of the locking process.
00136   // <group>
00137   virtual Bool lock (FileLocker::LockType, uInt nattempts);
00138   virtual void unlock();
00139   virtual Bool hasLock (FileLocker::LockType) const;
00140   // </group>
00141 
00142   // Resynchronize the Lattice object with the lattice file.
00143   // This function is only useful if no read-locking is used, ie.
00144   // if the table lock option is UserNoReadLocking or AutoNoReadLocking.
00145   // In that cases the table system does not acquire a read-lock, thus
00146   // does not synchronize itself automatically.
00147   virtual void resync();
00148 
00149   // Flush the data.
00150   virtual void flush();
00151 
00152   // Close the Lattice temporarily (if it is paged to disk).
00153   // It'll be reopened automatically when needed or when
00154   // <src>reopen</src> is called explicitly.
00155   virtual void tempClose();
00156 
00157   // If needed, reopen a temporarily closed Lattice.
00158   virtual void reopen();
00159 
00160   // Get a pointer the region/mask object.
00161   // It returns 0.
00162   virtual const LatticeRegion* getRegionPtr() const;
00163 
00164   // Returns the shape of the lattice.
00165   virtual IPosition shape() const;
00166   
00167   // Return the name of the parent lattice.
00168   virtual String name (Bool stripPath=False) const;
00169 
00170   // This function returns the recommended maximum number of pixels to
00171   // include in the cursor of an iterator.
00172   virtual uInt advisedMaxPixels() const;
00173 
00174   // Check class internals - used for debugging. Should always return True
00175   virtual Bool ok() const;
00176 
00177   // Do the actual getting of an array of values.
00178   virtual Bool doGetSlice (Array<T>& buffer, const Slicer& section);
00179 
00180   // Do the actual getting of an array of values.
00181   virtual void doPutSlice (const Array<T>& sourceBuffer,
00182                            const IPosition& where,
00183                            const IPosition& stride);
00184   
00185   // Get a section of the mask.
00186   virtual Bool doGetMaskSlice (Array<Bool>& buffer, const Slicer& section);
00187 
00188   // Get the best cursor shape.
00189   virtual IPosition doNiceCursorShape (uInt maxPixels) const;
00190 
00191 
00192 private:
00193   // Make the AxesMapping object to map input to output axes.
00194   void makeMapping (uInt axis1, uInt axis2, Int curveAxis);
00195 
00196 
00197   MaskedLattice<T>*       itsLatticePtr;
00198   CLInterpolator2D<T>*    itsInterpolator;
00199   PixelCurve1D            itsCurve;
00200   uInt                    itsAxis1;
00201   uInt                    itsAxis2;
00202   uInt                    itsCurveAxis;
00203   AxesMapping             itsAxesMap;
00204 };
00205 
00206 
00207 
00208 } //# NAMESPACE CASA - END
00209 
00210 #ifndef CASACORE_NO_AUTO_TEMPLATES
00211 #include <lattices/Lattices/CurvedLattice2D.tcc>
00212 #endif //# CASACORE_NO_AUTO_TEMPLATES
00213 #endif