casa
$Rev:20696$
|
00001 //# RegionManager.h: framework independent class that provides 00002 //# functionality to tool of same name 00003 //# Copyright (C) 2007 00004 //# Associated Universities, Inc. Washington DC, USA. 00005 //# 00006 //# This program is free software; you can redistribute it and/or modify it 00007 //# under the terms of the GNU General Public License as published by the Free 00008 //# Software Foundation; either version 2 of the License, or (at your option) 00009 //# any later version. 00010 //# 00011 //# This program is distributed in the hope that it will be useful, but WITHOUT 00012 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00013 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 00014 //# more details. 00015 //# 00016 //# You should have received a copy of the GNU General Public License along 00017 //# with this program; if not, write to the Free Software Foundation, Inc., 00018 //# 675 Massachusetts Ave, Cambridge, MA 02139, USA. 00019 //# 00020 //# Correspondence concerning AIPS++ should be addressed as follows: 00021 //# Internet email: aips2-request@nrao.edu. 00022 //# Postal address: AIPS++ Project Office 00023 //# National Radio Astronomy Observatory 00024 //# 520 Edgemont Road 00025 //# Charlottesville, VA 22903-2475 USA 00026 00027 #ifndef IMAGEANALYSIS_CASACREGIONMANAGER_H 00028 #define IMAGEANALYSIS_CASACREGIONMANAGER_H 00029 00030 #include <images/Regions/RegionManager.h> 00031 00032 namespace casa { 00033 00044 class CasacRegionManager: public RegionManager { 00045 00046 public: 00047 const static String ALL; 00048 00049 enum StokesControl { 00050 USE_FIRST_STOKES, 00051 USE_ALL_STOKES 00052 }; 00053 00054 CasacRegionManager(); 00055 CasacRegionManager(const CoordinateSystem& csys); 00056 ~CasacRegionManager(); 00057 00058 00059 // convert to a record a region specified by a rectangular directional <src>box</src>, 00060 // <src>chans</src>, and <src>stokes</src>, or althernatively a pointer to 00061 // a region record. If box, chans, or stokes is not blank, <src>regionPtr</src> should 00062 // be null. Processing happens in the following order: 00063 // 1. if <src>box</src> is not empty it, along with <src>chans</src> and <src>stokes</src> 00064 // if specified, are used to determine the returned record. In this case <src>stokes</src> 00065 // is not altered. 00066 // 2. else if <src>regionPtr</src> is not null, it is used to determine the returned Record. 00067 // In this case, stokes may be modified to reflect the stokes parameters included in the 00068 // corresponding region. 00069 // 3. else if <src>regionName</src> is not empty, the region file of the same is read and 00070 // used to create the record, or if <src>regionName</src> is of the form "imagename:regionname" the region 00071 // record is read from the corresponding iamge. In this case, stokes may be modified 00072 // to reflect the stokes parameters included in the corresponding region. 00073 // 4. else <src>chans</src> and <src>stokes</src> are used to determine the region Record, or 00074 // if not given, the whole <src>imShape</src> is used. 00075 // <src>box</src> is specified in comma seperated quadruplets representing blc and trc pixel 00076 // locations, eg "100, 110, 200, 205". <src>stokes</src> is specified as the concatentation of 00077 // stokes parameters, eg "IQUV". <src>chans</src> is specified in ways supported by CASA, eg 00078 // "1~10" for channels 1 through 10. 00079 00080 Record fromBCS( 00081 String& diagnostics, uInt& nSelectedChannels, String& stokes, 00082 const Record * const ®ionPtr, const String& regionName, 00083 const String& chans, const StokesControl stokesControl, 00084 const String& box, const IPosition& imShape, const String& imageName="", 00085 Bool verbose=True 00086 ); 00087 // <src>ranges</src> are pairs describing the pixel range over which to select. 00088 // If you want to select just one pixel in the "range", you must specify that pixel 00089 // in both parts of the pair. So if you want to select pixels 0 through 5 and pixel 13, 00090 // you'd specify ranges[0] = 0; ranges[1] = 5; ranges[2] = 13; ranges[3] = 13 00091 static vector<uInt> consolidateAndOrderRanges( 00092 uInt& nSelected, const vector<uInt>& ranges 00093 ); 00094 00095 static Record regionFromString( 00096 const CoordinateSystem& csys, const String& regionStr, 00097 const String& imageName, const IPosition& imShape 00098 ); 00099 00100 // Return the range(s) of spectral channels selected by the specification or the 00101 // region record (Note only one of <src>specification</src> or <src>regionRec</src> 00102 // may be specified). <src>imShape</src> is not used if <src>specification</src> 00103 // is in the "new" format (ie contains "range"). 00104 vector<uInt> setSpectralRanges( 00105 uInt& nSelectedChannels, 00106 const Record *const regionRec, const IPosition& imShape=IPosition(0) 00107 ) const; 00108 00109 vector<uInt> setSpectralRanges( 00110 String specification, uInt& nSelectedChannels, 00111 const IPosition& imShape=IPosition(0) 00112 ) const; 00113 00114 private: 00115 00116 String _pairsToString(const vector<uInt>& pairs) const; 00117 00118 vector<uInt> _setPolarizationRanges( 00119 String& specification, const String& firstStokes, const uInt nStokes, 00120 const StokesControl stokesControl 00121 ) const; 00122 00123 vector<Double> _setBoxCorners(const String& box) const; 00124 00125 ImageRegion _fromBCS( 00126 String& diagnostics, uInt& nSelectedChannels, String& stokes, 00127 const String& chans, const StokesControl stokesControl, 00128 const String& box, const IPosition& imShape 00129 ) const; 00130 00131 ImageRegion _fromBCS( 00132 String& diagnostics, 00133 const vector<Double>& boxCorners, const vector<uInt>& chanEndPts, 00134 const vector<uInt>& polEndPts, const IPosition imShape 00135 ) const; 00136 00137 static void _setRegion( 00138 Record& regionRecord, String& diagnostics, 00139 const Record* regionPtr 00140 ); 00141 00142 String _stokesFromRecord( 00143 const Record& region, const StokesControl stokesControl, const IPosition& shape 00144 ) const; 00145 00146 void _setRegion( 00147 Record& regionRecord, String& diagnostics, 00148 const String& regionName, const IPosition& imShape, 00149 const String& imageName 00150 ); 00151 00152 vector<uInt> _spectralRangesFromTraditionalFormat( 00153 uInt& nSelectedChannels, const String& specification, const uInt nChannels 00154 ) const; 00155 00156 vector<uInt> _spectralRangeFromRangeFormat( 00157 uInt& nSelectedChannels, const String& specification, 00158 const IPosition& imShape 00159 ) const; 00160 00161 vector<uInt> _spectralRangeFromRegionRecord( 00162 uInt& nSelectedChannels, const Record *const regionRec, 00163 const IPosition& imShape 00164 ) const; 00165 00166 // does the image support the setting of a two dimensional box(es). 00167 // If except is True, an exception will be thrown if this image does not 00168 // support it. If not, False is returned in that case. 00169 Bool _supports2DBox(Bool except) const; 00170 00171 vector<uInt> _initSpectralRanges(uInt& nSelectedChannels, const IPosition& imShape) const; 00172 }; 00173 00174 } // casa namespace 00175 #endif 00176