casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ExtendSpecifier.h
Go to the documentation of this file.
1 //# ExtendSpecifier.h: Specification of new and stretched lattice axes
2 //# Copyright (C) 2001
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 //#
27 //# $Id$
28 
29 #ifndef CASA_EXTENDSPECIFIER_H
30 #define CASA_EXTENDSPECIFIER_H
31 
32 
33 //# Includes
34 #include <casacore/casa/aips.h>
36 
37 namespace casacore { //# NAMESPACE CASACORE - BEGIN
38 
39 //# Forward Declarations
40 class Slicer;
41 template<class T> class Block;
42 
43 // <summary>
44 // Specification of new and stretched lattice axes
45 // </summary>
46 
47 // <use visibility=local>
48 
49 // <reviewed reviewer="" date="yyyy/mm/dd" tests="tExtendSpecifier.cc" demos="">
50 // </reviewed>
51 
52 // <prerequisite>
53 // <li> <linkto class="IPosition">IPosition</linkto>
54 // </prerequisite>
55 
56 // <synopsis>
57 // ExtendSpecifier is a class internally used by class
58 // <linkto class=ExtendLattice>ExtendLattice</linkto>.
59 // It holds the information which axes are stretched and which axes
60 // are new. Note that a stretched axis has to have length 1 in the
61 // original shape.
62 // <p>
63 // The class only contains the functionality needed by ExtendLattice.
64 // which are (mainly) 2 conversion functions. One function converts
65 // a slicer from the extended lattice to the original lattice, so
66 // ExtendLattice can read the correct data.
67 // The other function converts a shape in the original lattice to the
68 // shape in the extended lattice.
69 // <br>Some data is precalculated for more efficient processing
70 // of the conversion of slicers and shapes.
71 // </synopsis>
72 
73 // <example>
74 // <srcblock>
75 // IPosition oldShape(4,10,1,3,1);
76 // IPosition newShape(5,10,1,5,3,8);
77 // ExtendSpecifier spec (oldShape, newShape, IPosition(1,2), IPosition(1,4));
78 // </srcblock>
79 // This example extends the old shape to the new shape.
80 // <br>The 3rd argument tells that axes 2 is new. The newShape tells that
81 // its length will be 5. Note that adding this axis means that axes 2
82 // in the old shape will get axes 3 in the new shape.
83 // <br>The 4th argument tells that axes 4 (in the new shape!!) is stretched
84 // (to 8 according to newShape).
85 // </example>
86 
87 //# <todo asof="yyyy/mm/dd">
88 //# </todo>
89 
91 {
92 public:
93  // Default constructor generates empty IPositions.
95 
96  // Tell if no or all degenerate axes have to be removed.
98  const IPosition& newShape,
99  const IPosition& newAxes,
100  const IPosition& stretchAxes);
101 
102  // Copy constructor (copy semantics).
103  ExtendSpecifier(const ExtendSpecifier& other);
104 
106 
107  // Assignment (copy semantics).
108  // This and that do not have to have the same length.
110 
111  // Return the new shape.
112  const IPosition& newShape() const
113  { return itsNewShape; }
114 
115  // Return the new axes.
116  const IPosition& newAxes() const
117  { return itsNewAxes; }
118 
119  // Return the axes to be stretched.
120  const IPosition& stretchAxes() const
121  { return itsStretchAxes; }
122 
123  // Return the old shape.
124  const IPosition& oldShape() const
125  { return itsOldShape; }
126 
127  // Return the axes to be extended (i.e. new and stretch axes).
128  const IPosition& extendAxes() const
129  { return itsExtendAxes; }
130 
131  // Return the old axes (i.e. axes new nor stretched) as in old shape.
132  const IPosition& oldOldAxes() const
133  { return itsOldOldAxes; }
134 
135  // Return the old axes as in new shape.
136  const IPosition& oldNewAxes() const
137  { return itsOldNewAxes; }
138 
139  // Convert the slicer to the specification for the old shape.
140  // It fills <src>shape</src> with the shape to reform the section
141  // length such that it contains the new axes.
142  Slicer convert (IPosition& shape, const Slicer& section) const;
143 
144  // Convert a shape to the specification for the new shape.
145  IPosition convertNew (const IPosition& oldShape) const;
146 
147 private:
148  // Fill the flags for the given axes.
149  // It throws an exception if the axis is invalid or multiply given.
150  void fill (Block<Bool>& flags, const IPosition& axes) const;
151 
152 
160 };
161 
162 
163 
164 } //# NAMESPACE CASACORE - END
165 
166 #endif
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:119
const IPosition & newAxes() const
Return the new axes.
ExtendSpecifier & operator=(const ExtendSpecifier &other)
Assignment (copy semantics).
const IPosition & oldOldAxes() const
Return the old axes (i.e.
const IPosition & stretchAxes() const
Return the axes to be stretched.
void fill(Block< Bool > &flags, const IPosition &axes) const
Fill the flags for the given axes.
const IPosition & newShape() const
Return the new shape.
ExtendSpecifier()
Default constructor generates empty IPositions.
const IPosition & extendAxes() const
Return the axes to be extended (i.e.
TableExprNode shape(const TableExprNode &array)
Function operating on any scalar or array resulting in a Double array containing the shape...
Definition: ExprNode.h:1944
Specify which elements to extract from an n-dimensional array.
Definition: Slicer.h:289
IPosition convertNew(const IPosition &oldShape) const
Convert a shape to the specification for the new shape.
simple 1-D array
Slicer convert(IPosition &shape, const Slicer &section) const
Convert the slicer to the specification for the old shape.
Specification of new and stretched lattice axes.
const IPosition & oldShape() const
Return the old shape.
const IPosition & oldNewAxes() const
Return the old axes as in new shape.
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42