casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
CLInterpolator2D.h
Go to the documentation of this file.
00001 //# CLInterpolator2D.h: Abstract base class for interpolator used by CurvedLattice2D
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: CLInterpolator2D.h 20229 2008-01-29 15:19:06Z gervandiepen $
00027 
00028 #ifndef LATTICES_CLINTERPOLATOR2D_H
00029 #define LATTICES_CLINTERPOLATOR2D_H
00030 
00031 
00032 //# Includes
00033 #include <casa/Arrays/AxesMapping.h>
00034 
00035 namespace casa { //# NAMESPACE CASA - BEGIN
00036 
00037 //# Forward Declarations
00038 template<class T> class MaskedLattice;
00039 
00040 
00041 // <summary>
00042 // Abstract base class for interpolator used by CurvedLattice2D.
00043 // </summary>
00044 
00045 // <use visibility=local>
00046 
00047 // <reviewed reviewer="" date="" tests="tCurvedLattice2D.cc">
00048 // </reviewed>
00049 
00050 // <prerequisite>
00051 //# Classes you should understand before using this one.
00052 //   <li> <linkto class=CurvedLattice2D>CurvedLattice2D</linkto>
00053 // </prerequisite>
00054 
00055 // <etymology>
00056 // The CL in CLInterpolator2D means CurvedLattice.
00057 // The 2D means that interpolation in 2 dimensions needs to be done.
00058 // </etymology>
00059 
00060 // <synopsis>
00061 // CurvedLattice2D needs lattice data which are not on exact grid points.
00062 // Therefore some interpolation scheme is needed. The abstract base class
00063 // CLInterpolation2D makes it possible for CurvedLattice2D to use any
00064 // interpolation scheme.
00065 // Currently the only derived class is
00066 // <linkto class=CLIPNearest2D>CLIPNearest2D</linkto>
00067 // <br>
00068 // Apart from interpolating and returning data, a derived class also has to
00069 // return a mask. For instance, in a possible derived class using
00070 // 4-point interpolation, the interpolation scheme has to take the
00071 // image mask into account, and make a mask for its output data (say that
00072 // the output point is masked off if its 4 input points are masked off).
00073 //
00074 // This base class has some data members defining the lattice and the
00075 // lattice axes to be interpolated. When these data members are set,
00076 // the virtual function <src>preset</src> is called. A derived class
00077 // can implement this function to do some precalculations, etc..
00078 // </synopsis>
00079 
00080 // <motivation>
00081 // This class makes it possible to hide the interpolation to be used
00082 // from the CurvedLattice2D class.
00083 // </motivation>
00084 
00085 
00086 template<class T>
00087 class CLInterpolator2D
00088 {
00089 public:
00090 
00091   CLInterpolator2D()
00092   : itsLatticePtr(0) {;}
00093 
00094   virtual ~CLInterpolator2D();
00095 
00096   // Let a derived class make a copy of itself.
00097   virtual CLInterpolator2D<T>* clone() const = 0;
00098 
00099   // Set the internals to the values of the CurvedLattice using it.
00100   // Note that only a copy of the lattice pointer is made.
00101   // Thereafter the virtual function preset() is called to give a derived
00102   // class the opportunity to do some initial work.
00103   void set (MaskedLattice<T>* lattice,
00104             const AxesMapping& axesMap,
00105             uInt axis1, uInt axis2, uInt curveAxis);
00106 
00107   // Get the data for the given pixel points (on axis1 and axis2) and
00108   // the chunk in the other axes as given by the section.
00109   // The Slicer is fixed and the buffer has the correct shape.
00110   virtual void getData (Array<T>& buffer,
00111                         const Vector<Float>& x,
00112                         const Vector<Float>& y,
00113                         const Slicer& section) = 0;
00114 
00115   // Get the mask for the given pixel points (on axis1 and axis2) and
00116   // the chunk in the other axes as given by the section.
00117   // The Slicer is fixed and the buffer has the correct shape.
00118   virtual void getMask (Array<Bool>& buffer,
00119                         const Vector<Float>& x,
00120                         const Vector<Float>& y,
00121                         const Slicer& section) = 0;
00122 
00123 protected:
00124   // Copy constructor can only be used by derived classes.
00125   CLInterpolator2D (const CLInterpolator2D<T>&);
00126 
00127   // Assignment can only be used by derived classes.
00128   CLInterpolator2D& operator= (const CLInterpolator2D<T>&);
00129 
00130   // Let a derived class do some initial work after set is called.
00131   // The default implementation does nothing.
00132   virtual void preset();
00133 
00134 
00135   MaskedLattice<T>* itsLatticePtr;
00136   AxesMapping       itsAxesMap;
00137   uInt              itsAxis1;
00138   uInt              itsAxis2;
00139   uInt              itsCurveAxis;
00140   Bool              itsIsRef;       // True = lattice returns array reference
00141 };
00142 
00143 
00144 
00145 } //# NAMESPACE CASA - END
00146 
00147 #ifndef CASACORE_NO_AUTO_TEMPLATES
00148 #include <lattices/Lattices/CLInterpolator2D.tcc>
00149 #endif //# CASACORE_NO_AUTO_TEMPLATES
00150 #endif