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