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