casacore
Loading...
Searching...
No Matches
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: casa-feedback@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#ifndef LATTICES_LCREGIONSINGLE_H
27#define LATTICES_LCREGIONSINGLE_H
28
29//# Includes
30#include <casacore/casa/aips.h>
31#include <casacore/lattices/LRegions/LCRegion.h>
32
33
34namespace casacore { //# NAMESPACE CASACORE - BEGIN
35
36// <summary>
37// Abstract base class to define a single region.
38// </summary>
39
40// <use visibility=export>
41
42// <reviewed reviewer="" date="" tests="">
43// </reviewed>
44
45// <prerequisite>
46// <li> <linkto class=Slicer>Slicer</linkto>
47// </prerequisite>
48
49// <synopsis>
50// The LCRegion class is the abstract base class for various types
51// of LCRegion's (e.g. LCRegionEllipsoid, LCRegionBox).
52// It contains the minimal bounding box of the region and, if needed,
53// a mask with the same shape as the bounding box. A mask element
54// is true if the element is inside the box.
55// <p>
56// Each LCRegion object must be able to convert itself to and from a Record.
57// In that way they can be made persistent (in for example a Table).
58// <p>
59// The LCRegion can be used in several Lattices and Images classes and
60// functions to limit the area to operate on.
61// </synopsis>
62
63// <example>
64// <srcblock>
65// </srcblock>
66// </example>
67
68// <motivation>
69// The Slicer class is too limited as a region, because it can only
70// describe a rectangular region. Specialized classes are needed to
71// describe arbitrary regions. They need a base class to combine them.
72// </motivation>
73
74//# <todo asof="1997/11/11">
75//# <li>
76//# </todo>
77
79{
80public:
82
83 // Construct with the lattice shape only.
85
86 // Copy constructor (copy semantics).
88
89 virtual ~LCRegionSingle();
90
91 // Does the region have a mask?
92 virtual Bool hasMask() const;
93
94 // Get the mask (as an array).
95 const Array<Bool> maskArray() const;
96
97 // Is the mask of this region the same as the mask of the other
98 Bool masksEqual (const LCRegion& other) const;
99
100 // The following "put" functions are described in detail in class
101 // <linkto class=Lattice>Lattice</linkto>.
102 // They'll throw an exception is no mask is available or if
103 // the mask is not writable.
104 // <group>
105 virtual void set (const Bool& value);
106 virtual void apply (Bool (*function)(Bool));
107 virtual void apply (Bool (*function)(const Bool&));
108 virtual void apply (const Functional<Bool,Bool>& function);
109 virtual void putAt (const Bool& value, const IPosition& where);
110 virtual void copyData (const Lattice<Bool>& from);
111 // </group>
112
113protected:
114 // Assignment (copy semantics) is only useful for derived classes.
116
117 // Set the pointer to the mask in the derived class.
119
120 // Do the actual getting of the mask.
121 virtual Bool doGetSlice (Array<Bool>& buffer, const Slicer& section);
122
123 // Do the actual putting of the mask. Only possible if region is writable.
124 virtual void doPutSlice (const Array<Bool>& sourceBuffer,
125 const IPosition& where,
126 const IPosition& stride);
127
128 // Get the best cursor shape.
129 virtual IPosition doNiceCursorShape (uInt maxPixels) const;
130
131 // Make an iterator.
132 // When the underlying region has a mask, an iterator for that region
133 // is returned. Otherwise the standard iterator is returned.
135 (const LatticeNavigator& navigator,
136 Bool useRef) const;
137
138private:
141};
142
143
144
145} //# NAMESPACE CASACORE - END
146
147#endif
virtual LatticeIterInterface< Bool > * makeIter(const LatticeNavigator &navigator, Bool useRef) const
Make an iterator.
virtual void apply(const Functional< Bool, Bool > &function)
void setMaskPtr(Lattice< Bool > &mask)
Set the pointer to the mask in the derived class.
virtual IPosition doNiceCursorShape(uInt maxPixels) const
Get the best cursor shape.
virtual void doPutSlice(const Array< Bool > &sourceBuffer, const IPosition &where, const IPosition &stride)
Do the actual putting of the mask.
virtual Bool hasMask() const
Does the region have a mask?
virtual void apply(Bool(*function)(const Bool &))
LCRegionSingle & operator=(const LCRegionSingle &other)
Assignment (copy semantics) is only useful for derived classes.
LCRegionSingle(const IPosition &latticeShape)
Construct with the lattice shape only.
virtual Bool doGetSlice(Array< Bool > &buffer, const Slicer &section)
Do the actual getting of the mask.
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.
Lattice< Bool > * itsMaskPtr
virtual void set(const Bool &value)
The following "put" functions are described in detail in class Lattice.
Bool masksEqual(const LCRegion &other) const
Is the mask of this region the same as the mask of the other.
const Array< Bool > maskArray() const
Get the mask (as an array).
LCRegionSingle(const LCRegionSingle &other)
Copy constructor (copy semantics).
virtual void putAt(const Bool &value, const IPosition &where)
Put the value of a single element.
const IPosition & latticeShape() const
Give the full lattice shape.
Definition LCRegion.h:229
this file contains all the compiler specific defines
Definition mainpage.dox:28
unsigned int uInt
Definition aipstype.h:49
LatticeExprNode mask(const LatticeExprNode &expr)
This function returns the mask of the given expression.
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.