USGS

Isis 3.0 Object Programmers' Reference

Home

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 
232  double Blobber::int2ToDouble(int value) const {
233  if (value == NULL2) return NULL8;
234  else if (value == LOW_REPR_SAT2) return LOW_REPR_SAT8;
235  else if (value == LOW_INSTR_SAT2) return LOW_INSTR_SAT8;
236  else if (value == HIGH_INSTR_SAT2) return HIGH_INSTR_SAT8;
237  else if (value == HIGH_REPR_SAT2) return HIGH_REPR_SAT8;
238  else return value;
239 
240  }
241 
242 } // end namespace Isis