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
33namespace casacore { // # NAMESPACE CASACORE - BEGIN
34
35// <summary>
36// Abstract base class to define a single region.
37// </summary>
38
39// <use visibility=export>
40
41// <reviewed reviewer="" date="" tests="">
42// </reviewed>
43
44// <prerequisite>
45// <li> <linkto class=Slicer>Slicer</linkto>
46// </prerequisite>
47
48// <synopsis>
49// The LCRegion class is the abstract base class for various types
50// of LCRegion's (e.g. LCRegionEllipsoid, LCRegionBox).
51// It contains the minimal bounding box of the region and, if needed,
52// a mask with the same shape as the bounding box. A mask element
53// is true if the element is inside the box.
54// <p>
55// Each LCRegion object must be able to convert itself to and from a Record.
56// In that way they can be made persistent (in for example a Table).
57// <p>
58// The LCRegion can be used in several Lattices and Images classes and
59// functions to limit the area to operate on.
60// </synopsis>
61
62// <example>
63// <srcblock>
64// </srcblock>
65// </example>
66
67// <motivation>
68// The Slicer class is too limited as a region, because it can only
69// describe a rectangular region. Specialized classes are needed to
70// describe arbitrary regions. They need a base class to combine them.
71// </motivation>
72
73// # <todo asof="1997/11/11">
74// # <li>
75// # </todo>
76
77class LCRegionSingle : public LCRegion {
78 public:
80
81 // Construct with the lattice shape only.
83
84 // Copy constructor (copy semantics).
86
87 virtual ~LCRegionSingle();
88
89 // Does the region have a mask?
90 virtual Bool hasMask() const;
91
92 // Get the mask (as an array).
93 const Array<Bool> maskArray() const;
94
95 // Is the mask of this region the same as the mask of the other
96 Bool masksEqual(const LCRegion& other) const;
97
98 // The following "put" functions are described in detail in class
99 // <linkto class=Lattice>Lattice</linkto>.
100 // They'll throw an exception is no mask is available or if
101 // the mask is not writable.
102 // <group>
103 virtual void set(const Bool& value);
104 virtual void apply(Bool (*function)(Bool));
105 virtual void apply(Bool (*function)(const Bool&));
106 virtual void apply(const Functional<Bool, Bool>& function);
107 virtual void putAt(const Bool& value, const IPosition& where);
108 virtual void copyData(const Lattice<Bool>& from);
109 // </group>
110
111 protected:
112 // Assignment (copy semantics) is only useful for derived classes.
114
115 // Set the pointer to the mask in the derived class.
117
118 // Do the actual getting of the mask.
119 virtual Bool doGetSlice(Array<Bool>& buffer, const Slicer& section);
120
121 // Do the actual putting of the mask. Only possible if region is writable.
122 virtual void doPutSlice(const Array<Bool>& sourceBuffer, const IPosition& where,
123 const IPosition& stride);
124
125 // Get the best cursor shape.
126 virtual IPosition doNiceCursorShape(uInt maxPixels) const;
127
128 // Make an iterator.
129 // When the underlying region has a mask, an iterator for that region
130 // is returned. Otherwise the standard iterator is returned.
132 Bool useRef) const;
133
134 private:
137};
138
139} // namespace casacore
140
141#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:211
For temporary backward namespace compatibility, use casa as alias for casacore.
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
NewDelAllocator< T > NewDelAllocator< T >::value
Definition Allocator.h:360