casacore
Loading...
Searching...
No Matches
LCSlicer.h
Go to the documentation of this file.
1// # LCSlicer.h: Class to define a rectangular box of interest with strides
2// # Copyright (C) 1998,1999,2001
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_LCSLICER_H
27#define LATTICES_LCSLICER_H
28
29// # Includes
30#include <casacore/casa/aips.h>
31#include <casacore/lattices/LRegions/RegionType.h>
32#include <casacore/casa/Arrays/Vector.h>
33#include <casacore/casa/BasicSL/String.h>
34
35namespace casacore { // # NAMESPACE CASACORE - BEGIN
36
37// # Forward Declarations
38class IPosition;
39class Slicer;
40class TableRecord;
41
42// <summary>
43// Class to define a rectangular box of interest with strides.
44// </summary>
45
46// <use visibility=export>
47
48// <reviewed reviewer="" date="" tests="">
49// </reviewed>
50
51// <prerequisite>
52// <li> <linkto class=Slicer>Slicer</linkto>
53// </prerequisite>
54
55// <synopsis>
56// The LCSlicer makes it possible to define a rectangular box
57// with strides. Note that this class is not derived from
58// <linkto class=LCRegion>LCRegion</linkto>, so it cannot be used in
59// a compound region object like <linkto class=LCUnion>LCUnion</linkto>.
60// The reason is that strides make it impossible to use a region
61// in a compound.
62// <br>
63// The slicer region can be defined from an
64// <linkto class=Slicer>Slicer</linkto> object defining the blc/trc
65// and a vector (of the same length) containing the strides.
66// The LCSlicer can be of any type (thus relative, fractional, unspecified),
67// while the strides can be defined as a number or a fraction.
68// <br>
69// It is also possible to construct it directly from a
70// <linkto class=Slicer>Slicer</linkto> object,
71// </synopsis>
72
73// <example>
74// <srcblock>
75// </srcblock>
76// </example>
77
78// <todo asof="1997/11/11">
79// </todo>
80
81class LCSlicer {
82 public:
84
85 // Construct a slicer from the blc, trc, and stride (default 1).
86 // The vectors can be different in lengths. The longest determines
87 // the dimensionality of the region. The shorter ones get padded
88 // with default values.
89 // <br> For each axis (or all axes) it can be defined if the blc/trc are
90 // given as pixel coordinates or as fractional values between 0 and 1. In the
91 // latter case the true pixel coordinate is derived from the image shape.
92 // <br> Also the region type can be given, if needed per axis.
93 // <ul>
94 // <li> RegionType::Abs is absolute
95 // <li> RegionType::RelRef is relative to reference pixel given in toSlice().
96 // <li> RegionType::RelCen is relative to image center.
97 // </ul>
98 // <group>
99 LCSlicer(const Vector<Float>& blc, const Vector<Float>& trc, Bool fractionalBlcTrc = False,
102 Bool fractionalBlcTrc = False, RegionType::AbsRelType = RegionType::Abs);
104 const Vector<Bool>& fractionalBlc, const Vector<Bool>& fractionalTrc,
105 const Vector<Bool>& fractionalInc, const Vector<Int>& absRelBlc,
106 const Vector<Int>& absRelTrc);
107 LCSlicer(const Vector<Double>& blc, const Vector<Double>& trc, Bool fractionalBlcTrc = False,
110 Bool fractionalBlcTrc = False, RegionType::AbsRelType = RegionType::Abs);
112 const Vector<Bool>& fractionalBlc, const Vector<Bool>& fractionalTrc,
113 const Vector<Bool>& fractionalInc, const Vector<Int>& absRelBlc,
114 const Vector<Int>& absRelTrc);
115 LCSlicer(const Slicer& slicer);
120 const Vector<Int>& absRelBlc, const Vector<Int>& absRelTrc);
121 // </group>
122
123 // Copy constructor (reference semantics).
124 LCSlicer(const LCSlicer& other);
125
127
128 // Assignment (copy semantics).
130
131 // Test for equality.
132 // True is returned when the given region is a slicer with exactly
133 // the same specification as this slicer.
134 // It does not compare the comment.
135 // <group>
136 Bool operator==(const LCSlicer& other) const;
137 Bool operator!=(const LCSlicer& other) const;
138 // </group>
139
140 // The region is completely specified if it is absolute, not fractional,
141 // and has no unspecified values.
143
144 // Get the dimensionality of the region.
145 uInt ndim() const;
146
147 // Simple accessor functions.
148 // <group>
149 const Vector<Float>& blc() const;
150 const Vector<Float>& trc() const;
151 const Vector<Float>& inc() const;
152 Bool isFractional() const;
153 Bool isAbsolute() const;
154 Bool isUnspecified() const;
155 Bool isStrided() const;
156 // </group>
157
158 // Get the class name (to store in the record).
160
161 // Get the region type. Returns className().
162 String type() const;
163
164 // Get or set the comment.
165 // <group>
166 const String& comment() const;
167 void setComment(const String& comment);
168 // </group>
169
170 // Make the region complete using the given reference pixel
171 // and shape. It returns a new region where the relative regions
172 // are made absolute by translating them with respect to the
173 // reference pixel. Furthermore unspecified values are filled
174 // in and fractional values are turned into absolute ones.
175 // <group>
176 Slicer toSlicer(const IPosition& referencePixel, const IPosition& latticeShape) const;
177 Slicer toSlicer(const Vector<Double>& referencePixel, const IPosition& latticeShape) const;
178 Slicer toSlicer(const Vector<Float>& referencePixel, const IPosition& newLatticeShape) const;
179 // </group>
180
181 // Convert the object to a record.
182 TableRecord toRecord(const String& tableName) const;
183
184 // Convert to correct object from a record.
185 static LCSlicer* fromRecord(const TableRecord&, const String& tablename);
186
187 private:
188 // Fill the pixel based flags from the general ones.
189 void fillFlags(Bool fractional, Int absRel, uInt nrblc, uInt nrtrc, uInt nrinc);
190
191 // Fill the vectors from the values given as doubles.
193 const Vector<Double>& inc);
194
195 // Fill the vectors from the values given as IPositions.
197
198 // Fill the remaining variables.
199 // It also adjust the lengths of the vectors if they are different.
200 // Check if everything is given correctly.
201 void fill();
202
203 // # Variables
217};
218
219inline Bool LCSlicer::operator!=(const LCSlicer& other) const { return (!operator==(other)); }
220inline uInt LCSlicer::ndim() const { return itsBlc.nelements(); }
221inline const Vector<Float>& LCSlicer::blc() const { return itsBlc; }
222inline const Vector<Float>& LCSlicer::trc() const { return itsTrc; }
223inline const Vector<Float>& LCSlicer::inc() const { return itsInc; }
225inline Bool LCSlicer::isAbsolute() const { return itsIsAbsolute; }
227inline Bool LCSlicer::isStrided() const { return itsIsStrided; }
228inline const String& LCSlicer::comment() const { return itsComment; }
230
231} // namespace casacore
232
233#endif
Vector< Bool > itsFracTrc
Definition LCSlicer.h:208
void fillFromDouble(const Vector< Double > &blc, const Vector< Double > &trc, const Vector< Double > &inc)
Fill the vectors from the values given as doubles.
Vector< Int > itsAbsRelBlc
Definition LCSlicer.h:210
Slicer toSlicer(const Vector< Float > &referencePixel, const IPosition &newLatticeShape) const
LCSlicer(const Vector< Float > &blc, const Vector< Float > &trc, Bool fractionalBlcTrc=False, RegionType::AbsRelType=RegionType::Abs)
Construct a slicer from the blc, trc, and stride (default 1).
LCSlicer(const IPosition &blc, const IPosition &trc, RegionType::AbsRelType=RegionType::Abs)
Bool isUnspecified() const
Definition LCSlicer.h:226
Vector< Float > itsBlc
Definition LCSlicer.h:204
LCSlicer(const LCSlicer &other)
Copy constructor (reference semantics).
Bool operator!=(const LCSlicer &other) const
Definition LCSlicer.h:219
Slicer toSlicer(const Vector< Double > &referencePixel, const IPosition &latticeShape) const
Bool isComplete() const
The region is completely specified if it is absolute, not fractional, and has no unspecified values.
Bool isFractional() const
Definition LCSlicer.h:224
Vector< Float > itsInc
Definition LCSlicer.h:206
String type() const
Get the region type.
void fillFlags(Bool fractional, Int absRel, uInt nrblc, uInt nrtrc, uInt nrinc)
Fill the pixel based flags from the general ones.
LCSlicer(const IPosition &blc, const IPosition &trc, const IPosition &inc, const Vector< Int > &absRelBlc, const Vector< Int > &absRelTrc)
LCSlicer(const Vector< Double > &blc, const Vector< Double > &trc, Bool fractionalBlcTrc=False, RegionType::AbsRelType=RegionType::Abs)
LCSlicer(const Vector< Float > &blc, const Vector< Float > &trc, const Vector< Float > &inc, Bool fractionalBlcTrc=False, RegionType::AbsRelType=RegionType::Abs)
uInt ndim() const
Get the dimensionality of the region.
Definition LCSlicer.h:220
TableRecord toRecord(const String &tableName) const
Convert the object to a record.
const String & comment() const
Get or set the comment.
Definition LCSlicer.h:228
void setComment(const String &comment)
Definition LCSlicer.h:229
Bool operator==(const LCSlicer &other) const
Test for equality.
const Vector< Float > & inc() const
Definition LCSlicer.h:223
LCSlicer(const IPosition &blc, const IPosition &trc, const IPosition &inc, RegionType::AbsRelType=RegionType::Abs)
static String className()
Get the class name (to store in the record).
LCSlicer & operator=(const LCSlicer &other)
Assignment (copy semantics).
Vector< Bool > itsFracBlc
Definition LCSlicer.h:207
const Vector< Float > & trc() const
Definition LCSlicer.h:222
Vector< Int > itsAbsRelTrc
Definition LCSlicer.h:211
Slicer toSlicer(const IPosition &referencePixel, const IPosition &latticeShape) const
Make the region complete using the given reference pixel and shape.
Bool isStrided() const
Definition LCSlicer.h:227
LCSlicer(const Vector< Double > &blc, const Vector< Double > &trc, const Vector< Double > &inc, const Vector< Bool > &fractionalBlc, const Vector< Bool > &fractionalTrc, const Vector< Bool > &fractionalInc, const Vector< Int > &absRelBlc, const Vector< Int > &absRelTrc)
LCSlicer(const Vector< Float > &blc, const Vector< Float > &trc, const Vector< Float > &inc, const Vector< Bool > &fractionalBlc, const Vector< Bool > &fractionalTrc, const Vector< Bool > &fractionalInc, const Vector< Int > &absRelBlc, const Vector< Int > &absRelTrc)
LCSlicer(const Vector< Double > &blc, const Vector< Double > &trc, const Vector< Double > &inc, Bool fractionalBlcTrc=False, RegionType::AbsRelType=RegionType::Abs)
const Vector< Float > & blc() const
Simple accessor functions.
Definition LCSlicer.h:221
Vector< Bool > itsFracInc
Definition LCSlicer.h:209
void fillFromIPosition(const IPosition &blc, const IPosition &trc, const IPosition &inc)
Fill the vectors from the values given as IPositions.
Vector< Float > itsTrc
Definition LCSlicer.h:205
void fill()
Fill the remaining variables.
static LCSlicer * fromRecord(const TableRecord &, const String &tablename)
Convert to correct object from a record.
LCSlicer(const Slicer &slicer)
Bool isAbsolute() const
Definition LCSlicer.h:225
AbsRelType
Define if a region is absolute or relative.
Definition RegionType.h:71
String: the storage and methods of handling collections of characters.
Definition String.h:355
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
const Bool False
Definition aipstype.h:42
unsigned int uInt
Definition aipstype.h:49
int Int
Definition aipstype.h:48
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40