00001 //# Copyright (C) 1998,1999,2000,2001,2003 00002 //# Associated Universities, Inc. Washington DC, USA. 00003 //# 00004 //# This program is free software; you can redistribute it and/or modify it 00005 //# under the terms of the GNU General Public License as published by the Free 00006 //# Software Foundation; either version 2 of the License, or (at your option) 00007 //# any later version. 00008 //# 00009 //# This program is distributed in the hope that it will be useful, but WITHOUT 00010 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00011 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 00012 //# more details. 00013 //# 00014 //# You should have received a copy of the GNU General Public License along 00015 //# with this program; if not, write to the Free Software Foundation, Inc., 00016 //# 675 Massachusetts Ave, Cambridge, MA 02139, USA. 00017 //# 00018 //# Correspondence concerning AIPS++ should be addressed as follows: 00019 //# Internet email: aips2-request@nrao.edu. 00020 //# Postal address: AIPS++ Project Office 00021 //# National Radio Astronomy Observatory 00022 //# 520 Edgemont Road 00023 //# Charlottesville, VA 22903-2475 USA 00024 //# 00025 00026 #ifndef IMAGES_IMAGEINPUTPROCESSOR_H 00027 #define IMAGES_IMAGEINPUTPROCESSOR_H 00028 00029 #include <images/Images/ImageInterface.h> 00030 00031 #include <imageanalysis/ImageTypedefs.h> 00032 #include <imageanalysis/IO/OutputDestinationChecker.h> 00033 #include <imageanalysis/Regions/CasacRegionManager.h> 00034 00035 #include <casa/namespace.h> 00036 00037 namespace casa { 00038 00039 class ImageInputProcessor { 00040 // <summary> 00041 // Collection of methods for processing inputs to image analysis applications 00042 // </summary> 00043 00044 // <reviewed reviewer="" date="" tests="" demos=""> 00045 // </reviewed> 00046 00047 // <prerequisite> 00048 // </prerequisite> 00049 00050 // <etymology> 00051 // Processes inputs to image analysis apps. 00052 // </etymology> 00053 00054 // <synopsis> 00055 // Collection of methods for processing inputs to image analysis applications 00056 // </synopsis> 00057 00058 public: 00059 00060 //constructor 00061 ImageInputProcessor(); 00062 00063 //Destructor 00064 ~ImageInputProcessor(); 00065 00066 // Process the inputs. Output parameters are the pointer to the 00067 // opened <src>image</src>, the specified region as a record (<src> 00068 // regionRecord</src>, and a <src>diagnostics</src> String describing 00069 // how the region was chosen. If provided, <src>regionPtr</src> should 00070 // be a pointer to a record created by a RegionManager method. 00071 // <src>stokesControl</src> indicates default 00072 // stokes range to use if <src>stokes</src> is blank. In this case <src>stokes</src> 00073 // will be set the the value of stokes that will be used. If 00074 // <src>allowMultipleBoxes</src> is False, an exception will be thrown if 00075 // the inputs specify multiple n-dimensional rectangles. This should usually 00076 // be set to false if the caller can only deal with a single n-dimensional 00077 // rectangular region. 00078 /* 00079 template<class T> void process( 00080 SPIIT image, Record& regionRecord, 00081 String& diagnostics, 00082 std::vector<OutputDestinationChecker::OutputStruct> *const outputStruct, 00083 String& stokes, const String& imagename, 00084 const Record* regionPtr, const String& regionName, 00085 const String& box, const String& chans, 00086 const CasacRegionManager::StokesControl& stokesControl, 00087 const Bool& allowMultipleBoxes, 00088 const std::vector<Coordinate::Type> *const &requiredCoordinateTypes, 00089 Bool verbose=True 00090 ); 00091 */ 00092 // Process the inputs. Use this version if the associated image already exists. 00093 // Output parameters the specified region as a record (<src> 00094 // regionRecord</src>, and a <src>diagnostics</src> String describing 00095 // how the region was chosen. If provided, <src>regionPtr</src> should 00096 // be a pointer to a record created by a RegionManager method. 00097 // <src>stokesControl</src> indicates default 00098 // stokes range to use if <src>stokes</src> is blank. In this case <src>stokes</src> 00099 // will be set the the value of stokes that will be used. If 00100 // <src>allowMultipleBoxes</src> is False, an exception will be thrown if 00101 // the inputs specify multiple n-dimensional rectangles. This should usually 00102 // be set to false if the caller can only deal with a single n-dimensional 00103 // rectangular region. 00104 template<class T> void process( 00105 Record& regionRecord, 00106 String& diagnostics, 00107 std::vector<OutputDestinationChecker::OutputStruct> *const outputStruct, 00108 String& stokes, 00109 SPCIIT image, 00110 const Record* regionPtr, 00111 const String& regionName, const String& box, 00112 const String& chans, 00113 const CasacRegionManager::StokesControl& stokesControl, 00114 const Bool& allowMultipleBoxes, 00115 const std::vector<Coordinate::Type> *const &requiredCoordinateTypes, 00116 Bool verbose=True 00117 ); 00118 00119 // Get the number of channels that have been selected. The process() method must 00120 // be called prior to calling this method or an exception is thrown. 00121 uInt nSelectedChannels() const; 00122 00123 private: 00124 LogIO *_log; 00125 Bool _processHasRun; 00126 uInt _nSelectedChannels; 00127 00128 template<class T> void _process( 00129 Record& regionRecord, String& diagnostics, 00130 std::vector<OutputDestinationChecker::OutputStruct>* outputStruct, 00131 String& stokes, SPCIIT image, 00132 const Record *const ®ionPtr, 00133 const String& regionName, const String& box, 00134 const String& chans, const CasacRegionManager::StokesControl& stokesControl, 00135 const Bool& allowMultipleBoxes, 00136 const std::vector<Coordinate::Type> *const &requiredCoordinateTypes, Bool verbose 00137 ); 00138 00139 // set region given a pointer to a region record. 00140 void _setRegion( 00141 Record& regionRecord, String& diagnostics, 00142 const Record *const regionPtr 00143 ) const; 00144 00145 template<class T> void _setRegion(Record& regionRecord, String& diagnostics, 00146 const ImageInterface<T> *const image, const String& regionName 00147 ) const; 00148 00149 String _stokesFromRecord( 00150 const Record& region, const CoordinateSystem& csys 00151 ) const; 00152 00153 String _pairsToString(const std::vector<uInt>& pairs) const; 00154 00155 }; 00156 } 00157 00158 #ifndef AIPS_NO_TEMPLATE_SRC 00159 #include <imageanalysis/ImageAnalysis/ImageInputProcessor2.tcc> 00160 #endif 00161 00162 #endif /* IMAGES_IMAGEINPUTPROCESSOR_H */