casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LCBox.h
Go to the documentation of this file.
1 //# LCBox.h: Class to define a rectangular box of interest
2 //# Copyright (C) 1997,1998,1999
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id$
27 
28 #ifndef LATTICES_LCBOX_H
29 #define LATTICES_LCBOX_H
30 
31 //# Includes
32 #include <casacore/casa/aips.h>
36 
37 
38 namespace casacore { //# NAMESPACE CASACORE - BEGIN
39 
40 // <summary>
41 // Class to define a rectangular box of interest.
42 // </summary>
43 
44 // <use visibility=export>
45 
46 // <reviewed reviewer="" date="" tests="">
47 // </reviewed>
48 
49 // <prerequisite>
50 // <li> <linkto class=LCRegion>LCRegion</linkto>
51 // </prerequisite>
52 
53 // <synopsis>
54 // The LCBox class is a specialization of class
55 // <linkto class=LCRegion>LCRegion</linkto>.
56 // It makes it possible to define a rectangular region of interest.
57 // </synopsis>
58 
59 // <example>
60 // <srcblock>
61 // </srcblock>
62 // </example>
63 
64 // <todo asof="1997/11/11">
65 // </todo>
66 
67 class LCBox: public LCRegionFixed
68 {
69 public:
70  LCBox();
71 
72  // Construct a box for the full lattice shape.
73  explicit LCBox (const IPosition& latticeShape);
74 
75  // Construct from the Slicer defining the box.
76  // The slicer may not contain a stride.
77  LCBox (const Slicer& box, const IPosition& latticeShape);
78 
79  // Construct from the IPosition's defining the bottom-left and
80  // top-right corner of the box.
81  LCBox (const IPosition& blc, const IPosition& trc,
82  const IPosition& latticeShape);
83 
84  // Construct from the Vector's defining the bottom-left and
85  // top-right corner of the box.
86  // <group>
87  LCBox (const Vector<Float>& blc, const Vector<Float>& trc,
88  const IPosition& latticeShape);
89  LCBox (const Vector<Double>& blc, const Vector<Double>& trc,
90  const IPosition& latticeShape);
91  // </group>
92 
93  // Copy constructor (reference semantics).
94  LCBox (const LCBox& other);
95 
96  virtual ~LCBox();
97 
98  // Assignment (copy semantics).
99  LCBox& operator= (const LCBox& other);
100 
101  // Comparison. Mask not checked. Use function
102  // LRegionSingle::maskEqual to do this
103  virtual Bool operator== (const LCRegion& other) const;
104 
105  // Make a copy of the derived object.
106  virtual LCRegion* cloneRegion() const;
107 
108  // Get the class name (to store in the record).
109  static String className();
110 
111  // Get the region type. Returns className()
112  virtual String type() const;
113 
114  // Convert the (derived) object to a record.
115  virtual TableRecord toRecord (const String& tableName) const;
116 
117  // Convert correct object from a record.
118  static LCBox* fromRecord (const TableRecord&,
119  const String& tablename);
120 
121  // Get the box blc
122  Vector<Float> blc() const;
123 
124  // Get the box trc
125  Vector<Float> trc() const;
126 
127 // Verify a box specification. Illegal (inlcuding blc > trc) or
128 // unspecified values are given 0 (blc) shape (trc) or
129 // unity (inc). Returns <src>True</src> if any of the blc/trc/inc
130 // are changed from their input values, else returns <src>False</src>
131  static Bool verify (IPosition& blc, IPosition& trc,
132  IPosition& inc, const IPosition& shape);
133 
134 
135 protected:
136  // Construct another LCBox (for e.g. another lattice) by moving
137  // this one. It recalculates the bounding box.
138  // A positive translation value indicates "to right".
139  virtual LCRegion* doTranslate (const Vector<Float>& translateVector,
140  const IPosition& newLatticeShape) const;
141 
142 private:
143  // Make a box from the blc,trc such that it does not exceed the
144  // lattice boundaries.
145  void setSlicerBox (const IPosition& blc, const IPosition& trc);
146 
147  // Fill the blc and trc vector from IPositions.
148  void fillBlcTrc();
149 
150 
151  //# Variables
154 };
155 
156 
157 inline Vector<Float> LCBox::blc() const
158 {
159  return itsBlc;
160 }
161 inline Vector<Float> LCBox::trc() const
162 {
163  return itsTrc;
164 }
165 
166 
167 
168 } //# NAMESPACE CASACORE - END
169 
170 #endif
Vector< Float > itsTrc
Definition: LCBox.h:153
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:118
Class to define a rectangular box of interest.
Definition: LCBox.h:67
static String className()
Get the class name (to store in the record).
Vector< Float > itsBlc
Definition: LCBox.h:152
static Bool verify(IPosition &blc, IPosition &trc, IPosition &inc, const IPosition &shape)
Verify a box specification.
virtual String type() const
Get the region type.
virtual TableRecord toRecord(const String &tableName) const
Convert the (derived) object to a record.
Abstract base class to define a fixed region.
Definition: LCRegionFixed.h:81
virtual ~LCBox()
virtual LCRegion * doTranslate(const Vector< Float > &translateVector, const IPosition &newLatticeShape) const
Construct another LCBox (for e.g.
void fillBlcTrc()
Fill the blc and trc vector from IPositions.
LCBox & operator=(const LCBox &other)
Assignment (copy semantics).
virtual Bool operator==(const LCRegion &other) const
Comparison.
static LCBox * fromRecord(const TableRecord &, const String &tablename)
Convert correct object from a record.
virtual LCRegion * cloneRegion() const
Make a copy of the derived object.
const IPosition & latticeShape() const
Give the full lattice shape.
Definition: LCRegion.h:231
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
virtual IPosition shape() const
Return the shape of the region (i.e.
A hierarchical collection of named fields of various types.
Definition: TableRecord.h:185
Specify which elements to extract from an n-dimensional array.
Definition: Slicer.h:288
Vector< Float > trc() const
Get the box trc.
Definition: LCBox.h:161
Vector< Float > blc() const
Get the box blc.
Definition: LCBox.h:157
String: the storage and methods of handling collections of characters.
Definition: String.h:225
void setSlicerBox(const IPosition &blc, const IPosition &trc)
Make a box from the blc,trc such that it does not exceed the lattice boundaries.
Abstract base class to define a region of interest in lattice coordinates.
Definition: LCRegion.h:87