casacore
CurvedLattice2D.h
Go to the documentation of this file.
1 //# CurvedLattice2D.h: A lattice crosscut based on a curve in a plane
2 //# Copyright (C) 2003
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have receied a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id$
27 
28 #ifndef LATTICES_CURVEDLATTICE2D_H
29 #define LATTICES_CURVEDLATTICE2D_H
30 
31 
32 //# Includes
33 #include <casacore/casa/aips.h>
34 #include <casacore/lattices/Lattices/MaskedLattice.h>
35 #include <casacore/lattices/Lattices/PixelCurve1D.h>
36 #include <casacore/lattices/LatticeMath/CLInterpolator2D.h>
37 #include <casacore/casa/Arrays/AxesMapping.h>
38 
39 namespace casacore { //# NAMESPACE CASACORE - BEGIN
40 
41 //# Forward Declarations
42 
43 
44 // <summary>
45 // A lattice crosscut based on a curve in a plane.
46 // </summary>
47 
48 // <use visibility=local>
49 
50 // <reviewed reviewer="" date="" tests="tCurvedLattice2D.cc">
51 // </reviewed>
52 
53 // <prerequisite>
54 //# Classes you should understand before using this one.
55 // <li> <linkto class=PixelCurve1D>PixelCurve1D</linkto>
56 // <li> <linkto class=CLInterpolator2D>CLInterpolator2D</linkto>
57 // </prerequisite>
58 
59 // <synopsis>
60 // Class CurvedImage2D can be used to make a crosscut through an image
61 // with a dimensionality >= 2.
62 // The crosscut is based on a curve defined by a
63 // <linkto class=PixelCurve1D>PixelCurve1D</linkto> object. The curve
64 // can be any 1-dim function (e.g. straight line, spline)
65 // supported by the Functionals module. The curve must be in one of the
66 // main planes of the image as defined by the axes arguments in the
67 // constructor.
68 // <br>See class <linkto class=CurvedImage2D>CurvedImage2D</linkto> for
69 // a more detailed description.
70 // </synopsis>
71 
72 // <example>
73 // See example in <linkto class=CurvedImage2D>CurvedImage2D</linkto>.
74 // </example>
75 
76 // <motivation>
77 // Users like to view arbitrary image crosscuts.
78 // </motivation>
79 
80 
81 template<class T>
83 {
84 public:
85 
86  // Default constructor
88 
89  // Take a curved slice from the given MaskedLattice. For example, define
90  // a spline in the RA-DEC plane and extend it in the FREQ direction.
91  // The result is a 2D lattice with axes FREQ and 'spline'.
92  // <br>
93  // The <linkto class=PixelCurve1D>PixelCurve1D</linkto> object defines
94  // the curve in one of the planes of the lattice. The arguments axis1
95  // and axis2 define the plane the curve is in.
96  // The <linkto class=CLInterpolator2D>CLInterpolator2D</linkto> object
97  // defines the interpolation scheme for pixels that are not on grid points.
98  // An example is CLIPNearest2D which takes the nearest neighbour.
99  // The dimensionality of the CurvedLattice2D is one less than the
100  // dimensionality of the given lattice. Two axes (axis1 and axis2) are
101  // replaced by the new axis representing the curve. The argument
102  // curveAxis defines the axis number of the new axis. It defaults to the
103  // last axis.
104  // An exception is thrown if the dimensionality of the input lattice is < 2
105  // or if the given axes numbers are too high.
107  const PixelCurve1D&, uInt axis1, uInt axis2,
108  Int curveAxis=-1);
109 
110  // Copy constructor (reference semantics)
112 
113  // Destructor, does nothing
114  virtual ~CurvedLattice2D();
115 
116  // Assignment (reference semantics)
118 
119  // Make a copy of the object (reference semantics).
120  virtual MaskedLattice<T>* cloneML() const;
121 
122  // Is the lattice masked?
123  // It is if its parent lattice is masked.
124  virtual Bool isMasked() const;
125 
126  // Is the lattice paged to disk?
127  virtual Bool isPaged() const;
128 
129  // The lattice is not writable.
130  virtual Bool isWritable() const;
131 
132  // Handle ocking of the lattice which is delegated to its parent.
133  // <br>It is strongly recommended to use class
134  // <linkto class=LatticeLocker>LatticeLocker</linkto> to
135  // handle lattice locking. It also contains a more detailed
136  // explanation of the locking process.
137  // <group>
138  virtual Bool lock (FileLocker::LockType, uInt nattempts);
139  virtual void unlock();
141  // </group>
142 
143  // Resynchronize the Lattice object with the lattice file.
144  // This function is only useful if no read-locking is used, ie.
145  // if the table lock option is UserNoReadLocking or AutoNoReadLocking.
146  // In that cases the table system does not acquire a read-lock, thus
147  // does not synchronize itself automatically.
148  virtual void resync();
149 
150  // Flush the data.
151  virtual void flush();
152 
153  // Close the Lattice temporarily (if it is paged to disk).
154  // It'll be reopened automatically when needed or when
155  // <src>reopen</src> is called explicitly.
156  virtual void tempClose();
157 
158  // If needed, reopen a temporarily closed Lattice.
159  virtual void reopen();
160 
161  // Get a pointer the region/mask object.
162  // It returns 0.
163  virtual const LatticeRegion* getRegionPtr() const;
164 
165  // Returns the shape of the lattice.
166  virtual IPosition shape() const;
167 
168  // Return the name of the parent lattice.
169  virtual String name (Bool stripPath=False) const;
170 
171  // This function returns the recommended maximum number of pixels to
172  // include in the cursor of an iterator.
173  virtual uInt advisedMaxPixels() const;
174 
175  // Check class internals - used for debugging. Should always return True
176  virtual Bool ok() const;
177 
178  // Do the actual getting of an array of values.
179  virtual Bool doGetSlice (Array<T>& buffer, const Slicer& section);
180 
181  // Do the actual getting of an array of values.
182  virtual void doPutSlice (const Array<T>& sourceBuffer,
183  const IPosition& where,
184  const IPosition& stride);
185 
186  // Get a section of the mask.
187  virtual Bool doGetMaskSlice (Array<Bool>& buffer, const Slicer& section);
188 
189  // Get the best cursor shape.
190  virtual IPosition doNiceCursorShape (uInt maxPixels) const;
191 
192 
193 private:
194  // Make the AxesMapping object to map input to output axes.
195  void makeMapping (uInt axis1, uInt axis2, Int curveAxis);
196 
197 
205 };
206 
207 
208 
209 } //# NAMESPACE CASACORE - END
210 
211 #ifndef CASACORE_NO_AUTO_TEMPLATES
212 #include <casacore/lattices/Lattices/CurvedLattice2D.tcc>
213 #endif //# CASACORE_NO_AUTO_TEMPLATES
214 #endif
casacore::Slicer
Definition: Slicer.h:290
casacore::IPosition
Definition: IPosition.h:120
casacore::CurvedLattice2D::makeMapping
void makeMapping(uInt axis1, uInt axis2, Int curveAxis)
Make the AxesMapping object to map input to output axes.
casacore::CurvedLattice2D::CurvedLattice2D
CurvedLattice2D(const MaskedLattice< T > &, const CLInterpolator2D< T > &, const PixelCurve1D &, uInt axis1, uInt axis2, Int curveAxis=-1)
Take a curved slice from the given MaskedLattice.
casacore::MaskedLattice
Definition: MaskedLattice.h:218
casacore::CurvedLattice2D::itsLatticePtr
MaskedLattice< T > * itsLatticePtr
Definition: CurvedLattice2D.h:198
casacore::CurvedLattice2D::doPutSlice
virtual void doPutSlice(const Array< T > &sourceBuffer, const IPosition &where, const IPosition &stride)
Do the actual getting of an array of values.
casacore::CurvedLattice2D::isMasked
virtual Bool isMasked() const
Is the lattice masked? It is if its parent lattice is masked.
casacore::CurvedLattice2D::getRegionPtr
virtual const LatticeRegion * getRegionPtr() const
Get a pointer the region/mask object.
casacore::FileLocker::LockType
LockType
Define the possible lock types.
Definition: FileLocker.h:95
casacore::CurvedLattice2D::itsCurve
PixelCurve1D itsCurve
Definition: CurvedLattice2D.h:200
casacore::LatticeRegion
Definition: LatticeRegion.h:75
casacore::CurvedLattice2D::itsAxesMap
AxesMapping itsAxesMap
Definition: CurvedLattice2D.h:204
casacore::PixelCurve1D
Definition: PixelCurve1D.h:97
casacore::CurvedLattice2D::isPaged
virtual Bool isPaged() const
Is the lattice paged to disk?
casacore::False
const Bool False
Definition: aipstype.h:44
casacore::uInt
unsigned int uInt
Definition: aipstype.h:51
casacore::CurvedLattice2D::name
virtual String name(Bool stripPath=False) const
Return the name of the parent lattice.
casacore::CurvedLattice2D::flush
virtual void flush()
Flush the data.
casacore::CurvedLattice2D::operator=
CurvedLattice2D< T > & operator=(const CurvedLattice2D< T > &other)
Assignment (reference semantics)
casacore::CurvedLattice2D::CurvedLattice2D
CurvedLattice2D()
Default constructor.
casacore::CurvedLattice2D::doNiceCursorShape
virtual IPosition doNiceCursorShape(uInt maxPixels) const
Get the best cursor shape.
casacore::CurvedLattice2D::itsInterpolator
CLInterpolator2D< T > * itsInterpolator
Definition: CurvedLattice2D.h:199
casacore::Int
int Int
Definition: aipstype.h:50
casacore
this file contains all the compiler specific defines
Definition: mainpage.dox:28
casacore::CurvedLattice2D::advisedMaxPixels
virtual uInt advisedMaxPixels() const
This function returns the recommended maximum number of pixels to include in the cursor of an iterato...
casacore::AxesMapping
Definition: AxesMapping.h:88
casacore::CurvedLattice2D::itsAxis1
uInt itsAxis1
Definition: CurvedLattice2D.h:201
casacore::CurvedLattice2D::~CurvedLattice2D
virtual ~CurvedLattice2D()
Destructor, does nothing.
casacore::CurvedLattice2D::isWritable
virtual Bool isWritable() const
The lattice is not writable.
casacore::CurvedLattice2D::hasLock
virtual Bool hasLock(FileLocker::LockType) const
casacore::CurvedLattice2D::resync
virtual void resync()
Resynchronize the Lattice object with the lattice file.
casacore::CurvedLattice2D::reopen
virtual void reopen()
If needed, reopen a temporarily closed Lattice.
casacore::CurvedLattice2D::itsAxis2
uInt itsAxis2
Definition: CurvedLattice2D.h:202
casacore::CurvedLattice2D::tempClose
virtual void tempClose()
Close the Lattice temporarily (if it is paged to disk).
casacore::Array
template <class T, class U> class vector;
Definition: Array.h:167
casacore::String
String: the storage and methods of handling collections of characters.
Definition: String.h:223
casacore::Bool
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
casacore::CurvedLattice2D
Definition: CurvedLattice2D.h:83
casacore::CurvedLattice2D::itsCurveAxis
uInt itsCurveAxis
Definition: CurvedLattice2D.h:203
casacore::CurvedLattice2D::lock
virtual Bool lock(FileLocker::LockType, uInt nattempts)
Handle ocking of the lattice which is delegated to its parent.
casacore::CLInterpolator2D
Definition: CLInterpolator2D.h:89
casacore::CurvedLattice2D::doGetSlice
virtual Bool doGetSlice(Array< T > &buffer, const Slicer &section)
Do the actual getting of an array of values.
casacore::CurvedLattice2D::ok
virtual Bool ok() const
Check class internals - used for debugging.
casacore::CurvedLattice2D::cloneML
virtual MaskedLattice< T > * cloneML() const
Make a copy of the object (reference semantics).
casacore::CurvedLattice2D::unlock
virtual void unlock()
casacore::CurvedLattice2D::shape
virtual IPosition shape() const
Returns the shape of the lattice.
casacore::CurvedLattice2D::CurvedLattice2D
CurvedLattice2D(const CurvedLattice2D< T > &other)
Copy constructor (reference semantics)
casacore::CurvedLattice2D::doGetMaskSlice
virtual Bool doGetMaskSlice(Array< Bool > &buffer, const Slicer &section)
Get a section of the mask.