Isis 3 Programmer Reference
Chip.h
Go to the documentation of this file.
1 
24 #ifndef Chip_h
25 #define Chip_h
26 
27 
28 #include "Affine.h"
29 #include "Interpolator.h"
30 #include "Pvl.h"
31 #include "SpecialPixel.h"
32 
33 #include <vector>
34 
35 #include <geos/geom/MultiPolygon.h>
36 
37 namespace Isis {
38  class Cube;
39  class Statistics;
40 
102  class Chip {
103  public:
104  Chip();
105  Chip(const Chip &other);
106  Chip(const int samples, const int lines);
107  virtual ~Chip();
108 
109  void SetSize(const int samples, const int lines);
110  bool IsInsideChip(double sample, double line);
111 
115  inline int Samples() const {
116  return m_chipSamples;
117  };
118 
122  inline int Lines() const {
123  return m_chipLines;
124  };
125 
129  inline QString FileName() const {
130  return m_filename;
131  };
132 
133  void SetAllValues(const double &d);
134 
142  void SetValue(int sample, int line, const double &value) {
143  m_buf[line-1][sample-1] = value;
144  }
145 
161  inline double GetValue(int sample, int line) {
162  return m_buf[line-1][sample-1];
163  }
164 
179  inline double GetValue(int sample, int line) const {
180  return m_buf[line-1][sample-1];
181  }
182 
183  void TackCube(const double cubeSample, const double cubeLine);
184 
192  inline int TackSample() const {
193  return m_tackSample;
194  };
195 
203  inline int TackLine() const {
204  return m_tackLine;
205  };
206 
207  void Load(Cube &cube, const double rotation = 0.0, const double scale = 1.0,
208  const int band = 1);
209  void Load(Cube &cube, Chip &match, Cube &matchChipCube,
210  const double scale = 1.0, const int band = 1);
211  void Load(Cube &cube, const Affine &affine, const bool &keepPoly = true,
212  const int band = 1);
213 
214  void SetChipPosition(const double sample, const double line);
215 
219  inline double CubeSample() const {
220  return m_cubeSample;
221  };
222 
226  inline double CubeLine() const {
227  return m_cubeLine;
228  };
229 
230  void SetCubePosition(const double sample, const double line);
231 
235  double ChipSample() const {
236  return m_chipSample;
237  };
238 
242  double ChipLine() const {
243  return m_chipLine;
244  };
245 
246  void SetValidRange(const double minimum = Isis::ValidMinimum,
247  const double maximum = Isis::ValidMaximum);
248 
256  inline bool IsValid(int sample, int line) {
257  double value = GetValue(sample, line);
258  if (value < m_validMinimum) return false;
259  if (value > m_validMaximum) return false;
260  return true;
261  }
262 
271  bool IsValid(double percentage);
272  Chip Extract(int samples, int lines, int samp, int line);
273  void Extract(int samp, int line, Chip &output);
275  void Extract(Chip &output, Affine &affine);
276  void Write(const QString &filename);
277 
278  void SetClipPolygon(const geos::geom::MultiPolygon &clipPolygon);
279 
280  Chip &operator=(const Chip &other);
281 
291  const Affine &GetTransform() const {
292  return (m_affine);
293  }
294 
306  void SetTransform(const Affine &affine, const bool &keepPoly = true) {
307  m_affine = affine;
308  if (!keepPoly) {
309  delete m_clipPolygon;
310  m_clipPolygon = 0;
311  }
312  return;
313  }
314 
326  return m_readInterpolator;
327  }
328 
340  if (type == Interpolator::NearestNeighborType ||
341  type == Interpolator::BiLinearType ||
342  type == Interpolator::CubicConvolutionType) {
343  m_readInterpolator = type;
344  return;
345  }
346  // Interpolator::None is not valid type
347  QString msg = "Invalid Interpolator type. Cannot use [";
348  msg += toString(type) + "] to read cube into chip.";
350  }
351 
352  private:
353  void Init(const int samples, const int lines);
354  void Read(Cube &cube, const int band);
355  std::vector<int> MovePoints(int startSamp, int startLine,
356  int endSamp, int endLine);
357  bool PointsColinear(double x0, double y0,
358  double x1, double y1,
359  double x2, double y2,
360  double tol);
361 
364  std::vector< std::vector<double> > m_buf;
367 
369  double m_cubeTackLine;
370 
371  double m_validMinimum;
372  double m_validMaximum;
373 
374  double m_chipSample;
375  double m_chipLine;
376  double m_cubeSample;
377  double m_cubeLine;
378 
379  geos::geom::MultiPolygon *m_clipPolygon;
380  // (line,samp)
381 
383  // Used to load cubes into chip
384 
386  // SetReadInterpolator. Used to read
387  // cubes into chip.
388 
389  QString m_filename;
390  };
391 };
392 
393 #endif
void SetChipPosition(const double sample, const double line)
Compute the position of the cube given a chip coordinate.
Definition: Chip.cpp:665
void SetValidRange(const double minimum=Isis::ValidMinimum, const double maximum=Isis::ValidMaximum)
Set the valid range of data in the chip.
Definition: Chip.cpp:703
void SetCubePosition(const double sample, const double line)
Compute the position of the chip given a cube coordinate.
Definition: Chip.cpp:682
virtual ~Chip()
Destroys the Chip object.
Definition: Chip.cpp:110
interpType
The interpolator type, including: None, Nearest Neighbor, BiLinear or Cubic Convultion.
Definition: Interpolator.h:57
double m_validMaximum
valid maximum chip pixel value
Definition: Chip.h:372
const double ValidMinimum
The minimum valid double value for Isis pixels.
Definition: SpecialPixel.h:102
double GetValue(int sample, int line) const
Get a value from a Chip.
Definition: Chip.h:179
double m_cubeLine
cube line set by SetCubePosition
Definition: Chip.h:377
const Affine & GetTransform() const
Returns the Affine transformation of chip-to-cube indices.
Definition: Chip.h:291
A small chip of data used for pattern matching.
Definition: Chip.h:102
double m_cubeSample
cube sample set by SetCubePosition
Definition: Chip.h:376
Interpolator::interpType m_readInterpolator
Interpolator type set by.
Definition: Chip.h:385
int m_tackSample
Middle sample of the chip.
Definition: Chip.h:365
bool IsInsideChip(double sample, double line)
Definition: Chip.cpp:184
void TackCube(const double cubeSample, const double cubeLine)
This sets which cube position will be located at the chip tack position.
Definition: Chip.cpp:204
double m_chipSample
chip sample set by SetChip/CubePosition
Definition: Chip.h:374
void SetTransform(const Affine &affine, const bool &keepPoly=true)
Sets the internal Affine transform to new translation.
Definition: Chip.h:306
void SetReadInterpolator(const Interpolator::interpType type)
Sets Interpolator Type for loading a chip.
Definition: Chip.h:339
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Definition: IString.cpp:226
This error is for when a programmer made an API call that was illegal.
Definition: IException.h:162
Chip Extract(int samples, int lines, int samp, int line)
Extract a sub-chip from a chip.
Definition: Chip.cpp:749
double m_cubeTackLine
cube line at the chip tack
Definition: Chip.h:369
This class is used to accumulate statistics on double arrays.
Definition: Statistics.h:107
bool PointsColinear(double x0, double y0, double x1, double y1, double x2, double y2, double tol)
This method is called by Load() to determine whether the given 3 points are nearly colinear...
Definition: Chip.cpp:568
int Lines() const
Definition: Chip.h:122
Isis::Statistics * Statistics()
Returns a statistics object of the current data in the chip.
Definition: Chip.cpp:931
QString FileName() const
Definition: Chip.h:129
Affine basis function.
Definition: Affine.h:80
double m_validMinimum
valid minimum chip pixel value
Definition: Chip.h:371
bool IsValid(int sample, int line)
Definition: Chip.h:256
std::vector< int > MovePoints(int startSamp, int startLine, int endSamp, int endLine)
This method is called by Load() to move a control point across the chip.
Definition: Chip.cpp:637
void Write(const QString &filename)
Writes the contents of the Chip to a cube.
Definition: Chip.cpp:1007
#define _FILEINFO_
Macro for the filename and line number.
Definition: IException.h:40
double CubeLine() const
Definition: Chip.h:226
Interpolator::interpType GetReadInterpolator()
Access method that returns the Interpolator Type used for loading a chip.
Definition: Chip.h:325
double m_cubeTackSample
cube sample at the chip tack
Definition: Chip.h:368
double CubeSample() const
Definition: Chip.h:219
int m_chipLines
Number of lines in the chip.
Definition: Chip.h:363
int TackSample() const
This method returns a chip&#39;s fixed tack sample; the middle of the chip.
Definition: Chip.h:192
void SetAllValues(const double &d)
Single value assignment operator.
Definition: Chip.cpp:122
double ChipLine() const
Definition: Chip.h:242
void SetSize(const int samples, const int lines)
Change the size of the Chip.
Definition: Chip.cpp:156
void Load(Cube &cube, const double rotation=0.0, const double scale=1.0, const int band=1)
Load cube data into the Chip.
Definition: Chip.cpp:225
Chip()
Constructs a Chip.
Definition: Chip.cpp:57
void SetClipPolygon(const geos::geom::MultiPolygon &clipPolygon)
Sets the clipping polygon for this chip.
Definition: Chip.cpp:1030
QString m_filename
FileName of loaded cube.
Definition: Chip.h:389
void SetValue(int sample, int line, const double &value)
Sets a value in the chip.
Definition: Chip.h:142
Affine m_affine
Transform set by SetTransform.
Definition: Chip.h:382
int m_tackLine
Middle line of the chip.
Definition: Chip.h:366
const double ValidMaximum
The maximum valid double value for Isis pixels.
Definition: SpecialPixel.h:137
geos::geom::MultiPolygon * m_clipPolygon
clipping polygon set by SetClipPolygon
Definition: Chip.h:379
int Samples() const
Definition: Chip.h:115
Isis exception class.
Definition: IException.h:107
int m_chipSamples
Number of samples in the chip.
Definition: Chip.h:362
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
void Read(Cube &cube, const int band)
This method reads data from a cube and puts it into the chip.
Definition: Chip.cpp:961
double ChipSample() const
Definition: Chip.h:235
Chip & operator=(const Chip &other)
Copy assignment operator.
Definition: Chip.cpp:1043
double GetValue(int sample, int line)
Loads a Chip with a value.
Definition: Chip.h:161
std::vector< std::vector< double > > m_buf
Chip buffer.
Definition: Chip.h:364
void Init(const int samples, const int lines)
Common initialization used by constructors.
Definition: Chip.cpp:138
double m_chipLine
chip line set by SetChip/CubePosition
Definition: Chip.h:375
int TackLine() const
This method returns a chip&#39;s fixed tack line; the middle of the chip.
Definition: Chip.h:203
IO Handler for Isis Cubes.
Definition: Cube.h:170