casacore
Loading...
Searching...
No Matches
TiledShape.h
Go to the documentation of this file.
1//# TiledShape.h: Define the shape and tile shape
2//# Copyright (C) 1997,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_TILEDSHAPE_H
27#define LATTICES_TILEDSHAPE_H
28
29//# Includes
30#include <casacore/casa/aips.h>
31#include <casacore/casa/Arrays/ArrayFwd.h>
32#include <casacore/casa/Arrays/IPosition.h>
33
34namespace casacore { //# NAMESPACE CASACORE - BEGIN
35
36// <summary>
37// Define the shape and tile shape
38// </summary>
39
40// <use visibility=export>
41
42// <reviewed reviewer="Peter Barnes" date="1999/10/30" tests="tTiledShape.cc">
43// </reviewed>
44
45// <prerequisite>
46// <li> <linkto class=IPosition>IPosition</linkto>
47// </prerequisite>
48
49// <etymology>
50// TiledShape defines the shape and tile shape of a tiled array.
51// </etymology>
52
53// <synopsis>
54// TiledShape is a class defining the shape and optionally the tile
55// shape of a lattice. It is used in the constructors of
56// <linkto class=PagedArray>PagedArray</linkto> and
57// <linkto class=PagedImage>PagedImage</linkto>.
58// <p>
59// In principle it serves as a place holder for the lattice shape and
60// tile shape. The functions <src>shape</src> and <src>tileShape</src>
61// can be used to retrieve the shapes.
62// However, when the tile shape is not given, the function
63// <src>tileShape</src> calculates a default tile shape using the
64// given maximum tile size in pixel elements. The default tile shape
65// is calculated in such a way that the sizes of its axes
66// are proportional to the sizes of the lattice axes. Per axis it is
67// tried as much as possible to fit an integral number of tiles
68// in the lattice.
69// <br>In this way getting the tile shape is completely transparent.
70// </synopsis>
71
72// <example>
73// <srcblock>
74// // Do not explicitly define a tile shape.
75// // This results in a default tile shape (of 32,32,32).
76// TiledShape shape(IPosition(3,128,128,128));
77// cout << shape.shape() << ' ' << shape.tileShape() << endl;
78//
79// // Use with an explicitly given tile shape.
80// TiledShape shape(IPosition(3,128,128,128), IPosition(3,64,32,8));
81// cout << shape.shape() << ' ' << shape.tileShape() << endl;
82// </srcblock>
83// </example>
84
85// <motivation>
86// Classes <src>PagedArray</src> and <src>PagedImage</src> contained
87// several duplicated constructors to be able to pass a tile shape.
88// This class makes it possible to have only one constructor
89// instead of two. Furthermore it contains the logic to check if the
90// shapes are conforming and the logic to calculate a default tile shape.
91// </motivation>
92
93
95{
96public:
97 // Default constructor has empty shape and tile shape.
99
100 // Use the given shape.
101 // No tile shape is given, so function <src>tileShape</src>
102 // will calculate it using the size of a tile.
104
105 // Use the given shape and tile shape.
106 // Both shapes must be conforming (i.e. have same number of elements).
108
109 // Copy constructor (copy semantics).
110 TiledShape (const TiledShape& that);
111
113
114 // Assignment (copy semantics).
116
117 // Is the tile shape defined?
118 Bool isTileShapeDefined() const;
119
120 // Return the shape.
121 const IPosition& shape() const;
122
123 // Return the tile shape.
124 // When the tile shape is undefined, the default tile shape will be
125 // calculated using the given tile size and tolerance.
126 // <br> The tolerance is used to determine the boundaries where
127 // it is tried to fit an integral number of tiles.
128 IPosition tileShape (uInt nrPixelsPerTile = 32768,
129 Double tolerance = 0.5) const;
130
131 // Derive the default tile shape from the shape for the given
132 // number of pixels per tile. It is tried to get the same number
133 // of tiles for each dimension.
134 // When a weight vector is given, the number of tiles for a dimension
135 // is proportional to the weight.
136 // <br>After the initial guess it tries to optimize it by trying to
137 // waste as little space as possible, while trying to keep as close as
138 // possible to the initial guess. The given tolerance (possibly per axis)
139 // gives the minimum and maximum possible length of a tile axis
140 // (minimum = initial_guess*tolerance; maximum = initial_guess/tolerance).
141 // The heuristic is such that a tile axis length dividing the cube length
142 // exactly is always favoured.
143 // The test program <src>tTiledShape</src> can be used to see how
144 // the algorithm works out for a given shape and tile size.
145 // <group>
146 IPosition defaultTileShape (uInt nrPixelsPerTile, Double tolerance) const;
148 const Vector<Double>& tolerance,
149 const Vector<Double>& weight) const;
150 // </group>
151
152private:
156};
157
158
160{
161 return itsTileDefined;
162}
163inline const IPosition& TiledShape::shape() const
164{
165 return itsShape;
166}
167inline IPosition TiledShape::tileShape (uInt nrPixelsPerTile,
168 Double tolerance) const
169{
170 return (itsTileDefined ? itsTileShape :
171 defaultTileShape (nrPixelsPerTile, tolerance));
172}
173
174
175
176} //# NAMESPACE CASACORE - END
177
178#endif
TiledShape()
Default constructor has empty shape and tile shape.
IPosition tileShape(uInt nrPixelsPerTile=32768, Double tolerance=0.5) const
Return the tile shape.
Definition TiledShape.h:167
TiledShape(const IPosition &shape)
Use the given shape.
TiledShape(const TiledShape &that)
Copy constructor (copy semantics).
TiledShape & operator=(const TiledShape &that)
Assignment (copy semantics).
Bool isTileShapeDefined() const
Is the tile shape defined?
Definition TiledShape.h:159
IPosition defaultTileShape(uInt nrPixelsPerTile, Double tolerance) const
Derive the default tile shape from the shape for the given number of pixels per tile.
const IPosition & shape() const
Return the shape.
Definition TiledShape.h:163
TiledShape(const IPosition &shape, const IPosition &tileShape)
Use the given shape and tile shape.
IPosition defaultTileShape(uInt nrPixelsPerTile, const Vector< Double > &tolerance, const Vector< Double > &weight) const
this file contains all the compiler specific defines
Definition mainpage.dox:28
unsigned int uInt
Definition aipstype.h:49
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
double Double
Definition aipstype.h:53