casacore
LCRegionMulti.h
Go to the documentation of this file.
1 //# LCRegionMulti.h: Make the intersection of 2 or more regions
2 //# Copyright (C) 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_LCREGIONMULTI_H
29 #define LATTICES_LCREGIONMULTI_H
30 
31 //# Includes
32 #include <casacore/casa/aips.h>
33 #include <casacore/lattices/LRegions/LCRegion.h>
34 #include <casacore/casa/Arrays/IPosition.h>
35 #include <casacore/casa/Containers/Block.h>
36 
37 
38 namespace casacore { //# NAMESPACE CASACORE - BEGIN
39 
40 // <summary>
41 // Make the intersection of 2 or more regions.
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 LCRegionMulti class is a specialization of class
55 // <linkto class=LCRegion>LCRegion</linkto>.
56 // It makes it possible to extend a LCRegion along straight lines to
57 // other dimensions. E.g. a circle in the xy-plane can be extended to
58 // a cylinder in the xyz-space.
59 // includes the intersection border.
60 // It can only be used for a lattice of any dimensionality as long as the
61 // dimensionality of the (hyper-)intersection matches the dimensionality of
62 // the lattice.
63 // <p>
64 // The center of the intersection must be inside the lattice
65 // </synopsis>
66 
67 // <example>
68 // <srcblock>
69 // </srcblock>
70 // </example>
71 
72 // <todo asof="1997/11/11">
73 // <li>
74 // </todo>
75 
76 class LCRegionMulti: public LCRegion
77 {
78 public:
80 
81  // Construct from 2 regions.
82  LCRegionMulti (const LCRegion& region1, const LCRegion& region2);
83 
84  // Construct from multiple regions.
85  LCRegionMulti (Bool takeOver, const LCRegion* region1,
86  const LCRegion* region2 = 0,
87  const LCRegion* region3 = 0,
88  const LCRegion* region4 = 0,
89  const LCRegion* region5 = 0,
90  const LCRegion* region6 = 0,
91  const LCRegion* region7 = 0,
92  const LCRegion* region8 = 0,
93  const LCRegion* region9 = 0,
94  const LCRegion* region10 = 0);
95 
96  // Construct from multiple regions given as a Block.
97  // When <src>takeOver</src> is True, the destructor will delete the
98  // given regions. Otherwise a copy of the regions is made.
100 
101  // Copy constructor (copy semantics).
102  LCRegionMulti (const LCRegionMulti& other);
103 
104  virtual ~LCRegionMulti();
105 
106  // Assignment (copy semantics).
108 
109  // Comparison
110  virtual Bool operator== (const LCRegion& other) const;
111 
112  // Does the region have a mask?
113  virtual Bool hasMask() const;
114 
115 protected:
116  // Store the contributing regions in a record.
117  TableRecord makeRecord (const String& tableName) const;
118 
119  // Retrieve the contributing objects from the record.
121  const TableRecord&,
122  const String& tableName);
123 
124  // Translate all regions.
126  const Vector<Float>& translateVector,
127  const IPosition& newLatticeShape) const;
128 
129  // Determine if all regions have mask (used by LCIntersection).
130  void fillHasMask();
131 
132  // Find which area of the section and region are needed.
133  // False is returned if no part of the region is included in the section.
134  Bool findAreas (IPosition& bufStart, IPosition& bufEnd,
135  IPosition& regStart, IPosition& regEnd,
136  const Slicer& section, uInt regNr) const;
137 
138  // Get the contributing regions.
139  const PtrBlock<const LCRegion*>& regions() const;
140 
141 protected:
142  // Construct from lattice shape and region pointer, which is
143  // taken over.
144  // Primarily meant for LCExtension.
145  LCRegionMulti (const LCRegion* region, const IPosition& latticeShape);
146 
147  // Do the actual getting of an array of values.
148  virtual Bool doGetSlice (Array<Bool>& buffer, const Slicer& section);
149 
150  // Get the values from the class derived from Multi.
151  // It is called when there is a mask. Note that it is not sure
152  // whether the buffer has the correct size.
153  virtual void multiGetSlice (Array<Bool>& buffer,
154  const Slicer& section) = 0;
155 
156  // Get the best cursor shape.
157  virtual IPosition doNiceCursorShape (uInt maxPixels) const;
158 
159 private:
160  // Check if the regions are correct.
161  // If needed, make a copy of the region objects.
162  void init (Bool takeOver);
163 
164  //# >=0 means this region has a mask.
165  //# Its value gives the region with the biggest mask.
168 };
169 
170 
172 {
173  return itsRegions;
174 }
175 
176 
177 
178 } //# NAMESPACE CASACORE - END
179 
180 #endif
void fillHasMask()
Determine if all regions have mask (used by LCIntersection).
virtual void multiGetSlice(Array< Bool > &buffer, const Slicer &section)=0
Get the values from the class derived from Multi.
virtual Bool hasMask() const
Does the region have a mask?
const PtrBlock< const LCRegion * > & regions() const
Get the contributing regions.
Bool findAreas(IPosition &bufStart, IPosition &bufEnd, IPosition &regStart, IPosition &regEnd, const Slicer &section, uInt regNr) const
Find which area of the section and region are needed.
PtrBlock< const LCRegion * > itsRegions
LCRegionMulti(const LCRegionMulti &other)
Copy constructor (copy semantics).
TableRecord makeRecord(const String &tableName) const
Store the contributing regions in a record.
static void unmakeRecord(PtrBlock< const LCRegion * > &, const TableRecord &, const String &tableName)
Retrieve the contributing objects from the record.
virtual Bool doGetSlice(Array< Bool > &buffer, const Slicer &section)
Do the actual getting of an array of values.
virtual IPosition doNiceCursorShape(uInt maxPixels) const
Get the best cursor shape.
void multiTranslate(PtrBlock< const LCRegion * > &, const Vector< Float > &translateVector, const IPosition &newLatticeShape) const
Translate all regions.
LCRegionMulti(Bool takeOver, const PtrBlock< const LCRegion * > &regions)
Construct from multiple regions given as a Block.
LCRegionMulti & operator=(const LCRegionMulti &other)
Assignment (copy semantics).
virtual Bool operator==(const LCRegion &other) const
Comparison
LCRegionMulti(Bool takeOver, const LCRegion *region1, const LCRegion *region2=0, const LCRegion *region3=0, const LCRegion *region4=0, const LCRegion *region5=0, const LCRegion *region6=0, const LCRegion *region7=0, const LCRegion *region8=0, const LCRegion *region9=0, const LCRegion *region10=0)
Construct from multiple regions.
void init(Bool takeOver)
Check if the regions are correct.
LCRegionMulti(const LCRegion &region1, const LCRegion &region2)
Construct from 2 regions.
LCRegionMulti(const LCRegion *region, const IPosition &latticeShape)
Construct from lattice shape and region pointer, which is taken over.
const IPosition & latticeShape() const
Give the full lattice shape.
Definition: LCRegion.h:231
A drop-in replacement for Block<T*>.
Definition: Block.h:814
String: the storage and methods of handling collections of characters.
Definition: String.h:225
this file contains all the compiler specific defines
Definition: mainpage.dox:28
unsigned int uInt
Definition: aipstype.h:51
int Int
Definition: aipstype.h:50
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42