casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LCRegionSingle.h
Go to the documentation of this file.
1 //# LCRegionSingle.h: Abstract base class to define a single region
2 //# Copyright (C) 1998,1999,2003
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_LCREGIONSINGLE_H
29 #define LATTICES_LCREGIONSINGLE_H
30 
31 //# Includes
32 #include <casacore/casa/aips.h>
34 
35 
36 namespace casacore { //# NAMESPACE CASACORE - BEGIN
37 
38 // <summary>
39 // Abstract base class to define a single region.
40 // </summary>
41 
42 // <use visibility=export>
43 
44 // <reviewed reviewer="" date="" tests="">
45 // </reviewed>
46 
47 // <prerequisite>
48 // <li> <linkto class=Slicer>Slicer</linkto>
49 // </prerequisite>
50 
51 // <synopsis>
52 // The LCRegion class is the abstract base class for various types
53 // of LCRegion's (e.g. LCRegionEllipsoid, LCRegionBox).
54 // It contains the minimal bounding box of the region and, if needed,
55 // a mask with the same shape as the bounding box. A mask element
56 // is true if the element is inside the box.
57 // <p>
58 // Each LCRegion object must be able to convert itself to and from a Record.
59 // In that way they can be made persistent (in for example a Table).
60 // <p>
61 // The LCRegion can be used in several Lattices and Images classes and
62 // functions to limit the area to operate on.
63 // </synopsis>
64 
65 // <example>
66 // <srcblock>
67 // </srcblock>
68 // </example>
69 
70 // <motivation>
71 // The Slicer class is too limited as a region, because it can only
72 // describe a rectangular region. Specialized classes are needed to
73 // describe arbitrary regions. They need a base class to combine them.
74 // </motivation>
75 
76 //# <todo asof="1997/11/11">
77 //# <li>
78 //# </todo>
79 
80 class LCRegionSingle : public LCRegion
81 {
82 public:
84 
85  // Construct with the lattice shape only.
87 
88  // Copy constructor (copy semantics).
89  LCRegionSingle (const LCRegionSingle& other);
90 
91  virtual ~LCRegionSingle();
92 
93  // Does the region have a mask?
94  virtual Bool hasMask() const;
95 
96  // Get the mask (as an array).
97  const Array<Bool> maskArray() const;
98 
99  // Is the mask of this region the same as the mask of the other
100  Bool masksEqual (const LCRegion& other) const;
101 
102  // The following "put" functions are described in detail in class
103  // <linkto class=Lattice>Lattice</linkto>.
104  // They'll throw an exception is no mask is available or if
105  // the mask is not writable.
106  // <group>
107  virtual void set (const Bool& value);
108  virtual void apply (Bool (*function)(Bool));
109  virtual void apply (Bool (*function)(const Bool&));
110  virtual void apply (const Functional<Bool,Bool>& function);
111  virtual void putAt (const Bool& value, const IPosition& where);
112  virtual void copyData (const Lattice<Bool>& from);
113  // </group>
114 
115 protected:
116  // Assignment (copy semantics) is only useful for derived classes.
118 
119  // Set the pointer to the mask in the derived class.
120  void setMaskPtr (Lattice<Bool>& mask);
121 
122  // Do the actual getting of the mask.
123  virtual Bool doGetSlice (Array<Bool>& buffer, const Slicer& section);
124 
125  // Do the actual putting of the mask. Only possible if region is writable.
126  virtual void doPutSlice (const Array<Bool>& sourceBuffer,
127  const IPosition& where,
128  const IPosition& stride);
129 
130  // Get the best cursor shape.
131  virtual IPosition doNiceCursorShape (uInt maxPixels) const;
132 
133  // Make an iterator.
134  // When the underlying region has a mask, an iterator for that region
135  // is returned. Otherwise the standard iterator is returned.
137  (const LatticeNavigator& navigator,
138  Bool useRef) const;
139 
140 private:
143 };
144 
145 
146 
147 } //# NAMESPACE CASACORE - END
148 
149 #endif
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:119
Bool masksEqual(const LCRegion &other) const
Is the mask of this region the same as the mask of the other.
virtual IPosition doNiceCursorShape(uInt maxPixels) const
Get the best cursor shape.
Map a domain object into a range object via operator().
Definition: Functional.h:122
LatticeExprNode mask(const LatticeExprNode &expr)
This function returns the mask of the given expression.
virtual void putAt(const Bool &value, const IPosition &where)
Put the value of a single element.
LCRegionSingle & operator=(const LCRegionSingle &other)
Assignment (copy semantics) is only useful for derived classes.
virtual void set(const Bool &value)
The following &quot;put&quot; functions are described in detail in class Lattice.
virtual void apply(Bool(*function)(Bool))
Replace every element, x, of the Lattice with the result of f(x).
virtual void copyData(const Lattice< Bool > &from)
Copy the data from the given lattice to this one.
A base class for Lattice iterators.
Definition: SubImage.h:46
virtual Bool doGetSlice(Array< Bool > &buffer, const Slicer &section)
Do the actual getting of the mask.
const IPosition & latticeShape() const
Give the full lattice shape.
Definition: LCRegion.h:231
const Array< Bool > maskArray() const
Get the mask (as an array).
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
virtual LatticeIterInterface< Bool > * makeIter(const LatticeNavigator &navigator, Bool useRef) const
Make an iterator.
virtual void doPutSlice(const Array< Bool > &sourceBuffer, const IPosition &where, const IPosition &stride)
Do the actual putting of the mask.
Specify which elements to extract from an n-dimensional array.
Definition: Slicer.h:289
Lattice< Bool > * itsMaskPtr
void setMaskPtr(Lattice< Bool > &mask)
Set the pointer to the mask in the derived class.
Abstract base class to define a single region.
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
unsigned int uInt
Definition: aipstype.h:51
Abstract base class to steer lattice iterators.
Abstract base class to define a region of interest in lattice coordinates.
Definition: LCRegion.h:87
virtual Bool hasMask() const
Does the region have a mask?
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42