casacore
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_2_H
30 #define CASA_EXTENDSPECIFIER_2_H
31 
32 
33 //# Includes
34 #include "IPosition.h"
35 
36 namespace casacore { //# NAMESPACE CASACORE - BEGIN
37 
38 //# Forward Declarations
39 class Slicer;
40 
41 // <summary>
42 // Specification of new and stretched lattice axes
43 // </summary>
44 
45 // <use visibility=local>
46 
47 // <reviewed reviewer="" date="yyyy/mm/dd" tests="tExtendSpecifier.cc" demos="">
48 // </reviewed>
49 
50 // <prerequisite>
51 // <li> <linkto class="IPosition">IPosition</linkto>
52 // </prerequisite>
53 
54 // <synopsis>
55 // ExtendSpecifier is a class internally used by casacore class
56 // ExtendLattice.
57 // It holds the information which axes are stretched and which axes
58 // are new. Note that a stretched axis has to have length 1 in the
59 // original shape.
60 // <p>
61 // The class only contains the functionality needed by ExtendLattice.
62 // which are (mainly) 2 conversion functions. One function converts
63 // a slicer from the extended lattice to the original lattice, so
64 // ExtendLattice can read the correct data.
65 // The other function converts a shape in the original lattice to the
66 // shape in the extended lattice.
67 // <br>Some data is precalculated for more efficient processing
68 // of the conversion of slicers and shapes.
69 // </synopsis>
70 
71 // <example>
72 // <srcblock>
73 // IPosition oldShape(4,10,1,3,1);
74 // IPosition newShape(5,10,1,5,3,8);
75 // ExtendSpecifier spec (oldShape, newShape, IPosition(1,2), IPosition(1,4));
76 // </srcblock>
77 // This example extends the old shape to the new shape.
78 // <br>The 3rd argument tells that axes 2 is new. The newShape tells that
79 // its length will be 5. Note that adding this axis means that axes 2
80 // in the old shape will get axes 3 in the new shape.
81 // <br>The 4th argument tells that axes 4 (in the new shape!!) is stretched
82 // (to 8 according to newShape).
83 // </example>
84 
85 //# <todo asof="yyyy/mm/dd">
86 //# </todo>
87 
89 {
90 public:
91  // Default constructor generates empty IPositions.
93 
94  // Tell if no or all degenerate axes have to be removed.
96  const IPosition& newShape,
97  const IPosition& newAxes,
98  const IPosition& stretchAxes);
99 
100  // Return the new shape.
101  const IPosition& newShape() const
102  { return itsNewShape; }
103 
104  // Return the new axes.
105  const IPosition& newAxes() const
106  { return itsNewAxes; }
107 
108  // Return the axes to be stretched.
109  const IPosition& stretchAxes() const
110  { return itsStretchAxes; }
111 
112  // Return the old shape.
113  const IPosition& oldShape() const
114  { return itsOldShape; }
115 
116  // Return the axes to be extended (i.e. new and stretch axes).
117  const IPosition& extendAxes() const
118  { return itsExtendAxes; }
119 
120  // Return the old axes (i.e. axes new nor stretched) as in old shape.
121  const IPosition& oldOldAxes() const
122  { return itsOldOldAxes; }
123 
124  // Return the old axes as in new shape.
125  const IPosition& oldNewAxes() const
126  { return itsOldNewAxes; }
127 
128  // Convert the slicer to the specification for the old shape.
129  // It fills <src>shape</src> with the shape to reform the section
130  // length such that it contains the new axes.
131  Slicer convert (IPosition& shape, const Slicer& section) const;
132 
133  // Convert a shape to the specification for the new shape.
135 
136 private:
137  // Fill the flags for the given axes.
138  // It throws an exception if the axis is invalid or multiply given.
139  void fill (bool* flags, size_t nrdim, const IPosition& axes) const;
140 
148 };
149 
150 } //# NAMESPACE CASACORE - END
151 
152 #endif
void fill(bool *flags, size_t nrdim, const IPosition &axes) const
Fill the flags for the given axes.
const IPosition & stretchAxes() const
Return the axes to be stretched.
const IPosition & oldOldAxes() const
Return the old axes (i.e.
Slicer convert(IPosition &shape, const Slicer &section) const
Convert the slicer to the specification for the old shape.
ExtendSpecifier(const IPosition &oldShape, const IPosition &newShape, const IPosition &newAxes, const IPosition &stretchAxes)
Tell if no or all degenerate axes have to be removed.
const IPosition & newShape() const
Return the new shape.
const IPosition & oldShape() const
Return the old shape.
const IPosition & extendAxes() const
Return the axes to be extended (i.e.
const IPosition & oldNewAxes() const
Return the old axes as in new shape.
IPosition convertNew(const IPosition &oldShape) const
Convert a shape to the specification for the new shape.
const IPosition & newAxes() const
Return the new axes.
ExtendSpecifier()
Default constructor generates empty IPositions.
this file contains all the compiler specific defines
Definition: mainpage.dox:28
TableExprNode shape(const TableExprNode &array)
Function operating on any scalar or array resulting in a Double array containing the shape.
Definition: ExprNode.h:1987