casacore
WCConcatenation.h
Go to the documentation of this file.
1 //# WCConcatenation.h: Combine multiple ImageRegion's into a new dimension
2 //# Copyright (C) 1998
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 IMAGES_WCCONCATENATION_H
29 #define IMAGES_WCCONCATENATION_H
30 
31 //# Includes
32 #include <casacore/casa/aips.h>
33 #include <casacore/images/Regions/WCCompound.h>
34 #include <casacore/images/Regions/WCBox.h>
35 
36 
37 namespace casacore { //# NAMESPACE CASACORE - BEGIN
38 
39 // <summary>
40 // Combine multiple ImageRegion's into a new dimension.
41 // </summary>
42 
43 // <use visibility=export>
44 
45 // <reviewed reviewer="" date="" tests="">
46 // </reviewed>
47 
48 // <prerequisite>
49 // <li> <linkto class=WCCompound>WCCompound</linkto>
50 // </prerequisite>
51 
52 // <synopsis>
53 // The WCConcatenation class is a specialization of class
54 // <linkto class=WCCompound>WCCompound</linkto>.
55 // It makes it possible to combine multiple regions and to add a
56 // dimension on them. The axis and the range (beginning and end)
57 // of that new dimension have to be specified using an
58 // <linkto class=WCBox>WCBox</linkto> object.
59 // That axes should not be an axis in the given regions.
60 // <p>
61 // WCConcatenation can be seen as a mixture of the classes
62 // <linkto class=WCUnion>WCUnion</linkto> and
63 // <linkto class=WCExtension>WCExtension</linkto>. Like WCUnion it
64 // combines regions and like WCExtension it increases the dimensionality
65 // for the new region (be it with only 1).
66 // <br>
67 // Unlike WCUnion the axes have to be the same in all regions,
68 // because creating a WCConcatenation means combining similar regions.
69 // <p>
70 // E.g. One can define a different polygon in the RA-DEC plane of each
71 // channel. WCConcatenation makes it possible to combine the polygons
72 // to one 3D region in the RA-DEC-Freq cube.
73 // </synopsis>
74 
75 // <example>
76 // This example combines <src>n</src> (relative) circles
77 // given in the RA,DEC plane along the FREQ-axis.
78 // In this example the regions used are circles with the same centers,
79 // but it is also possible to combine differently shaped regions.
80 // Note that WCConcatenation takes over the pointers to the individual regions,
81 // so they do not need to be deleted (the WCConcatenation destructor does it).
82 // <srcblock>
83 // IPosition center (2,10,20);
84 // PtrBlock<ImageRegion*> cirPtr(n);
85 // for (i=0; i<n; i++) {
86 // // Each circle has a different radius.
87 // cirPtr(i) = new WCEllipsoid cir1 (center, 1 + i%(n/2));
88 // }
89 // // Construct the concatenation for a range (given as a box in fractions).
90 // // Extend along the FREQ-axis (the 2nd axis in the given cSys)..
91 // // Take over the region pointers.
92 // Vector<Quantity> blc(1);
93 // Vector<Quantity> trc(1);
94 // blc(0) = Quantity (0.25, "frac");
95 // trc(0) = Quantity (0.75, "frac");
96 // WCConcatenation region (True, cirPtr, WCBox(blc, trc, cSys, IPosition(1,2));
97 // </srcblock>
98 // This example is artificial in the sense that WCEllipsoid does not
99 // exist yet and the WCBox constructor looks a bit different.
100 // One should probably also do a bit more trouble to find out if FREQ
101 // is indeed the 2nd axis in the coordinate system.
102 // </example>
103 
104 //# <todo asof="1997/11/11">
105 //# <li>
106 //# </todo>
107 
108 
110 {
111 public:
112  // Combine the given regions.
113  // When <src>takeOver</src> is True, the destructor will delete the
114  // given regions. Otherwise a copy of the regions is made.
115  // The extend range has to be given as a 1-dimensional box.
116  // <group>
118  const WCBox& extendRange);
120  const WCBox& extendRange);
121  // </group>
122 
123  // Copy constructor (copy semantics).
125 
126  virtual ~WCConcatenation();
127 
128  // Assignment (copy semantics).
130 
131  // Comparison
132  virtual Bool operator== (const WCRegion& other) const;
133 
134  // Make a copy of the derived object.
135  virtual WCRegion* cloneRegion() const;
136 
137  // Get the class name (to store in the record).
138  static String className();
139 
140  // Get the region type. Returns className()
141  virtual String type() const;
142 
143  // Convert the (derived) object to a record.
144  virtual TableRecord toRecord (const String& tableName) const;
145 
146  // Convert correct object from a record.
148  const String& tableName);
149 
150 protected:
151  // Convert to an LCRegion using the given coordinate system and shape.
152  // pixelAxesMap(i) gives the pixel axis in cSys of axes <src>i</src>
153  // in the axesDesc.
154  virtual LCRegion* doToLCRegion (const CoordinateSystem& cSys,
155  const IPosition& shape,
156  const IPosition& pixelAxesMap,
157  const IPosition& outOrder) const;
158 
159 private:
160  // Do a check and fill the remainder of the object.
161  void fill();
162 
163  //# Variables
165 };
166 
167 
168 
169 } //# NAMESPACE CASACORE - END
170 
171 #endif
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
const PtrBlock< const WCRegion * > & regions() const
Get the contributing regions.
Definition: WCCompound.h:156
static String className()
Get the class name (to store in the record).
virtual Bool operator==(const WCRegion &other) const
Comparison.
virtual WCRegion * cloneRegion() const
Make a copy of the derived object.
WCConcatenation & operator=(const WCConcatenation &other)
Assignment (copy semantics).
static WCConcatenation * fromRecord(const TableRecord &, const String &tableName)
Convert correct object from a record.
WCConcatenation(const PtrBlock< const ImageRegion * > &regions, const WCBox &extendRange)
Combine the given regions.
void fill()
Do a check and fill the remainder of the object.
virtual TableRecord toRecord(const String &tableName) const
Convert the (derived) object to a record.
WCConcatenation(Bool takeOver, const PtrBlock< const WCRegion * > &regions, const WCBox &extendRange)
virtual String type() const
Get the region type.
virtual LCRegion * doToLCRegion(const CoordinateSystem &cSys, const IPosition &shape, const IPosition &pixelAxesMap, const IPosition &outOrder) const
Convert to an LCRegion using the given coordinate system and shape.
WCConcatenation(const WCConcatenation &other)
Copy constructor (copy semantics).
this file contains all the compiler specific defines
Definition: mainpage.dox:28
TableExprNode shape(const TableExprNode &array)
Function operating on any scalar or array resulting in a Double array containing the shape.
Definition: ExprNode.h:1987
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42