Isis 3 Programmer Reference
Blobber.cpp
Go to the documentation of this file.
1 
23 #include "Blobber.h"
24 
25 #include <vector>
26 
27 #include "Cube.h"
28 #include "IException.h"
29 #include "Progress.h"
30 #include "SpecialPixel.h"
31 #include "Table.h"
32 #include "TableField.h"
33 
34 using std::vector;
35 
36 namespace Isis {
43  Blobber::Blobber() : _blobname("_undefined_"), _fieldname("_undefined_"),
44  _name("Blob") { }
63  Blobber::Blobber(const QString &blobname, const QString &fieldname,
64  const QString &name) : _blobname(blobname),
65  _fieldname(fieldname), _name(name) {
66  }
67 
92  Blobber::Blobber(Cube &cube, const QString &blobname,
93  const QString &fieldname,
94  const QString &name) :
95  _blobname(blobname),
96  _fieldname(fieldname),
97  _name(name) {
98  load(cube);
99  }
100 
124  Blobber myblob = *this;
125  myblob._buf = _buf.copy();
126  return (myblob);
127  }
128 
136  void Blobber::load(const QString &filename) {
137  Cube cube;
138  cube.open(filename);
139  load(cube);
140  return;
141  }
142 
143 
156  void Blobber::load(Cube &cube) {
157  Table tbl(getBlobName());
158  cube.read(tbl);
159  TableField data = tbl[0][getFieldName()];
160  if (data.isDouble()) {
161  loadDouble(tbl);
162  }
163  else if (data.isInteger()) {
164  loadInteger(tbl);
165  }
166  else {
167  QString msg = "Field type for " + getFieldName() +
168  " is not double or integer";
170  }
171  }
172 
173 
185  int nlines = tbl.Records();
186  int nsamps = tbl[0][getFieldName()].size();
187  BlobBuf pixels(nlines, nsamps);
188  for (int i = 0 ; i < nlines ; i++) {
189  vector<double> d = tbl[i][getFieldName()];
190  for (unsigned int j = 0 ; j < d.size() ; j++) {
191  pixels[i][j] = d[j];
192  }
193  }
194  _buf = pixels;
195  }
196 
211  int nlines = tbl.Records();
212  int nsamps = tbl[0][getFieldName()].size();
213  BlobBuf pixels(nlines, nsamps);
214  for (int i = 0 ; i < nlines ; i++) {
215  vector<int> d = tbl[i][getFieldName()];
216  for (unsigned int j = 0 ; j < d.size(); j++) {
217  pixels[i][j] = int2ToDouble(d[j]);
218  }
219  }
220  _buf = pixels;
221  }
222 
234  double Blobber::int2ToDouble(int value) const {
235  if (value == NULL2) return NULL8;
236  else if (value == LOW_REPR_SAT2) return LOW_REPR_SAT8;
237  else if (value == LOW_INSTR_SAT2) return LOW_INSTR_SAT8;
238  else if (value == HIGH_INSTR_SAT2) return HIGH_INSTR_SAT8;
239  else if (value == HIGH_REPR_SAT2) return HIGH_REPR_SAT8;
240  else return value;
241 
242  }
243 
244 
245  double Blobber::int2ToDouble(unsigned int value) const {
246  if (value == NULLUI4) return NULL8;
247  else if (value == LOW_REPR_SATUI4) return LOW_REPR_SAT8;
248  else if (value == LOW_INSTR_SATUI4) return LOW_INSTR_SAT8;
249  else if (value == HIGH_INSTR_SATUI4) return HIGH_INSTR_SAT8;
250  else if (value == HIGH_REPR_SATUI4) return HIGH_REPR_SAT8;
251  else return value;
252 
253  }
254 
255 
256 
257 
258 } // end namespace Isis
TNT::Array2D< double > BlobBuf
Internal buffer uses TNT.
Definition: Blobber.h:247
int Records() const
Returns the number of records.
Definition: Table.cpp:224
QString getFieldName() const
Retreive the name of the field in the Tabel object BLOB.
Definition: Blobber.h:207
Base class for accessing ISIS blobs.
Definition: Blobber.h:114
void load(const QString &filename)
Loads the contents of a BLOB from a cube file.
Definition: Blobber.cpp:136
void loadInteger(Table &tbl)
Provides direct reading in of the field data from the BLOB.
Definition: Blobber.cpp:210
QString getBlobName() const
Retrieves the name of the Table object.
Definition: Blobber.h:199
This error is for when a programmer made an API call that was illegal.
Definition: IException.h:162
void loadDouble(Table &tbl)
Provides direct reading in of the field data from the BLOB.
Definition: Blobber.cpp:184
bool isInteger() const
Determines whether the field type is Integer.
Definition: TableField.cpp:138
#define _FILEINFO_
Macro for the filename and line number.
Definition: IException.h:40
BlobBuf _buf
Buffer holding data.
Definition: Blobber.h:262
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
Blobber deepcopy() const
Create a unique copy of this blob.
Definition: Blobber.cpp:123
Class for storing Table blobs information.
Definition: Table.h:77
Isis exception class.
Definition: IException.h:107
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
Blobber()
Default basic constructor that is mostly not useful.
Definition: Blobber.cpp:43
Class for storing an Isis::Table&#39;s field information.
Definition: TableField.h:63
bool isDouble() const
Determines whether the field type is Double.
Definition: TableField.cpp:148
IO Handler for Isis Cubes.
Definition: Cube.h:170