casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LatticeSlice1D.h
Go to the documentation of this file.
1 //# LatticeSlice1D.h: 1-D slice from a Lattice
2 //# Copyright (C) 1996,1997,1998,1999,2000,2001,2002,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 received 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_LATTICESLICE1D_H
29 #define LATTICES_LATTICESLICE1D_H
30 
31 
32 //# Includes
33 #include <casacore/casa/aips.h>
36 
37 
38 namespace casacore { //# NAMESPACE CASACORE - BEGIN
39 
40 //# Forward Declarations
41 template <class T> class MaskedLattice;
42 class IPosition;
43 class Interpolate2D;
44 class PixelCurve1D;
45 class String;
46 
47 // <summary>
48 // Extract a 1-D slice from a Lattice
49 // </summary>
50 // <use visibility=export>
51 // <reviewed reviewer="" date="yyyy/mm/dd" tests="test/tLatticeSlice1D" demos="">
52 // </reviewed>
53 // <prerequisite>
54 // <li> <linkto class=MaskedLattice>MaskedLattice</linkto>
55 // </prerequisite>
56 
57 // <etymology>
58 // </etymology>
59 
60 // <synopsis>
61 // This class extracts an interpolated 1-D slice from a Lattice
62 // with a range of interpolation schemes available. The slice must lie in
63 // the plane of two cardinal axes.
64 // </synopsis>
65 //
66 // <note role=tip>
67 // </note>
68 //
69 // <example>
70 // <srcBlock>
71 // IPosition shape(2, 20, 30); // Create MaskedLattice
72 // ArrayLattice<Float> arrLat(shape);
73 // SubLattice<Float> subLat(arrLat);
74 // LatticeSlice1D<Float> slicer(subLat);
75 //
76 // IPosition blc(2); blc = 0; // Extract slice between corners
77 // IPosition trc(shape-1);
78 // Vector<Float> data;
79 // Vector<Bool> mask;
80 // slicer.getSlice (data, mask, blc, trc);
81 // </srcBlock>
82 // </example>
83 
84 // <motivation>
85 // Users often want to see cross-cuts through their data.
86 // </motivation>
87 
88 // <todo asof="2004/04/16">
89 // <li> Handle curves not in cardinal axis plane
90 // <li> Derive from MaskedLattice ?
91 // </todo>
92 
93 
94 template <class T> class LatticeSlice1D
95 {
96 public:
97 
98 // Interpolation method
99  enum Method {NEAREST=0, LINEAR=1, CUBIC=2, N_TYPES};
100 
101 // Default constructor - object useless
102  LatticeSlice1D ();
103 
104 // Constructor
105  LatticeSlice1D (const MaskedLattice<T>& lattice, Method method=LINEAR);
106 
107 // Copy constructor (reference semantics)
108  LatticeSlice1D(const LatticeSlice1D<T> &other);
109 
110 // Destructor
111  virtual ~LatticeSlice1D ();
112 
113 // Assignment operator (reference semantics)
115 
116 // Get 1-D slice. PixelCurve1D supplies the locus of the slice in
117 // the plane specified by axis0 and axis1. The pixel coordinate for
118 // the rest of the lattice is specified in <src>coord</src>.
119  void getSlice (Vector<T>& data, Vector<Bool>& mask,
120  const PixelCurve1D& curve, uInt axis0, uInt axis1,
121  const IPosition& coord);
122 
123 // Get 1-D slice between blc & trc. These start and end points must be
124 // in a cardinal plane of the lattice. If nPts is 0 it is set automatically to
125 // the length of the slice.
126  void getSlice (Vector<T>& data, Vector<Bool>& mask,
127  const IPosition& blc, const IPosition& trc, uInt nPts=0);
128 
129 // Get the (x,y) pixel coordinates from the last slice and the distance along
130 // the slice in pixels.. Also recover the axes of the slice plane
131  void getPosition (uInt& axis0, uInt& axis1, Vector<Float>& x,
132  Vector<Float>& y, Vector<Float>& distance) const;
133 
134 // Recover interpolation method
136 
137  static Method stringToMethod (const String& method);
138 
139 private:
140 // Check the suppliec curve is valid.
141  void checkCurve (IPosition& blc, IPosition& trc,
142  const IPosition& coord, const PixelCurve1D& curve);
143 // Find the slice plane.
144  void findPlane (const IPosition& blc,
145  const IPosition& trc);
146 // Get the interpolated slice
147  void doGetSlice (Vector<T>& data, Vector<Bool>& mask,
148  const PixelCurve1D& curve,
149  const IPosition& blc, const IPosition& trc);
150 // Make Interpolator
151  void makeInterpolator (Method method);
152 
153 //
162 };
163 
164 
165 } //# NAMESPACE CASACORE - END
166 
167 #ifndef CASACORE_NO_AUTO_TEMPLATES
168 #include <casacore/lattices/LatticeMath/LatticeSlice1D.tcc>
169 #endif //# CASACORE_NO_AUTO_TEMPLATES
170 #endif
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:118
void getPosition(uInt &axis0, uInt &axis1, Vector< Float > &x, Vector< Float > &y, Vector< Float > &distance) const
Get the (x,y) pixel coordinates from the last slice and the distance along the slice in pixels...
LatticeExprNode mask(const LatticeExprNode &expr)
This function returns the mask of the given expression.
void makeInterpolator(Method method)
Make Interpolator.
LatticeSlice1D()
Default constructor - object useless.
A templated, abstract base class for array-like objects with masks.
Definition: ImageConcat.h:46
Extract a 1-D slice from a Lattice.
void getSlice(Vector< T > &data, Vector< Bool > &mask, const PixelCurve1D &curve, uInt axis0, uInt axis1, const IPosition &coord)
Get 1-D slice.
Vector< Double > itsPos
MaskedLattice< T > * itsLatticePtr
Arbitrary 1-dim curve in a lattice plane.
Definition: PixelCurve1D.h:96
virtual ~LatticeSlice1D()
Destructor.
static Method stringToMethod(const String &method)
void doGetSlice(Vector< T > &data, Vector< Bool > &mask, const PixelCurve1D &curve, const IPosition &blc, const IPosition &trc)
Get the interpolated slice.
Method
Interpolation method.
void findPlane(const IPosition &blc, const IPosition &trc)
Find the slice plane.
LatticeSlice1D< T > & operator=(const LatticeSlice1D< T > &other)
Assignment operator (reference semantics)
A two dimension interpolator for Matrices or Arrays.
Definition: Interpolate2D.h:96
String: the storage and methods of handling collections of characters.
Definition: String.h:225
Interpolate2D * itsInterpPtr
Method interpolationMethod() const
Recover interpolation method.
void checkCurve(IPosition &blc, IPosition &trc, const IPosition &coord, const PixelCurve1D &curve)
Check the suppliec curve is valid.
unsigned int uInt
Definition: aipstype.h:51