Isis 3 Programmer Reference
Cube.h
Go to the documentation of this file.
1 #ifndef Cube_h
2 #define Cube_h
3 
26 #include <vector>
27 
28 // This is needed for the QVariant macro
29 #include <QMetaType>
30 
31 #include "Endian.h"
32 #include "PixelType.h"
33 
34 class QFile;
35 class QMutex;
36 class QString;
37 
38 namespace Isis {
39  class Blob;
40  class Buffer;
41  class Camera;
42  class CubeAttributeOutput;
43  class CubeCachingAlgorithm;
44  class CubeIoHandler;
45  class FileName;
46  class Projection;
47  class Pvl;
48  class PvlGroup;
49  class Statistics;
50  class Histogram;
51 
170  class Cube {
171  public:
172  Cube();
173  Cube(const FileName &fileName, QString access = "r");
174  virtual ~Cube();
175 
180  enum Format {
235  };
236 
237  bool isOpen() const;
238  bool isProjected() const;
239  bool isReadOnly() const;
240  bool isReadWrite() const;
241  bool labelsAttached() const;
242 
243  void close(bool remove = false);
244  Cube *copy(FileName newFile, const CubeAttributeOutput &newFileAttributes);
245  void create(const QString &cfile);
246  void create(const QString &cfile, const CubeAttributeOutput &att);
247  void open(const QString &cfile, QString access = "r");
248  void reopen(QString access = "r");
249 
250  void read(Blob &blob) const;
251  void read(Buffer &rbuf) const;
252  void write(Blob &blob);
253  void write(Buffer &wbuf);
254 
255  void setBaseMultiplier(double base, double mult);
256  void setMinMax(double min, double max);
258  void setDimensions(int ns, int nl, int nb);
259  void setExternalDnData(FileName cubeFileWithDnData);
260  void setFormat(Format format);
261  void setLabelsAttached(bool attached);
262  void setLabelSize(int labelBytes);
264  void setVirtualBands(const QList<QString> &vbands);
265  void setVirtualBands(const std::vector<QString> &vbands);
266 
267  void relocateDnData(FileName dnDataFile);
268 // static void relocateDnData(FileName externalLabelFile, FileName dnDataFile);
269 
270  virtual int bandCount() const;
271  double base() const;
272  ByteOrder byteOrder() const;
273  Camera *camera();
275  virtual QString fileName() const;
276  Format format() const;
277  virtual Histogram *histogram(const int &band = 1,
278  QString msg = "Gathering histogram");
279  virtual Histogram *histogram(const int &band, const double &validMin,
280  const double &validMax,
281  QString msg = "Gathering histogram");
282  Pvl *label() const;
283  int labelSize(bool actual = false) const;
284  int lineCount() const;
285  double multiplier() const;
286  PixelType pixelType() const;
287  virtual int physicalBand(const int &virtualBand) const;
289  int sampleCount() const;
290  Statistics *statistics(const int &band = 1,
291  QString msg = "Gathering statistics");
292  Statistics *statistics(const int &band, const double &validMin,
293  const double &validMax,
294  QString msg = "Gathering statistics");
295  bool storesDnData() const;
296 
298  void clearIoCache();
299  bool deleteBlob(QString BlobType, QString BlobName);
300  void deleteGroup(const QString &group);
301  PvlGroup &group(const QString &group) const;
302  bool hasGroup(const QString &group) const;
303  bool hasTable(const QString &name);
304  void putGroup(const PvlGroup &group);
305  void latLonRange(double &minLatitude, double &maxLatitude, double &minLongitude,
306  double &maxLongitude);
307 
308  private:
310  void cleanUp(bool remove);
311 
312  void construct();
313  QFile *dataFile() const;
314  FileName realDataFileName() const;
315 
316  void initialize();
317  void initCoreFromLabel(const Pvl &label);
318  void initLabelFromFile(FileName labelFileName, bool readWrite);
319  void openCheck();
320  Pvl realDataFileLabel() const;
321  void reformatOldIsisLabel(const QString &oldCube);
322  void writeLabels();
323 
324  private:
333  QFile *m_labelFile;
339  QFile *m_dataFile;
340 
346 
353 
360 
367 
369  QMutex *m_mutex;
370 
373 
376 
379 
382 
389 
392 
395 
402 
405 
408 
411 
413  int m_lines;
414 
416  int m_bands;
417 
422  double m_base;
423 
428  double m_multiplier;
429 
432  };
433 }
434 
437 
438 #endif
Statistics * statistics(const int &band=1, QString msg="Gathering statistics")
This method returns a pointer to a Statistics object which allows the program to obtain and use vario...
Definition: Cube.cpp:1475
int m_labelBytes
The maximum allowed size of the label; the allocated space.
Definition: Cube.h:407
Buffer for reading and writing cube data.
Definition: Buffer.h:69
bool deleteBlob(QString BlobType, QString BlobName)
This method will delete a blob label object from the cube as specified by the Blob type and name...
Definition: Cube.cpp:1600
virtual Histogram * histogram(const int &band=1, QString msg="Gathering histogram")
This method returns a pointer to a Histogram object which allows the program to obtain and use variou...
Definition: Cube.cpp:1244
void construct()
Initialize members from their initial undefined states.
Definition: Cube.cpp:1786
Pvl * m_label
The label if IsOpen(), otherwise NULL.
Definition: Cube.h:404
bool isProjected() const
Returns true if the labels of the cube appear to have a valid mapping group.
Definition: Cube.cpp:119
bool storesDnData() const
This method returns a boolean value.
Definition: Cube.cpp:1549
File name manipulation and expansion.
Definition: FileName.h:116
virtual ~Cube()
Destroys the Cube object.
Definition: Cube.cpp:77
Camera * camera()
Return a camera associated with the cube.
Definition: Cube.cpp:1166
double base() const
Returns the base value for converting 8-bit/16-bit pixels to 32-bit.
Definition: Cube.cpp:1142
bool m_attached
True if labels are attached.
Definition: Cube.h:394
void applyVirtualBandsToLabel()
Applies virtual bands to label.
Definition: Cube.cpp:1710
int sampleCount() const
Definition: Cube.cpp:1452
void openCheck()
Throw an exception if the cube is not open.
Definition: Cube.cpp:2073
void setFormat(Format format)
Used prior to the Create method, this will specify the format of the cube, either band...
Definition: Cube.cpp:981
CubeIoHandler * m_ioHandler
This does the heavy lifting for cube DN IO and is always allocated when isOpen() is true...
Definition: Cube.h:345
double m_base
The base of the open cube or the cube that will be created; does not apply if m_pixelType is Real...
Definition: Cube.h:422
ByteOrder
Tests the current architecture for byte order.
Definition: Endian.h:59
int m_bands
The band count of the open cube or the cube that will be created.
Definition: Cube.h:416
FileName * m_tempCube
If open was called with an Isis 2 cube, then this will be the name of the imported Isis3 cube...
Definition: Cube.h:388
bool isOpen() const
Test if a cube file has been opened/created.
Definition: Cube.cpp:100
void setLabelsAttached(bool attached)
Use prior to calling create, this sets whether or not to use separate label and data files...
Definition: Cube.cpp:993
Q_DECLARE_METATYPE(Isis::Cube *)
This allows Cube *&#39;s to be stored in a QVariant.
bool labelsAttached() const
Test if labels are attached.
Definition: Cube.cpp:165
FileName * m_formatTemplateFile
Label pvl format template file (describes how to format labels)
Definition: Cube.h:391
Format format() const
Definition: Cube.cpp:1220
Projection * projection()
Definition: Cube.cpp:1439
void initialize()
This sets Cube to its default state: Native byte order Format = Tile PixelType = Real (4 bytes per pi...
Definition: Cube.cpp:1897
void setDimensions(int ns, int nl, int nb)
Used prior to the Create method to specify the size of the cube.
Definition: Cube.cpp:932
void initCoreFromLabel(const Pvl &label)
This function initializes the Cube core from a Pvl Label passed as a parameter.
Definition: Cube.cpp:1922
PixelType
Enumerations for Isis Pixel Types.
Definition: PixelType.h:43
Handles converting buffers to and from disk.
PvlGroup & group(const QString &group) const
Read a group from the cube into a Label.
Definition: Cube.cpp:1636
void reopen(QString access="r")
This method will reopen an isis sube for reading or reading/writing.
Definition: Cube.cpp:691
QFile * dataFile() const
This returns the QFile with cube DN data in it.
Definition: Cube.cpp:1817
This class is used to accumulate statistics on double arrays.
Definition: Statistics.h:107
FileName * m_dataFileName
The full filename of the data file (.cub)
Definition: Cube.h:381
Base class for Map Projections.
Definition: Projection.h:171
bool isReadWrite() const
Test if the opened cube is read-write, that is read and write operations should succeed if this is tr...
Definition: Cube.cpp:152
Cubes are stored in tile format, that is the order of the pixels in the file (on disk) is BSQ within ...
Definition: Cube.h:234
void setPixelType(PixelType pixelType)
Used prior to the Create method, this will specify the output pixel type.
Definition: Cube.cpp:1019
PixelType m_pixelType
This is the pixel type on disk.
Definition: Cube.h:366
FileName * m_labelFileName
The full filename of the label file (.lbl or .cub)
Definition: Cube.h:378
bool hasTable(const QString &name)
Check to see if the cube contains a pvl table by the provided name.
Definition: Cube.cpp:1663
Container of a cube histogram.
Definition: Histogram.h:86
bool hasGroup(const QString &group) const
Return if the cube has a specified group in the labels.
Definition: Cube.cpp:1649
Contains multiple PvlContainers.
Definition: PvlGroup.h:57
void setVirtualBands(const QList< QString > &vbands)
This allows the programmer to specify a subset of bands to work with.
Definition: Cube.cpp:1036
FileName realDataFileName() const
This gets the file name of the file which actually contains the DN data.
Definition: Cube.cpp:1832
Manipulate and parse attributes of output cube filenames.
void setBaseMultiplier(double base, double mult)
Used prior to the Create method, this will specify the base and multiplier for converting 8-bit/16-bi...
Definition: Cube.cpp:866
void writeLabels()
Write the Pvl labels to the cube&#39;s label file.
Definition: Cube.cpp:2233
bool isReadOnly() const
Test if the opened cube is read-only, that is write operations will fail if this is true...
Definition: Cube.cpp:130
void close(bool remove=false)
Closes the cube and updates the labels.
Definition: Cube.cpp:177
QList< int > * m_virtualBandList
If allocated, converts from physical on-disk band # to virtual band #.
Definition: Cube.h:431
void read(Blob &blob) const
This method will read data from the specified Blob object.
Definition: Cube.cpp:724
void open(const QString &cfile, QString access="r")
This method will open an isis cube for reading or reading/writing.
Definition: Cube.cpp:544
Cube * copy(FileName newFile, const CubeAttributeOutput &newFileAttributes)
Copies the cube to the new fileName.
Definition: Cube.cpp:193
Cube()
Constructs a Cube object.
Definition: Cube.cpp:58
QFile * m_dataFile
This is only sometimes allocated.
Definition: Cube.h:339
void addCachingAlgorithm(CubeCachingAlgorithm *)
This will add the given caching algorithm to the list of attempted caching algorithms.
Definition: Cube.cpp:1567
Pvl realDataFileLabel() const
Function to read data from a cube label and return it as a PVL object.
Definition: Cube.cpp:2086
QFile * m_labelFile
This is the file that contains the labels always; if labels are attached then this contains the file ...
Definition: Cube.h:333
Container for cube-like labels.
Definition: Pvl.h:135
PixelType pixelType() const
Definition: Cube.cpp:1403
void setByteOrder(ByteOrder byteOrder)
Used prior to the Create method, this will specify the byte order of pixels, either least or most sig...
Definition: Cube.cpp:917
Camera * m_camera
Camera allocated from the camera() method.
Definition: Cube.h:372
Cubes are stored in band-sequential format, that is the order of the pixels in the file (on disk) is:...
Definition: Cube.h:201
void setMinMax(double min, double max)
Used prior to the Create method, this will compute a good base and multiplier value given the minimum...
Definition: Cube.cpp:883
Pvl * label() const
Returns a pointer to the IsisLabel object associated with the cube.
Definition: Cube.cpp:1346
void clearIoCache()
This will clear excess RAM used for quicker IO in the cube.
Definition: Cube.cpp:1583
int m_samples
The sample count of the open cube or the cube that will be created.
Definition: Cube.h:410
Format m_format
If isOpen() then this is the IO format that the cube uses.
Definition: Cube.h:359
void reformatOldIsisLabel(const QString &oldCube)
This is a helper, used by open(...), that handles opening Isis 2 cubes as if they were Isis 3 cubes...
Definition: Cube.cpp:2116
virtual QString fileName() const
Returns the opened cube&#39;s filename.
Definition: Cube.cpp:1208
void initLabelFromFile(FileName labelFileName, bool readWrite)
This function initializes the Cube label from a file passed as a parameter.
Definition: Cube.cpp:1966
int lineCount() const
Definition: Cube.cpp:1379
void write(Blob &blob)
This method will write a blob of data (e.g.
Definition: Cube.cpp:763
QMutex * m_mutex
Basic thread-safety mutex; this class is not optimized for threads.
Definition: Cube.h:369
void relocateDnData(FileName dnDataFile)
Relocates the DN data for a cube to an external cube label file.
Definition: Cube.cpp:1081
Projection * m_projection
Projection allocated from the projection() method.
Definition: Cube.h:375
void cleanUp(bool remove)
This clears all of the allocated memory associated with an open cube.
Definition: Cube.cpp:1738
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
virtual int bandCount() const
Returns the number of virtual bands for the cube.
Definition: Cube.cpp:1125
void setExternalDnData(FileName cubeFileWithDnData)
Used to set external dn data to cube.
Definition: Cube.cpp:949
void putGroup(const PvlGroup &group)
Adds a group in a Label to the cube.
Definition: Cube.cpp:1688
ByteOrder byteOrder() const
Returns the byte order/endian-ness of the cube file.
Definition: Cube.cpp:1154
int labelSize(bool actual=false) const
Returns the number of bytes used by the label.
Definition: Cube.cpp:1358
bool m_storesDnData
True (most common case) when the cube DN data is inside the file we&#39;re writing to.
Definition: Cube.h:401
int m_lines
The line count of the open cube or the cube that will be created.
Definition: Cube.h:413
double m_multiplier
The multiplier of the open cube or the cube that will be created; does not apply if m_pixelType is Re...
Definition: Cube.h:428
ByteOrder m_byteOrder
The byte order of the opened cube; if there is no open cube then this is the byte order that will be ...
Definition: Cube.h:352
void deleteGroup(const QString &group)
Deletes a group from the cube labels.
Definition: Cube.cpp:1622
void latLonRange(double &minLatitude, double &maxLatitude, double &minLongitude, double &maxLongitude)
Returns the latitude and longitude range for the Cube.
Definition: Cube.cpp:2146
void create(const QString &cfile)
This method will create an isis cube for writing.
Definition: Cube.cpp:331
Format
These are the possible storage formats of Isis3 cubes.
Definition: Cube.h:180
This is the parent of the caching algorithms
FileName externalCubeFileName() const
If this is an external cube label file, this will give you the cube dn file that this label reference...
Definition: Cube.cpp:1180
virtual int physicalBand(const int &virtualBand) const
This method will return the physical band number given a virtual band number.
Definition: Cube.cpp:1418
void setLabelSize(int labelBytes)
Used prior to the Create method, this will allocate a specific number of bytes in the label area for ...
Definition: Cube.cpp:1006
double multiplier() const
Returns the multiplier value for converting 8-bit/16-bit pixels to 32-bit.
Definition: Cube.cpp:1393
IO Handler for Isis Cubes.
Definition: Cube.h:170