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