USGS

Isis 3.0 Object Programmers' Reference

Home

Chip.h
Go to the documentation of this file.
1 
24 #ifndef Chip_h
25 #define Chip_h
26 
27 #include <vector>
28 
29 #include <geos/geom/MultiPolygon.h>
30 
31 #include "Affine.h"
32 #include "Interpolator.h"
33 #include "Pvl.h"
34 #include "SpecialPixel.h"
35 
36 namespace Isis {
37  class Cube;
38  class Statistics;
39 
114  class Chip {
115  public:
116  Chip();
117  Chip(const Chip &other);
118  Chip(const int samples, const int lines);
119  virtual ~Chip();
120 
121  void SetSize(const int samples, const int lines);
122 
123  bool IsInsideChip(double sample, double line);
124 
126  inline int Samples() const {
127  return p_chipSamples;
128  };
129 
131  inline int Lines() const {
132  return p_chipLines;
133  };
134 
137  inline QString FileName() const {
138  return p_filename;
139  };
140 
141  void SetAllValues(const double &d);
142 
150  void SetValue(int sample, int line, const double &value) {
151  p_buf[line-1][sample-1] = value;
152  }
153 
165  inline double GetValue(int sample, int line) {
166  return p_buf[line-1][sample-1];
167  }
168 
178  inline const double GetValue(int sample, int line) const {
179  return p_buf[line-1][sample-1];
180  }
181 
182  void TackCube(const double cubeSample, const double cubeLine);
183 
190  inline int TackSample() const {
191  return p_tackSample;
192  };
193 
200  inline int TackLine() const {
201  return p_tackLine;
202  };
203 
204  void Load(Cube &cube, const double rotation = 0.0, const double scale = 1.0,
205  const int band = 1);
206  void Load(Cube &cube, Chip &match, Cube &matchChipCube,
207  const double scale = 1.0, const int band = 1);
208  void Load(Cube &cube, const Affine &affine, const bool &keepPoly = true,
209  const int band = 1);
210 
211  void SetChipPosition(const double sample, const double line);
212 
214  inline double CubeSample() const {
215  return p_cubeSample;
216  };
217 
219  inline double CubeLine() const {
220  return p_cubeLine;
221  };
222 
223  void SetCubePosition(const double sample, const double line);
224 
226  double ChipSample() const {
227  return p_chipSample;
228  };
229 
231  double ChipLine() const {
232  return p_chipLine;
233  };
234 
235  void SetValidRange(const double minimum = Isis::ValidMinimum,
236  const double maximum = Isis::ValidMaximum);
237  bool IsValid(double percentage);
238 
245  inline bool IsValid(int sample, int line) {
246  double value = GetValue(sample, line);
247  if(value < p_validMinimum) return false;
248  if(value > p_validMaximum) return false;
249  return true;
250  }
251 
252  Chip Extract(int samples, int lines, int samp, int line);
253  void Extract(int samp, int line, Chip &output);
255  void Extract(Chip &output, Affine &affine);
256  void Write(const QString &filename);
257 
258  void SetClipPolygon(const geos::geom::MultiPolygon &clipPolygon);
259 
260  Chip &operator=(const Chip &other);
261 
273  const Affine &GetTransform() const {
274  return (p_affine);
275  }
276 
290  void SetTransform(const Affine &affine, const bool &keepPoly = true) {
291  p_affine = affine;
292  if(!keepPoly) {
293  delete p_clipPolygon;
294  p_clipPolygon = 0;
295  }
296  return;
297  }
298 
310  return p_readInterpolator;
311  }
312 
313 
326  if(type == Interpolator::NearestNeighborType ||
327  type == Interpolator::BiLinearType ||
328  type == Interpolator::CubicConvolutionType) {
329  p_readInterpolator = type;
330  return;
331  }
332  // Interpolator::None is not valid type
333  QString msg = "Invalid Interpolator type. Cannot use [";
334  msg += toString(type) + "] to read cube into chip.";
336  }
337 
338  private:
339  void Init(const int samples, const int lines);
340  void Read(Cube &cube, const int band);
341  std::vector<int> MovePoints(int startSamp, int startLine,
342  int endSamp, int endLine);
343  bool PointsColinear(double x0, double y0,
344  double x1, double y1,
345  double x2, double y2,
346  double tol);
347 
348 
351  std::vector< std::vector<double> > p_buf;
354 
356  double p_cubeTackLine;
357 
358  double p_validMinimum;
359  double p_validMaximum;
360 
361  double p_chipSample;
362  double p_chipLine;
363  double p_cubeSample;
364  double p_cubeLine;
365  geos::geom::MultiPolygon *p_clipPolygon;
366 
369  QString p_filename;
370  };
371 };
372 
373 #endif