casacore
Loading...
Searching...
No Matches
AxesMapping.h
Go to the documentation of this file.
1// # AxesMapping.h: Info about mapping array axes to another order
2// # Copyright (C) 2000,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_AXESMAPPING_2_H
27#define CASA_AXESMAPPING_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// Info about mapping array axes to another order.
39// </summary>
40
41// <use visibility=local>
42
43// <reviewed reviewer="" date="yyyy/mm/dd" tests="tAxesSpecifier.cc" demos="">
44// </reviewed>
45
46// <prerequisite>
47// <li> <linkto class="IPosition">IPosition</linkto>
48// <li> <linkto class="AxesSpecifier">AxesSpecifier</linkto>
49// </prerequisite>
50
51// <synopsis>
52// AxesMapping holds the information about mapping axes to another order.
53// It can be constructed by <linkto class=AxesSpecifier>AxesSpecifier</linkto>
54// by applying a shape to the axes specification.
55// <br>AxesMapping is thereafter used to map positions, shapes, and
56// slices to the new axes or backwards.
57// <note role=caution>
58// Shapes and positions are both represented by class IPosition.
59// However, they have to be treated differently in this class,
60// because removed axes for a position have value 0, while for a
61// shape they have value 1. Hence there are different functions for them
62// and the user has to take care that the correct function is called.
63// </note>
64// </synopsis>
65
66// <example>
67// <srcblock>
68//
69// </srcblock>
70// </example>
71
72// <motivation>
73// The class encapsulates the mapping functionality.
74// It is meant as a helper class for casacore's SubLattice.
75// </motivation>
76
77// # <todo asof="yyyy/mm/dd">
78// # </todo>
79
81 public:
82 // The default constructor creates empty maps.
84
85 // Construct it with the mapping from old to new axes order.
86 // A value of -1 means that the old axes is ignored in the new one.
87 // Another value gives the new axis number.
88 // <br>It determines if axes are removed and/or reordered.
89 explicit AxesMapping(const IPosition& oldToNew);
90
91 // Are axes removed?
92 bool isRemoved() const { return itsRemoved; }
93
94 // Is the axes order reordered?
95 bool isReordered() const { return itsReordered; }
96
97 // Get the mapping of old->new.
98 // The length of the resulting IPosition is the dimensionality of
99 // the original lattice. A value of -1 indicates that the corresponding
100 // axis in the original lattice is removed.
101 // Another value is the axis number in the new lattice,
102 const IPosition& getToNew() const { return itsToNew; }
103
104 // Get the mapping of new->old.
105 // The length of the resulting IPosition is the dimensionality of
106 // the new lattice. Its values give the axes in the original lattice.
107 const IPosition& getToOld() const { return itsToOld; }
108
109 // Map an old position to the new one.
110 // In debug-mode it checks if the removed axes have position 0
111 // in the input position.
112 IPosition posToNew(const IPosition& pos) const;
113
114 // Map a new position or shape to the old one.
115 IPosition posToOld(const IPosition& pos) const;
116
117 // Map an old shape to the new one.
118 // In debug-mode it checks if the removed axes have length 1
119 // in the input shape.
121
122 // Map a new position or shape to the old one.
124
125 // Map an old shape to the new one.
126 // In debug-mode it checks if the removed axes have length 1
127 // in the input slicer.
128 Slicer slicerToNew(const Slicer& slicer) const;
129
130 // Map a new position or shape to the old one.
131 Slicer slicerToOld(const Slicer& slicer) const;
132
133 private:
138};
139
140} // namespace casacore
141
142#endif
AxesMapping(const IPosition &oldToNew)
Construct it with the mapping from old to new axes order.
const IPosition & getToNew() const
Get the mapping of old->new.
IPosition posToNew(const IPosition &pos) const
Map an old position to the new one.
IPosition shapeToOld(const IPosition &shape) const
Map a new position or shape to the old one.
bool isRemoved() const
Are axes removed?
Definition AxesMapping.h:92
IPosition posToOld(const IPosition &pos) const
Map a new position or shape to the old one.
Slicer slicerToNew(const Slicer &slicer) const
Map an old shape to the new one.
IPosition shapeToNew(const IPosition &shape) const
Map an old shape to the new one.
const IPosition & getToOld() const
Get the mapping of new->old.
AxesMapping()
The default constructor creates empty maps.
Slicer slicerToOld(const Slicer &slicer) const
Map a new position or shape to the old one.
bool isReordered() const
Is the axes order reordered?
Definition AxesMapping.h:95
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.