casa
$Rev:20696$
|
00001 //# WCLELMask.h: Class to define a mask as a LEL expression 00002 //# Copyright (C) 2000,2003 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 //# $Id: WCLELMask.h 20615 2009-06-09 02:16:01Z Malte.Marquarding $ 00026 00027 00028 00029 #ifndef IMAGES_WCLELMASK_H 00030 #define IMAGES_WCLELMASK_H 00031 00032 //# Includes 00033 #include <images/Regions/WCRegion.h> 00034 #include <lattices/Lattices/RegionType.h> 00035 #include <coordinates/Coordinates/CoordinateSystem.h> 00036 #include <casa/Arrays/Vector.h> 00037 #include <casa/Quanta/Quantum.h> 00038 00039 namespace casa { //# NAMESPACE CASA - BEGIN 00040 00041 //# Forward Declarations 00042 class LCRegion; 00043 class TableRecord; 00044 class IPosition; 00045 template<class T> class ImageExpr; 00046 template<class T> class LatticeExpr; 00047 class LatticeExprNode; 00048 00049 00050 // <summary> 00051 // Class to define a mask as a LEL expression 00052 // </summary> 00053 00054 // <use visibility=export> 00055 00056 // <reviewed reviewer="" date="" tests=""> 00057 // </reviewed> 00058 00059 // <prerequisite> 00060 // <li> <linkto class=WCRegion>WCRegion</linkto> 00061 // <li> <linkto class=ImageExpr>ImageExpr</linkto> 00062 // </prerequisite> 00063 00064 // <synopsis> 00065 // The WCLELMask class is a specialization of class 00066 // <linkto class=WCRegion>WCRegion</linkto>. 00067 // <br> 00068 // It can be used to define an on-the-fly mask for an image 00069 // using a boolean <linkto class=LatticeExpr>LatticeExpr</linkto>. 00070 // The contents of the mask are calculated on the fly from the expression. 00071 // Thus the mask may change if the data in the image(s) used in the 00072 // expression change. 00073 // <note role=caution> 00074 // This mask is only persistent if constructed from an expression string. 00075 // When constructed from an <linkto class=ImageExpr>ImageExpr</linkto> 00076 // the mask is not persistent. 00077 // </note> 00078 // </synopsis> 00079 00080 // <example> 00081 // </example> 00082 00083 // <motivation> 00084 // Users must be able to specify a mask based on an expression. 00085 // </motivation> 00086 00087 //# <todo asof="1998/05/20"> 00088 //# <li> 00089 //# </todo> 00090 00091 class WCLELMask : public WCRegion 00092 { 00093 public: 00094 WCLELMask(); 00095 00096 // Construct from the given expression command. 00097 // The command will be parsed and converted to an ImageExpr. 00098 // <group> 00099 explicit WCLELMask (const String& command); 00100 explicit WCLELMask (const char* command); 00101 // </group> 00102 00103 // Construct from the given image expression. 00104 explicit WCLELMask (const ImageExpr<Bool>& expr); 00105 00106 // Construct from the given lattice expression. 00107 explicit WCLELMask (const LatticeExpr<Bool>& expr); 00108 00109 // Construct from the given lattice expression. 00110 // This constructor makes it possible to have an expression with an 00111 // unknown shape (e.g. using LEL function INDEXIN). 00112 // If the shape is known, the LatticeExprNode will be converted to 00113 // a LatticeExpr<Bool>. 00114 explicit WCLELMask (const LatticeExprNode& expr); 00115 00116 // Copy constructor (copy semantics). 00117 WCLELMask (const WCLELMask& other); 00118 00119 // Destructor 00120 virtual ~WCLELMask(); 00121 00122 // Assignment (copy semantics) 00123 WCLELMask& operator= (const WCLELMask& other); 00124 00125 // Comparison 00126 virtual Bool operator== (const WCRegion& other) const; 00127 00128 // Clone a WCLELMask object. 00129 virtual WCRegion* cloneRegion() const; 00130 00131 // Get the dimensionality (i.e. the number of axes). 00132 virtual uInt ndim() const; 00133 00134 // WCLELMask cannot extend a region. 00135 virtual Bool canExtend() const; 00136 00137 // Convert to an LCRegion using the given new coordinate system and shape. 00138 // If the region has coordinates, the WCRegion implementation will 00139 // be called. Otherwise the LatticeExpr is returned after checking 00140 // that the shape matches. 00141 virtual LCRegion* toLCRegion (const CoordinateSystem& cSys, 00142 const IPosition& latticeShape) const; 00143 00144 // Convert to an LCRegion using the supplied <src>CoordinateSystem</src> 00145 // and shape. 00146 // It checks that coordinates match and that axes are not swapped. 00147 virtual LCRegion* doToLCRegion (const CoordinateSystem& cSys, 00148 const IPosition& latticeShape, 00149 const IPosition& pixelAxesMap, 00150 const IPosition& outOrder) const; 00151 00152 // Convert the WCLELMask object to a record. 00153 // The record can be used to make the object persistent. 00154 // The <src>tableName</src> argument can be used by derived 00155 // classes (e.g. LCPagedMask) to put very large objects. 00156 virtual TableRecord toRecord (const String& tableName) const; 00157 00158 // Convert to a WCLELMask from a record. 00159 static WCLELMask* fromRecord (const TableRecord& rec, 00160 const String& tableName); 00161 00162 // Returns WCLELMask 00163 static String className(); 00164 00165 // Return region type. Returns the class name 00166 virtual String type() const; 00167 00168 const ImageExpr<Bool>* getImageExpr() const {return itsImageExpr;} 00169 00170 private: 00171 // Process the command. 00172 void processCommand(); 00173 00174 // Initialize as a LatticeExprNode if expression's shape is unknown. 00175 // Otherwise as a LatticeExpr<Bool> if coordinates are unknown. 00176 // Otherwise as an ImageExpr<Bool>. 00177 void init (const LatticeExprNode& expr); 00178 00179 00180 String itsCommand; 00181 ImageExpr<Bool>* itsImageExpr; 00182 LatticeExpr<Bool>* itsLattExpr; 00183 LatticeExprNode* itsLattNode; 00184 }; 00185 00186 00187 00188 } //# NAMESPACE CASA - END 00189 00190 #endif