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