Isis 3 Programmer Reference
Blobber.cpp
1 
6 /* SPDX-License-Identifier: CC0-1.0 */
7 #include "Blobber.h"
8 
9 #include <vector>
10 
11 #include "Cube.h"
12 #include "IException.h"
13 #include "Progress.h"
14 #include "SpecialPixel.h"
15 #include "Table.h"
16 #include "TableField.h"
17 
18 using std::vector;
19 
20 namespace Isis {
27  Blobber::Blobber() : _blobname("_undefined_"), _fieldname("_undefined_"),
28  _name("Blob") { }
47  Blobber::Blobber(const QString &blobname, const QString &fieldname,
48  const QString &name) : _blobname(blobname),
49  _fieldname(fieldname), _name(name) {
50  }
51 
76  Blobber::Blobber(Cube &cube, const QString &blobname,
77  const QString &fieldname,
78  const QString &name) :
79  _blobname(blobname),
80  _fieldname(fieldname),
81  _name(name) {
82  load(cube);
83  }
84 
108  Blobber myblob = *this;
109  myblob._buf = _buf.copy();
110  return (myblob);
111  }
112 
120  void Blobber::load(const QString &filename) {
121  Cube cube;
122  cube.open(filename);
123  load(cube);
124  return;
125  }
126 
127 
140  void Blobber::load(Cube &cube) {
141  Table tbl = cube.readTable(getBlobName());
142  TableField data = tbl[0][getFieldName()];
143  if (data.isDouble()) {
144  loadDouble(tbl);
145  }
146  else if (data.isInteger()) {
147  loadInteger(tbl);
148  }
149  else {
150  QString msg = "Field type for " + getFieldName() +
151  " is not double or integer";
152  throw IException(IException::Programmer, msg, _FILEINFO_);
153  }
154  }
155 
156 
168  int nlines = tbl.Records();
169  int nsamps = tbl[0][getFieldName()].size();
170  BlobBuf pixels(nlines, nsamps);
171  for (int i = 0 ; i < nlines ; i++) {
172  vector<double> d = tbl[i][getFieldName()];
173  for (unsigned int j = 0 ; j < d.size() ; j++) {
174  pixels[i][j] = d[j];
175  }
176  }
177  _buf = pixels;
178  }
179 
194  int nlines = tbl.Records();
195  int nsamps = tbl[0][getFieldName()].size();
196  BlobBuf pixels(nlines, nsamps);
197  for (int i = 0 ; i < nlines ; i++) {
198  vector<int> d = tbl[i][getFieldName()];
199  for (unsigned int j = 0 ; j < d.size(); j++) {
200  pixels[i][j] = int2ToDouble(d[j]);
201  }
202  }
203  _buf = pixels;
204  }
205 
217  double Blobber::int2ToDouble(int value) const {
218  if (value == NULL2) return NULL8;
219  else if (value == LOW_REPR_SAT2) return LOW_REPR_SAT8;
220  else if (value == LOW_INSTR_SAT2) return LOW_INSTR_SAT8;
221  else if (value == HIGH_INSTR_SAT2) return HIGH_INSTR_SAT8;
222  else if (value == HIGH_REPR_SAT2) return HIGH_REPR_SAT8;
223  else return value;
224 
225  }
226 
227 
228  double Blobber::int2ToDouble(unsigned int value) const {
229  if (value == NULLUI4) return NULL8;
230  else if (value == LOW_REPR_SATUI4) return LOW_REPR_SAT8;
231  else if (value == LOW_INSTR_SATUI4) return LOW_INSTR_SAT8;
232  else if (value == HIGH_INSTR_SATUI4) return HIGH_INSTR_SAT8;
233  else if (value == HIGH_REPR_SATUI4) return HIGH_REPR_SAT8;
234  else return value;
235 
236  }
237 
238 
239 
240 
241 } // end namespace Isis
Isis::Blobber::loadInteger
void loadInteger(Table &tbl)
Provides direct reading in of the field data from the BLOB.
Definition: Blobber.cpp:193
Isis::Blobber
Base class for accessing ISIS blobs.
Definition: Blobber.h:98
Isis::Blobber::_buf
BlobBuf _buf
Buffer holding data.
Definition: Blobber.h:246
Isis::Cube::readTable
Table readTable(const QString &name)
Read a Table from the cube.
Definition: Cube.cpp:952
Isis::Blobber::Blobber
Blobber()
Default basic constructor that is mostly not useful.
Definition: Blobber.cpp:27
Isis::TableField::isInteger
bool isInteger() const
Determines whether the field type is Integer.
Definition: TableField.cpp:122
Isis::Blobber::BlobBuf
TNT::Array2D< double > BlobBuf
Internal buffer uses TNT.
Definition: Blobber.h:231
Isis::Table
Class for storing Table blobs information.
Definition: Table.h:61
Isis::Blobber::deepcopy
Blobber deepcopy() const
Create a unique copy of this blob.
Definition: Blobber.cpp:107
Isis::Blobber::getFieldName
QString getFieldName() const
Retreive the name of the field in the Tabel object BLOB.
Definition: Blobber.h:191
Isis::Cube
IO Handler for Isis Cubes.
Definition: Cube.h:167
Isis::IException
Isis exception class.
Definition: IException.h:91
Isis::TableField::isDouble
bool isDouble() const
Determines whether the field type is Double.
Definition: TableField.cpp:132
Isis::Blobber::getBlobName
QString getBlobName() const
Retrieves the name of the Table object.
Definition: Blobber.h:183
Isis::Blobber::loadDouble
void loadDouble(Table &tbl)
Provides direct reading in of the field data from the BLOB.
Definition: Blobber.cpp:167
Isis::IException::Programmer
@ Programmer
This error is for when a programmer made an API call that was illegal.
Definition: IException.h:146
Isis::Blobber::load
void load(const QString &filename)
Loads the contents of a BLOB from a cube file.
Definition: Blobber.cpp:120
Isis::Table::Records
int Records() const
Returns the number of records.
Definition: Table.cpp:313
Isis::Cube::open
void open(const QString &cfile, QString access="r")
This method will open an isis cube for reading or reading/writing.
Definition: Cube.cpp:627
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16
Isis::TableField
Class for storing an Isis::Table's field information.
Definition: TableField.h:47