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
43// <summary>
44// Class to define a rectangular box of interest with strides.
45// </summary>
46
47// <use visibility=export>
48
49// <reviewed reviewer="" date="" tests="">
50// </reviewed>
51
52// <prerequisite>
53// <li> <linkto class=Slicer>Slicer</linkto>
54// </prerequisite>
55
56// <synopsis>
57// The LCSlicer makes it possible to define a rectangular box
58// with strides. Note that this class is not derived from
59// <linkto class=LCRegion>LCRegion</linkto>, so it cannot be used in
60// a compound region object like <linkto class=LCUnion>LCUnion</linkto>.
61// The reason is that strides make it impossible to use a region
62// in a compound.
63// <br>
64// The slicer region can be defined from an
65// <linkto class=Slicer>Slicer</linkto> object defining the blc/trc
66// and a vector (of the same length) containing the strides.
67// The LCSlicer can be of any type (thus relative, fractional, unspecified),
68// while the strides can be defined as a number or a fraction.
69// <br>
70// It is also possible to construct it directly from a
71// <linkto class=Slicer>Slicer</linkto> object,
72// </synopsis>
73
74// <example>
75// <srcblock>
76// </srcblock>
77// </example>
78
79// <todo asof="1997/11/11">
80// </todo>
81
83{
84public:
86
87 // Construct a slicer from the blc, trc, and stride (default 1).
88 // The vectors can be different in lengths. The longest determines
89 // the dimensionality of the region. The shorter ones get padded
90 // with default values.
91 // <br> For each axis (or all axes) it can be defined if the blc/trc are
92 // given as pixel coordinates or as fractional values between 0 and 1. In the
93 // latter case the true pixel coordinate is derived from the image shape.
94 // <br> Also the region type can be given, if needed per axis.
95 // <ul>
96 // <li> RegionType::Abs is absolute
97 // <li> RegionType::RelRef is relative to reference pixel given in toSlice().
98 // <li> RegionType::RelCen is relative to image center.
99 // </ul>
100 // <group>
102 Bool fractionalBlcTrc = False,
105 const Vector<Float>& inc, Bool fractionalBlcTrc = False,
108 const Vector<Float>& inc,
109 const Vector<Bool>& fractionalBlc,
110 const Vector<Bool>& fractionalTrc,
111 const Vector<Bool>& fractionalInc,
112 const Vector<Int>& absRelBlc,
113 const Vector<Int>& absRelTrc);
115 Bool fractionalBlcTrc = False,
118 const Vector<Double>& inc, Bool fractionalBlcTrc = False,
121 const Vector<Double>& inc,
122 const Vector<Bool>& fractionalBlc,
123 const Vector<Bool>& fractionalTrc,
124 const Vector<Bool>& fractionalInc,
125 const Vector<Int>& absRelBlc,
126 const Vector<Int>& absRelTrc);
127 LCSlicer (const Slicer& slicer);
131 const IPosition& inc,
134 const IPosition& inc,
135 const Vector<Int>& absRelBlc,
136 const Vector<Int>& absRelTrc);
137 // </group>
138
139 // Copy constructor (reference semantics).
140 LCSlicer (const LCSlicer& other);
141
143
144 // Assignment (copy semantics).
146
147 // Test for equality.
148 // True is returned when the given region is a slicer with exactly
149 // the same specification as this slicer.
150 // It does not compare the comment.
151 // <group>
152 Bool operator== (const LCSlicer& other) const;
153 Bool operator!= (const LCSlicer& other) const;
154 // </group>
155
156 // The region is completely specified if it is absolute, not fractional,
157 // and has no unspecified values.
159
160 // Get the dimensionality of the region.
161 uInt ndim() const;
162
163 // Simple accessor functions.
164 // <group>
165 const Vector<Float>& blc() const;
166 const Vector<Float>& trc() const;
167 const Vector<Float>& inc() const;
168 Bool isFractional() const;
169 Bool isAbsolute() const;
170 Bool isUnspecified() const;
171 Bool isStrided() const;
172 // </group>
173
174 // Get the class name (to store in the record).
176
177 // Get the region type. Returns className().
178 String type() const;
179
180 // Get or set the comment.
181 // <group>
182 const String& comment() const;
183 void setComment (const String& comment);
184 // </group>
185
186 // Make the region complete using the given reference pixel
187 // and shape. It returns a new region where the relative regions
188 // are made absolute by translating them with respect to the
189 // reference pixel. Furthermore unspecified values are filled
190 // in and fractional values are turned into absolute ones.
191 // <group>
192 Slicer toSlicer (const IPosition& referencePixel,
193 const IPosition& latticeShape) const;
194 Slicer toSlicer (const Vector<Double>& referencePixel,
195 const IPosition& latticeShape) const;
196 Slicer toSlicer (const Vector<Float>& referencePixel,
197 const IPosition& newLatticeShape) const;
198 // </group>
199
200 // Convert the object to a record.
201 TableRecord toRecord (const String& tableName) const;
202
203 // Convert to correct object from a record.
205 const String& tablename);
206
207private:
208 // Fill the pixel based flags from the general ones.
209 void fillFlags (Bool fractional, Int absRel,
210 uInt nrblc, uInt nrtrc, uInt nrinc);
211
212 // Fill the vectors from the values given as doubles.
214 const Vector<Double>& trc,
215 const Vector<Double>& inc);
216
217 // Fill the vectors from the values given as IPositions.
219 const IPosition& trc,
220 const IPosition& inc);
221
222 // Fill the remaining variables.
223 // It also adjust the lengths of the vectors if they are different.
224 // Check if everything is given correctly.
225 void fill();
226
227 //# Variables
241};
242
243
244inline Bool LCSlicer::operator!= (const LCSlicer& other) const
245{
246 return (! operator==(other));
247}
248inline uInt LCSlicer::ndim() const
249{
250 return itsBlc.nelements();
251}
252inline const Vector<Float>& LCSlicer::blc() const
253{
254 return itsBlc;
255}
256inline const Vector<Float>& LCSlicer::trc() const
257{
258 return itsTrc;
259}
260inline const Vector<Float>& LCSlicer::inc() const
261{
262 return itsInc;
263}
265{
266 return itsIsFractional;
267}
269{
270 return itsIsAbsolute;
271}
273{
274 return itsIsUnspecified;
275}
277{
278 return itsIsStrided;
279}
280inline const String& LCSlicer::comment() const
281{
282 return itsComment;
283}
284inline void LCSlicer::setComment (const String& comment)
285{
287}
288
289
290
291} //# NAMESPACE CASACORE - END
292
293#endif
size_t nelements() const
How many elements does this array have? Product of all axis lengths.
Definition ArrayBase.h:101
Vector< Bool > itsFracTrc
Definition LCSlicer.h:232
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:234
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:272
Vector< Float > itsBlc
Definition LCSlicer.h:228
LCSlicer(const LCSlicer &other)
Copy constructor (reference semantics).
Bool operator!=(const LCSlicer &other) const
Definition LCSlicer.h:244
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:264
Vector< Float > itsInc
Definition LCSlicer.h:230
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:248
TableRecord toRecord(const String &tableName) const
Convert the object to a record.
const String & comment() const
Get or set the comment.
Definition LCSlicer.h:280
void setComment(const String &comment)
Definition LCSlicer.h:284
Bool operator==(const LCSlicer &other) const
Test for equality.
const Vector< Float > & inc() const
Definition LCSlicer.h:260
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:231
const Vector< Float > & trc() const
Definition LCSlicer.h:256
Vector< Int > itsAbsRelTrc
Definition LCSlicer.h:235
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:276
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:252
Vector< Bool > itsFracInc
Definition LCSlicer.h:233
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:229
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:268
AbsRelType
Define if a region is absolute or relative.
Definition RegionType.h:73
String: the storage and methods of handling collections of characters.
Definition String.h:223
this file contains all the compiler specific defines
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