casa
$Rev:20696$
|
00001 //# LELRegion.h: Class to hold a region as a LEL node 00002 //# Copyright (C) 1999 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 //# $Id: LELRegion.h 20508 2009-01-20 11:09:47Z gervandiepen $ 00027 00028 #ifndef LATTICES_LELREGION_H 00029 #define LATTICES_LELREGION_H 00030 00031 00032 //# Includes 00033 #include <lattices/Lattices/LELInterface.h> 00034 #include <lattices/Lattices/LatticeRegion.h> 00035 00036 namespace casa { //# NAMESPACE CASA - BEGIN 00037 00038 //# Forward Declarations 00039 class LattRegionHolder; 00040 00041 00042 // <summary> 00043 // Class to hold a region as a LEL node 00044 // </summary> 00045 00046 // <use visibility=local> 00047 00048 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos=""> 00049 // </reviewed> 00050 00051 // <prerequisite> 00052 // <li> <linkto class="Lattice"> Lattice</linkto> 00053 // <li> <linkto class="LatticeExpr"> LatticeExpr</linkto> 00054 // <li> <linkto class="LatticeExprNode"> LatticeExprNode</linkto> 00055 // <li> <linkto class="LELInterface"> LELInterface</linkto> 00056 // </prerequisite> 00057 00058 // <etymology> 00059 // This derived LEL letter class handles regions. 00060 // </etymology> 00061 00062 // <synopsis> 00063 // This LEL letter class is derived from LELInterface. It 00064 // is used to construct LEL objects from regions. 00065 // The internal region is an <linkto class=ImageRegion>ImageRegion</linkto> 00066 // object, thus the region can be of any type. 00067 // With operator [] a region is applied to an image (expression). 00068 // At that stage possible world coordinates are converted to lattice 00069 // coordinates. 00070 // <p> 00071 // The attributes of a LELRegion object define an empty shape, 00072 // because in general the shape of a region is only known after 00073 // it is applied to an image. 00074 // <p> 00075 // A description of the implementation details of the LEL classes can 00076 // be found in 00077 // <a href="../notes/216.html">Note 216</a> 00078 // </synopsis> 00079 00080 // <motivation> 00081 // We needed to be able to handle regions in a LEL expression. 00082 // </motivation> 00083 00084 //# <todo asof="1998/01/21"> 00085 //# </todo> 00086 00087 00088 class LELRegion : public LELInterface<Bool> 00089 { 00090 public: 00091 // Constructor. 00092 LELRegion (const LattRegionHolder& region); 00093 00094 // Constructor. It takes over the pointer. 00095 LELRegion (LattRegionHolder* region); 00096 00097 // Destructor. 00098 ~LELRegion(); 00099 00100 // Get a pointer to the region object. 00101 const LattRegionHolder& region() const 00102 { return *region_p; } 00103 00104 // Getting region data cannot be done (throws an exception). 00105 virtual void eval(LELArray<Bool>&, const Slicer&) const; 00106 00107 // Getting region data cannot be done (throws an exception). 00108 virtual LELScalar<Bool> getScalar() const; 00109 00110 // Do further preparations (e.g. optimization) on the expression. 00111 virtual Bool prepareScalarExpr(); 00112 00113 // Get class name 00114 virtual String className() const; 00115 00116 // Form a compound from the regions. 00117 // <group> 00118 static LELRegion* makeUnion (const LELInterface<Bool>& left, 00119 const LELInterface<Bool>& right); 00120 static LELRegion* makeIntersection (const LELInterface<Bool>& left, 00121 const LELInterface<Bool>& right); 00122 static LELRegion* makeDifference (const LELInterface<Bool>& left, 00123 const LELInterface<Bool>& right); 00124 static LELRegion* makeComplement (const LELInterface<Bool>& expr); 00125 // </group> 00126 00127 private: 00128 // Get the LattRegionHolder after checking that the expression is a region. 00129 static const LattRegionHolder& region (const LELInterface<Bool>& expr); 00130 00131 // Check if both regions have the same type (pixel or world) and if 00132 // no LCSlicer type of region is used. 00133 static void checkTypes (const LattRegionHolder& left, 00134 const LattRegionHolder& right); 00135 00136 // Member variables. 00137 LattRegionHolder* region_p; 00138 }; 00139 00140 00141 00142 00143 // <summary> 00144 // Class to convert a region to a boolean node 00145 // </summary> 00146 00147 // <use visibility=local> 00148 00149 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos=""> 00150 // </reviewed> 00151 00152 // <prerequisite> 00153 // <li> <linkto class="LELRegion"> Lattice</linkto> 00154 // <li> <linkto class="LatticeExprNode"> LatticeExprNode</linkto> 00155 // <li> <linkto class="LELInterface"> LELInterface</linkto> 00156 // </prerequisite> 00157 00158 // <etymology> 00159 // This derived LEL letter class handles a region as a boolean lattice. 00160 // </etymology> 00161 00162 // <synopsis> 00163 // This class makes it possible to handle a region as a true 00164 // boolean lattice without the need to apply the region to an image. 00165 // It means that it is only possible if the region has absolute 00166 // lattice coordinates. 00167 // <p> 00168 // A description of the implementation details of the LEL classes can 00169 // be found in 00170 // <a href="../notes/216.html">Note 216</a> 00171 // </synopsis> 00172 00173 // <motivation> 00174 // It is useful to be able to handle a mask as a boolean lattice. 00175 // </motivation> 00176 00177 //# <todo asof="1998/01/21"> 00178 //# </todo> 00179 00180 00181 class LELRegionAsBool : public LELInterface<Bool> 00182 { 00183 public: 00184 // Constructor. 00185 LELRegionAsBool (const LELRegion& region); 00186 00187 // Destructor. 00188 ~LELRegionAsBool(); 00189 00190 // Get region data. 00191 virtual void eval(LELArray<Bool>& result, 00192 const Slicer& section) const; 00193 00194 // Getting region data as a scalar cannot be done (throws an exception). 00195 virtual LELScalar<Bool> getScalar() const; 00196 00197 // Do further preparations (e.g. optimization) on the expression. 00198 virtual Bool prepareScalarExpr(); 00199 00200 // Get class name 00201 virtual String className() const; 00202 00203 private: 00204 // Member variables. 00205 LatticeRegion region_p; 00206 }; 00207 00208 00209 00210 00211 } //# NAMESPACE CASA - END 00212 00213 #endif