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$ 00027 00028 #ifndef LATTICES_CURVEDLATTICE2D_H 00029 #define LATTICES_CURVEDLATTICE2D_H 00030 00031 00032 //# Includes 00033 #include <casacore/casa/aips.h> 00034 #include <casacore/lattices/Lattices/MaskedLattice.h> 00035 #include <casacore/lattices/Lattices/PixelCurve1D.h> 00036 #include <casacore/lattices/LatticeMath/CLInterpolator2D.h> 00037 #include <casacore/casa/Arrays/AxesMapping.h> 00038 00039 namespace casacore { //# NAMESPACE CASACORE - BEGIN 00040 00041 //# Forward Declarations 00042 00043 00044 // <summary> 00045 // A lattice crosscut based on a curve in a plane. 00046 // </summary> 00047 00048 // <use visibility=local> 00049 00050 // <reviewed reviewer="" date="" tests="tCurvedLattice2D.cc"> 00051 // </reviewed> 00052 00053 // <prerequisite> 00054 //# Classes you should understand before using this one. 00055 // <li> <linkto class=PixelCurve1D>PixelCurve1D</linkto> 00056 // <li> <linkto class=CLInterpolator2D>CLInterpolator2D</linkto> 00057 // </prerequisite> 00058 00059 // <synopsis> 00060 // Class CurvedImage2D can be used to make a crosscut through an image 00061 // with a dimensionality >= 2. 00062 // The crosscut is based on a curve defined by a 00063 // <linkto class=PixelCurve1D>PixelCurve1D</linkto> object. The curve 00064 // can be any 1-dim function (e.g. straight line, spline) 00065 // supported by the Functionals module. The curve must be in one of the 00066 // main planes of the image as defined by the axes arguments in the 00067 // constructor. 00068 // <br>See class <linkto class=CurvedImage2D>CurvedImage2D</linkto> for 00069 // a more detailed description. 00070 // </synopsis> 00071 00072 // <example> 00073 // See example in <linkto class=CurvedImage2D>CurvedImage2D</linkto>. 00074 // </example> 00075 00076 // <motivation> 00077 // Users like to view arbitrary image crosscuts. 00078 // </motivation> 00079 00080 00081 template<class T> 00082 class CurvedLattice2D: public MaskedLattice<T> 00083 { 00084 public: 00085 00086 // Default constructor 00087 CurvedLattice2D(); 00088 00089 // Take a curved slice from the given MaskedLattice. For example, define 00090 // a spline in the RA-DEC plane and extend it in the FREQ direction. 00091 // The result is a 2D lattice with axes FREQ and 'spline'. 00092 // <br> 00093 // The <linkto class=PixelCurve1D>PixelCurve1D</linkto> object defines 00094 // the curve in one of the planes of the lattice. The arguments axis1 00095 // and axis2 define the plane the curve is in. 00096 // The <linkto class=CLInterpolator2D>CLInterpolator2D</linkto> object 00097 // defines the interpolation scheme for pixels that are not on grid points. 00098 // An example is CLIPNearest2D which takes the nearest neighbour. 00099 // The dimensionality of the CurvedLattice2D is one less than the 00100 // dimensionality of the given lattice. Two axes (axis1 and axis2) are 00101 // replaced by the new axis representing the curve. The argument 00102 // curveAxis defines the axis number of the new axis. It defaults to the 00103 // last axis. 00104 // An exception is thrown if the dimensionality of the input lattice is < 2 00105 // or if the given axes numbers are too high. 00106 CurvedLattice2D (const MaskedLattice<T>&, const CLInterpolator2D<T>&, 00107 const PixelCurve1D&, uInt axis1, uInt axis2, 00108 Int curveAxis=-1); 00109 00110 // Copy constructor (reference semantics) 00111 CurvedLattice2D(const CurvedLattice2D<T>& other); 00112 00113 // Destructor, does nothing 00114 virtual ~CurvedLattice2D(); 00115 00116 // Assignment (reference semantics) 00117 CurvedLattice2D<T>& operator=(const CurvedLattice2D<T>& other); 00118 00119 // Make a copy of the object (reference semantics). 00120 virtual MaskedLattice<T>* cloneML() const; 00121 00122 // Is the lattice masked? 00123 // It is if its parent lattice is masked. 00124 virtual Bool isMasked() const; 00125 00126 // Is the lattice paged to disk? 00127 virtual Bool isPaged() const; 00128 00129 // The lattice is not writable. 00130 virtual Bool isWritable() const; 00131 00132 // Handle ocking of the lattice which is delegated to its parent. 00133 // <br>It is strongly recommended to use class 00134 // <linkto class=LatticeLocker>LatticeLocker</linkto> to 00135 // handle lattice locking. It also contains a more detailed 00136 // explanation of the locking process. 00137 // <group> 00138 virtual Bool lock (FileLocker::LockType, uInt nattempts); 00139 virtual void unlock(); 00140 virtual Bool hasLock (FileLocker::LockType) const; 00141 // </group> 00142 00143 // Resynchronize the Lattice object with the lattice file. 00144 // This function is only useful if no read-locking is used, ie. 00145 // if the table lock option is UserNoReadLocking or AutoNoReadLocking. 00146 // In that cases the table system does not acquire a read-lock, thus 00147 // does not synchronize itself automatically. 00148 virtual void resync(); 00149 00150 // Flush the data. 00151 virtual void flush(); 00152 00153 // Close the Lattice temporarily (if it is paged to disk). 00154 // It'll be reopened automatically when needed or when 00155 // <src>reopen</src> is called explicitly. 00156 virtual void tempClose(); 00157 00158 // If needed, reopen a temporarily closed Lattice. 00159 virtual void reopen(); 00160 00161 // Get a pointer the region/mask object. 00162 // It returns 0. 00163 virtual const LatticeRegion* getRegionPtr() const; 00164 00165 // Returns the shape of the lattice. 00166 virtual IPosition shape() const; 00167 00168 // Return the name of the parent lattice. 00169 virtual String name (Bool stripPath=False) const; 00170 00171 // This function returns the recommended maximum number of pixels to 00172 // include in the cursor of an iterator. 00173 virtual uInt advisedMaxPixels() const; 00174 00175 // Check class internals - used for debugging. Should always return True 00176 virtual Bool ok() const; 00177 00178 // Do the actual getting of an array of values. 00179 virtual Bool doGetSlice (Array<T>& buffer, const Slicer& section); 00180 00181 // Do the actual getting of an array of values. 00182 virtual void doPutSlice (const Array<T>& sourceBuffer, 00183 const IPosition& where, 00184 const IPosition& stride); 00185 00186 // Get a section of the mask. 00187 virtual Bool doGetMaskSlice (Array<Bool>& buffer, const Slicer& section); 00188 00189 // Get the best cursor shape. 00190 virtual IPosition doNiceCursorShape (uInt maxPixels) const; 00191 00192 00193 private: 00194 // Make the AxesMapping object to map input to output axes. 00195 void makeMapping (uInt axis1, uInt axis2, Int curveAxis); 00196 00197 00198 MaskedLattice<T>* itsLatticePtr; 00199 CLInterpolator2D<T>* itsInterpolator; 00200 PixelCurve1D itsCurve; 00201 uInt itsAxis1; 00202 uInt itsAxis2; 00203 uInt itsCurveAxis; 00204 AxesMapping itsAxesMap; 00205 }; 00206 00207 00208 00209 } //# NAMESPACE CASACORE - END 00210 00211 #ifndef CASACORE_NO_AUTO_TEMPLATES 00212 #include <casacore/lattices/Lattices/CurvedLattice2D.tcc> 00213 #endif //# CASACORE_NO_AUTO_TEMPLATES 00214 #endif