casa
$Rev:20696$
|
00001 //# ExtendSpecifier.h: Specification of new and stretched lattice axes 00002 //# Copyright (C) 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: ExtendSpecifier.h 20551 2009-03-25 00:11:33Z Malte.Marquarding $ 00028 00029 #ifndef CASA_EXTENDSPECIFIER_H 00030 #define CASA_EXTENDSPECIFIER_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 template<class T> class Block; 00042 00043 // <summary> 00044 // Specification of new and stretched lattice axes 00045 // </summary> 00046 00047 // <use visibility=local> 00048 00049 // <reviewed reviewer="" date="yyyy/mm/dd" tests="tExtendSpecifier.cc" demos=""> 00050 // </reviewed> 00051 00052 // <prerequisite> 00053 // <li> <linkto class="IPosition">IPosition</linkto> 00054 // </prerequisite> 00055 00056 // <synopsis> 00057 // ExtendSpecifier is a class internally used by class 00058 // <linkto class=ExtendLattice>ExtendLattice</linkto>. 00059 // It holds the information which axes are stretched and which axes 00060 // are new. Note that a stretched axis has to have length 1 in the 00061 // original shape. 00062 // <p> 00063 // The class only contains the functionality needed by ExtendLattice. 00064 // which are (mainly) 2 conversion functions. One function converts 00065 // a slicer from the extended lattice to the original lattice, so 00066 // ExtendLattice can read the correct data. 00067 // The other function converts a shape in the original lattice to the 00068 // shape in the extended lattice. 00069 // <br>Some data is precalculated for more efficient processing 00070 // of the conversion of slicers and shapes. 00071 // </synopsis> 00072 00073 // <example> 00074 // <srcblock> 00075 // IPosition oldShape(4,10,1,3,1); 00076 // IPosition newShape(5,10,1,5,3,8); 00077 // ExtendSpecifier spec (oldShape, newShape, IPosition(1,2), IPosition(1,4)); 00078 // </srcblock> 00079 // This example extends the old shape to the new shape. 00080 // <br>The 3rd argument tells that axes 2 is new. The newShape tells that 00081 // its length will be 5. Note that adding this axis means that axes 2 00082 // in the old shape will get axes 3 in the new shape. 00083 // <br>The 4th argument tells that axes 4 (in the new shape!!) is stretched 00084 // (to 8 according to newShape). 00085 // </example> 00086 00087 //# <todo asof="yyyy/mm/dd"> 00088 //# </todo> 00089 00090 class ExtendSpecifier 00091 { 00092 public: 00093 // Default constructor generates empty IPositions. 00094 ExtendSpecifier(); 00095 00096 // Tell if no or all degenerate axes have to be removed. 00097 ExtendSpecifier (const IPosition& oldShape, 00098 const IPosition& newShape, 00099 const IPosition& newAxes, 00100 const IPosition& stretchAxes); 00101 00102 // Copy constructor (copy semantics). 00103 ExtendSpecifier(const ExtendSpecifier& other); 00104 00105 ~ExtendSpecifier(); 00106 00107 // Assignment (copy semantics). 00108 // This and that do not have to have the same length. 00109 ExtendSpecifier& operator= (const ExtendSpecifier& other); 00110 00111 // Return the new shape. 00112 const IPosition& newShape() const 00113 { return itsNewShape; } 00114 00115 // Return the new axes. 00116 const IPosition& newAxes() const 00117 { return itsNewAxes; } 00118 00119 // Return the axes to be stretched. 00120 const IPosition& stretchAxes() const 00121 { return itsStretchAxes; } 00122 00123 // Return the old shape. 00124 const IPosition& oldShape() const 00125 { return itsOldShape; } 00126 00127 // Return the axes to be extended (i.e. new and stretch axes). 00128 const IPosition& extendAxes() const 00129 { return itsExtendAxes; } 00130 00131 // Return the old axes (i.e. axes new nor stretched) as in old shape. 00132 const IPosition& oldOldAxes() const 00133 { return itsOldOldAxes; } 00134 00135 // Return the old axes as in new shape. 00136 const IPosition& oldNewAxes() const 00137 { return itsOldNewAxes; } 00138 00139 // Convert the slicer to the specification for the old shape. 00140 // It fills <src>shape</src> with the shape to reform the section 00141 // length such that it contains the new axes. 00142 Slicer convert (IPosition& shape, const Slicer& section) const; 00143 00144 // Convert a shape to the specification for the new shape. 00145 IPosition convertNew (const IPosition& oldShape) const; 00146 00147 private: 00148 // Fill the flags for the given axes. 00149 // It throws an exception if the axis is invalid or multiply given. 00150 void fill (Block<Bool>& flags, const IPosition& axes) const; 00151 00152 00153 IPosition itsOldShape; 00154 IPosition itsNewShape; 00155 IPosition itsNewAxes; 00156 IPosition itsStretchAxes; 00157 IPosition itsExtendAxes; 00158 IPosition itsOldOldAxes; 00159 IPosition itsOldNewAxes; 00160 }; 00161 00162 00163 00164 } //# NAMESPACE CASA - END 00165 00166 #endif