casa
$Rev:20696$
|
00001 //# AxesMapping.h: Info about mapping array axes to another order 00002 //# Copyright (C) 2000,2001 00003 //# Associated Universities, Inc. Washington DC, USA. 00004 //# 00005 //# This library is free software; you can redistribute it and/or modify it 00006 //# under the terms of the GNU Library General Public License as published by 00007 //# the Free Software Foundation; either version 2 of the License, or (at your 00008 //# option) any later version. 00009 //# 00010 //# This library is distributed in the hope that it will be useful, but WITHOUT 00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00012 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00013 //# License for more details. 00014 //# 00015 //# You should have received a copy of the GNU Library General Public License 00016 //# along with this library; if not, write to the Free Software Foundation, 00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. 00018 //# 00019 //# Correspondence concerning AIPS++ should be addressed as follows: 00020 //# Internet email: aips2-request@nrao.edu. 00021 //# Postal address: AIPS++ Project Office 00022 //# National Radio Astronomy Observatory 00023 //# 520 Edgemont Road 00024 //# Charlottesville, VA 22903-2475 USA 00025 //# 00026 //# 00027 //# $Id: AxesMapping.h 20551 2009-03-25 00:11:33Z Malte.Marquarding $ 00028 00029 #ifndef CASA_AXESMAPPING_H 00030 #define CASA_AXESMAPPING_H 00031 00032 00033 //# Includes 00034 #include <casa/aips.h> 00035 #include <casa/Arrays/IPosition.h> 00036 00037 namespace casa { //# NAMESPACE CASA - BEGIN 00038 00039 //# Forward Declarations 00040 class Slicer; 00041 00042 00043 // <summary> 00044 // Info about mapping array axes to another order. 00045 // </summary> 00046 00047 // <use visibility=local> 00048 00049 // <reviewed reviewer="" date="yyyy/mm/dd" tests="tAxesSpecifier.cc" demos=""> 00050 // </reviewed> 00051 00052 // <prerequisite> 00053 // <li> <linkto class="IPosition">IPosition</linkto> 00054 // <li> <linkto class="AxesSpecifier">AxesSpecifier</linkto> 00055 // </prerequisite> 00056 00057 // <synopsis> 00058 // AxesMapping holds the information about mapping axes to another order. 00059 // It can be constructed by <linkto class=AxesSpecifier>AxesSpecifier</linkto> 00060 // by applying a shape to the axes specification. 00061 // <br>AxesMapping is thereafter used to map positions, shapes, and 00062 // slices to the new axes or backwards. 00063 // <note role=caution> 00064 // Shapes and positions are both represented by class IPosition. 00065 // However, they have to be treated differently in this class, 00066 // because removed axes for a position have value 0, while for a 00067 // shape they have value 1. Hence there are different functions for them 00068 // and the user has to take care that the correct function is called. 00069 // </note> 00070 // </synopsis> 00071 00072 // <example> 00073 // <srcblock> 00074 // 00075 // </srcblock> 00076 // </example> 00077 00078 // <motivation> 00079 // The class encapsulates the mapping functionality. 00080 // It is meant as a helper class for 00081 // <linkto class=SubLattice>SubLattice</linkto>. 00082 // </motivation> 00083 00084 //# <todo asof="yyyy/mm/dd"> 00085 //# </todo> 00086 00087 class AxesMapping 00088 { 00089 public: 00090 // The default constructor creates empty maps. 00091 AxesMapping(); 00092 00093 // Construct it with the mapping from old to new axes order. 00094 // A value of -1 means that the old axes is ignored in the new one. 00095 // Another value gives the new axis number. 00096 // <br>It determines if axes are removed and/or reordered. 00097 explicit AxesMapping (const IPosition& oldToNew); 00098 00099 // Copy constructor (copy semantics). 00100 AxesMapping(const AxesMapping& other); 00101 00102 ~AxesMapping(); 00103 00104 // Assignment (copy semantics). 00105 // This and that do not have to have the same length. 00106 AxesMapping& operator= (const AxesMapping& other); 00107 00108 // Are axes removed? 00109 Bool isRemoved() const 00110 { return itsRemoved; } 00111 00112 // Is the axes order reordered? 00113 Bool isReordered() const 00114 { return itsReordered; } 00115 00116 // Get the mapping of old->new. 00117 // The length of the resulting IPosition is the dimensionality of 00118 // the original lattice. A value of -1 indicates that the corresponding 00119 // axis in the original lattice is removed. 00120 // Another value is the axis number in the new lattice, 00121 const IPosition& getToNew() const 00122 { return itsToNew; } 00123 00124 // Get the mapping of new->old. 00125 // The length of the resulting IPosition is the dimensionality of 00126 // the new lattice. Its values give the axes in the original lattice. 00127 const IPosition& getToOld() const 00128 { return itsToOld; } 00129 00130 // Map an old position to the new one. 00131 // In debug-mode it checks if the removed axes have position 0 00132 // in the input position. 00133 IPosition posToNew (const IPosition& pos) const; 00134 00135 // Map a new position or shape to the old one. 00136 IPosition posToOld (const IPosition& pos) const; 00137 00138 // Map an old shape to the new one. 00139 // In debug-mode it checks if the removed axes have length 1 00140 // in the input shape. 00141 IPosition shapeToNew (const IPosition& shape) const; 00142 00143 // Map a new position or shape to the old one. 00144 IPosition shapeToOld (const IPosition& shape) const; 00145 00146 // Map an old shape to the new one. 00147 // In debug-mode it checks if the removed axes have length 1 00148 // in the input slicer. 00149 Slicer slicerToNew (const Slicer& slicer) const; 00150 00151 // Map a new position or shape to the old one. 00152 Slicer slicerToOld (const Slicer& slicer) const; 00153 00154 private: 00155 IPosition itsToNew; 00156 IPosition itsToOld; 00157 Bool itsRemoved; 00158 Bool itsReordered; 00159 }; 00160 00161 00162 00163 } //# NAMESPACE CASA - END 00164 00165 #endif