8#include "CubeTileHandler.h"
12#include "IException.h"
15#include "PvlKeyword.h"
16#include "RawCubeChunk.h"
33 const QList<int> *virtualBandList,
const Pvl &labels,
bool alreadyOnDisk)
34 :
CubeIoHandler(dataFile, virtualBandList, labels, alreadyOnDisk) {
36 const PvlObject &core = labels.findObject(
"IsisCube").findObject(
"Core");
38 if(core.hasKeyword(
"Format")) {
39 setChunkSizes(core[
"TileSamples"], core[
"TileLines"], 1);
44 findGoodSize(512 * 4 / SizeOf(pixelType()), sampleCount());
46 findGoodSize(512 * 4 / SizeOf(pixelType()), lineCount());
48 setChunkSizes(sampleChunkSize, lineChunkSize, 1);
67 PvlObject &core = labels.findObject(
"IsisCube").findObject(
"Core");
68 core.addKeyword(PvlKeyword(
"Format",
"Tile"),
69 PvlContainer::Replace);
71 PvlContainer::Replace);
73 PvlContainer::Replace);
83 if(dataFile->seek(startByte)) {
84 QByteArray binaryData = dataFile->read(chunkToFill.
getByteCount());
93 IString msg =
"Reading from the file [" + dataFile->fileName() +
"] "
94 "failed with reading [" +
96 "] bytes at position [" + QString::number(startByte) +
"]";
97 throw IException(IException::Io, msg, _FILEINFO_);
104 bool success =
false;
107 if(dataFile->seek(startByte)) {
108 BigInt dataWritten = dataFile->write(chunkToWrite.
getRawData());
116 IString msg =
"Writing to the file [" + dataFile->fileName() +
"] "
117 "failed with writing [" +
119 "] bytes at position [" + QString::number(startByte) +
"]";
120 throw IException(IException::Io, msg, _FILEINFO_);
138 if(dimensionSize <= maxSize) {
139 ideal = dimensionSize;
142 int greatestDividend = maxSize;
144 while(greatestDividend > ideal) {
145 if(dimensionSize % greatestDividend == 0) {
146 ideal = greatestDividend;
virtual void clearCache(bool blockForWriteCache=true) const
Free all cube chunks (cached cube data) from memory and write them to disk.
int getLineCountInChunk() const
CubeIoHandler(QFile *dataFile, const QList< int > *virtualBandList, const Pvl &label, bool alreadyOnDisk)
Creates a new CubeIoHandler using a RegionalCachingAlgorithm.
BigInt getBytesPerChunk() const
BigInt getDataStartByte() const
int getSampleCountInChunk() const
int getChunkIndex(const RawCubeChunk &) const
Given a chunk, what's its index in the file.
void updateLabels(Pvl &label)
Update the cube labels so that this cube indicates what tile size it used.
BigInt getTileStartByte(const RawCubeChunk &chunk) const
This is a helper method that goes from chunk to file position.
int findGoodSize(int maxSize, int dimensionSize) const
This is a helper method that tries to compute a good tile size for one of the cube's dimensions (samp...
virtual void writeRaw(const RawCubeChunk &chunkToWrite)
This needs to write the chunkToWrite directly to disk with no modifications to the data itself.
virtual void readRaw(RawCubeChunk &chunkToFill)
This needs to populate the chunkToFill with unswapped raw bytes from the disk.
CubeTileHandler(QFile *dataFile, const QList< int > *virtualBandList, const Pvl &label, bool alreadyOnDisk)
Construct a tile handler.
~CubeTileHandler()
Writes all data from memory to disk.
A section of raw data on the disk.
QByteArray & getRawData() const
void setRawData(QByteArray rawData)
Sets the chunk's raw data.
This is free and unencumbered software released into the public domain.
This is free and unencumbered software released into the public domain.
QString toString(const LinearAlgebra::Vector &vector, int precision)
A global function to format LinearAlgebra::Vector as a QString with the given precision.
Namespace for the standard library.