00001 //# LCBox.h: Class to define a rectangular box of interest 00002 //# Copyright (C) 1997,1998,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$ 00027 00028 #ifndef LATTICES_LCBOX_H 00029 #define LATTICES_LCBOX_H 00030 00031 //# Includes 00032 #include <casacore/casa/aips.h> 00033 #include <casacore/lattices/LRegions/LCRegionFixed.h> 00034 #include <casacore/casa/Arrays/Slicer.h> 00035 #include <casacore/casa/Arrays/Vector.h> 00036 00037 00038 namespace casacore { //# NAMESPACE CASACORE - BEGIN 00039 00040 // <summary> 00041 // Class to define a rectangular box of interest. 00042 // </summary> 00043 00044 // <use visibility=export> 00045 00046 // <reviewed reviewer="" date="" tests=""> 00047 // </reviewed> 00048 00049 // <prerequisite> 00050 // <li> <linkto class=LCRegion>LCRegion</linkto> 00051 // </prerequisite> 00052 00053 // <synopsis> 00054 // The LCBox class is a specialization of class 00055 // <linkto class=LCRegion>LCRegion</linkto>. 00056 // It makes it possible to define a rectangular region of interest. 00057 // </synopsis> 00058 00059 // <example> 00060 // <srcblock> 00061 // </srcblock> 00062 // </example> 00063 00064 // <todo asof="1997/11/11"> 00065 // </todo> 00066 00067 class LCBox: public LCRegionFixed 00068 { 00069 public: 00070 LCBox(); 00071 00072 // Construct a box for the full lattice shape. 00073 explicit LCBox (const IPosition& latticeShape); 00074 00075 // Construct from the Slicer defining the box. 00076 // The slicer may not contain a stride. 00077 LCBox (const Slicer& box, const IPosition& latticeShape); 00078 00079 // Construct from the IPosition's defining the bottom-left and 00080 // top-right corner of the box. 00081 LCBox (const IPosition& blc, const IPosition& trc, 00082 const IPosition& latticeShape); 00083 00084 // Construct from the Vector's defining the bottom-left and 00085 // top-right corner of the box. 00086 // <group> 00087 LCBox (const Vector<Float>& blc, const Vector<Float>& trc, 00088 const IPosition& latticeShape); 00089 LCBox (const Vector<Double>& blc, const Vector<Double>& trc, 00090 const IPosition& latticeShape); 00091 // </group> 00092 00093 // Copy constructor (reference semantics). 00094 LCBox (const LCBox& other); 00095 00096 virtual ~LCBox(); 00097 00098 // Assignment (copy semantics). 00099 LCBox& operator= (const LCBox& other); 00100 00101 // Comparison. Mask not checked. Use function 00102 // LRegionSingle::maskEqual to do this 00103 virtual Bool operator== (const LCRegion& other) const; 00104 00105 // Make a copy of the derived object. 00106 virtual LCRegion* cloneRegion() const; 00107 00108 // Get the class name (to store in the record). 00109 static String className(); 00110 00111 // Get the region type. Returns className() 00112 virtual String type() const; 00113 00114 // Convert the (derived) object to a record. 00115 virtual TableRecord toRecord (const String& tableName) const; 00116 00117 // Convert correct object from a record. 00118 static LCBox* fromRecord (const TableRecord&, 00119 const String& tablename); 00120 00121 // Get the box blc 00122 Vector<Float> blc() const; 00123 00124 // Get the box trc 00125 Vector<Float> trc() const; 00126 00127 // Verify a box specification. Illegal (inlcuding blc > trc) or 00128 // unspecified values are given 0 (blc) shape (trc) or 00129 // unity (inc). Returns <src>True</src> if any of the blc/trc/inc 00130 // are changed from their input values, else returns <src>False</src> 00131 static Bool verify (IPosition& blc, IPosition& trc, 00132 IPosition& inc, const IPosition& shape); 00133 00134 00135 protected: 00136 // Construct another LCBox (for e.g. another lattice) by moving 00137 // this one. It recalculates the bounding box. 00138 // A positive translation value indicates "to right". 00139 virtual LCRegion* doTranslate (const Vector<Float>& translateVector, 00140 const IPosition& newLatticeShape) const; 00141 00142 private: 00143 // Make a box from the blc,trc such that it does not exceed the 00144 // lattice boundaries. 00145 void setSlicerBox (const IPosition& blc, const IPosition& trc); 00146 00147 // Fill the blc and trc vector from IPositions. 00148 void fillBlcTrc(); 00149 00150 00151 //# Variables 00152 Vector<Float> itsBlc; 00153 Vector<Float> itsTrc; 00154 }; 00155 00156 00157 inline Vector<Float> LCBox::blc() const 00158 { 00159 return itsBlc; 00160 } 00161 inline Vector<Float> LCBox::trc() const 00162 { 00163 return itsTrc; 00164 } 00165 00166 00167 00168 } //# NAMESPACE CASACORE - END 00169 00170 #endif