casa
$Rev:20696$
|
00001 //# LattRegionHolder.h: Class to hold a region of interest in an image 00002 //# Copyright (C) 1999,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 //# $Id: LattRegionHolder.h 20505 2009-01-19 14:37:24Z gervandiepen $ 00027 00028 #ifndef LATTICES_LATTREGIONHOLDER_H 00029 #define LATTICES_LATTREGIONHOLDER_H 00030 00031 //# Includes 00032 #include <lattices/Lattices/LatticeRegion.h> 00033 #include <lattices/Lattices/LCSlicer.h> 00034 #include <lattices/Lattices/LCRegion.h> 00035 00036 namespace casa { //# NAMESPACE CASA - BEGIN 00037 00038 class CoordinateSystem; 00039 class WCRegion; 00040 00041 // <summary> 00042 // Class to hold a region of interest in an image. 00043 // </summary> 00044 00045 // <use visibility=export> 00046 00047 // <reviewed reviewer="" date="" tests=""> 00048 // </reviewed> 00049 00050 // <prerequisite> 00051 // <li> <linkto class=LCSlicer>LCSlicer</linkto> 00052 // <li> <linkto class=WCRegion>LCRegion</linkto> 00053 // </prerequisite> 00054 00055 // <synopsis> 00056 // The only purpose of LattRegionHolder is to have a single object for 00057 // the various kinds of regions. It can hold a 00058 // <linkto class=LCRegion>LCRegion</linkto>, and 00059 // <linkto class=LCSlicer>LCSlicer</linkto>. 00060 // </synopsis> 00061 00062 // <example> 00063 // <srcblock> 00064 // </srcblock> 00065 // </example> 00066 00067 // <motivation> 00068 // It was felt that making an abstract base class LatticeRegion for 00069 // LCRegion and WCRegion would create undesirable dependencies of 00070 // module Lattices on module Coordinates. E.g. it would be impossible 00071 // to have a function toWCRegion. 00072 // Therefore the container class LattRegionHolder is chosen, from which 00073 // the container <linkto class=ImageRegion>ImageRegion</linkto> is derived. 00074 // </motivation> 00075 00076 //# <todo asof="1997/11/11"> 00077 //# <li> 00078 //# </todo> 00079 00080 00081 class LattRegionHolder 00082 { 00083 public: 00084 // Construct from a region based on lattice coordinates. 00085 LattRegionHolder (const LCRegion&); 00086 00087 // Construct from a slicer based on lattice coordinates. 00088 LattRegionHolder (const LCSlicer&); 00089 00090 // Similar constructors as above, but using a pointer. 00091 // It takes over the pointer, so the user should not delete the 00092 // object. It is deleted by the LattRegionHolder destructor. 00093 // <group> 00094 explicit LattRegionHolder (LCRegion*); 00095 explicit LattRegionHolder (LCSlicer*); 00096 // </group> 00097 00098 // Copy constructor (copy semantics). 00099 LattRegionHolder (const LattRegionHolder& other); 00100 00101 virtual ~LattRegionHolder(); 00102 00103 // Assignment (copy semantics). 00104 LattRegionHolder& operator= (const LattRegionHolder& other); 00105 00106 // Clone the object. 00107 virtual LattRegionHolder* clone() const; 00108 00109 // Comparison 00110 // <group> 00111 virtual Bool operator==(const LattRegionHolder& other) const; 00112 Bool operator!=(const LattRegionHolder& other) const; 00113 // </group> 00114 00115 // Test if the underlying region is an LCRegion, etc. 00116 // <group> 00117 Bool isLCRegion() const; 00118 Bool isLCSlicer() const; 00119 virtual Bool isWCRegion() const; 00120 // </group> 00121 00122 // Get the region as a pointer to a LCRegion, LCSlicer, or WCRegion. 00123 // An exception is thrown if the region is not the correct type. 00124 // Functions <src>isWCRegion()</src>, etc. can be used to test the type. 00125 // <group> 00126 const LCRegion* asLCRegionPtr() const; 00127 const LCSlicer* asLCSlicerPtr() const; 00128 virtual const WCRegion* asWCRegionPtr() const; 00129 // </group> 00130 00131 // Get the dimensionality. 00132 uInt ndim() const; 00133 00134 // Convert to a LatticeRegion using the given shape. 00135 LatticeRegion toLatticeRegion (const IPosition& shape) const; 00136 00137 // Convert to a LatticeRegion using the given coordinate system 00138 // (with reference pixel) and shape. 00139 // It will also make the region complete (absolute and non-fractional). 00140 virtual LatticeRegion toLatticeRegion (const CoordinateSystem& cSys, 00141 const IPosition& shape) const; 00142 00143 // Form a compound from this and the other region. 00144 // <group> 00145 virtual LattRegionHolder* makeUnion (const LattRegionHolder& other) const; 00146 virtual LattRegionHolder* makeIntersection 00147 (const LattRegionHolder& other) const; 00148 virtual LattRegionHolder* makeDifference 00149 (const LattRegionHolder& other) const; 00150 virtual LattRegionHolder* makeComplement() const; 00151 // </group> 00152 00153 protected: 00154 // Construct for the given dimensionality (for derived classes). 00155 explicit LattRegionHolder (uInt ndim); 00156 00157 private: 00158 LCRegion* itsLC; 00159 LCSlicer* itsSlicer; 00160 uInt itsNdim; 00161 }; 00162 00163 00164 inline Bool LattRegionHolder::isLCRegion() const 00165 { 00166 return (itsLC != 0); 00167 } 00168 inline Bool LattRegionHolder::isLCSlicer() const 00169 { 00170 return (itsSlicer != 0); 00171 } 00172 inline Bool LattRegionHolder::operator!= (const LattRegionHolder& other) const 00173 { 00174 return (! operator== (other)); 00175 } 00176 inline uInt LattRegionHolder::ndim() const 00177 { 00178 return itsNdim; 00179 } 00180 00181 00182 00183 } //# NAMESPACE CASA - END 00184 00185 #endif