Isis 3.0 Developer's Reference (API) |
Home |
00001 00024 #ifndef Chip_h 00025 #define Chip_h 00026 00027 #include <vector> 00028 00029 #include "Affine.h" 00030 #include "Interpolator.h" 00031 #include "Pvl.h" 00032 #include "SpecialPixel.h" 00033 #include "geos/geom/MultiPolygon.h" 00034 00035 using namespace std; 00036 namespace Isis { 00037 class Cube; 00038 class Statistics; 00039 00114 class Chip { 00115 public: 00116 Chip(); 00117 Chip(const Chip &other); 00118 Chip(const int samples, const int lines); 00119 virtual ~Chip(); 00120 00121 void SetSize(const int samples, const int lines) throw(iException &); 00122 00123 bool IsInsideChip(double sample, double line); 00124 00126 inline int Samples() const { 00127 return p_chipSamples; 00128 }; 00129 00131 inline int Lines() const { 00132 return p_chipLines; 00133 }; 00134 00137 inline string Filename() const { 00138 return p_filename; 00139 }; 00140 00141 void SetAllValues(const double &d); 00142 00150 void SetValue(int sample, int line, const double &value) { 00151 p_buf[line-1][sample-1] = value; 00152 } 00153 00165 inline double GetValue(int sample, int line) { 00166 return p_buf[line-1][sample-1]; 00167 } 00168 00178 inline const double GetValue(int sample, int line) const { 00179 return p_buf[line-1][sample-1]; 00180 } 00181 00182 void TackCube(const double cubeSample, const double cubeLine); 00183 00190 inline int TackSample() const { 00191 return p_tackSample; 00192 }; 00193 00200 inline int TackLine() const { 00201 return p_tackLine; 00202 }; 00203 00204 void Load(Cube &cube, const double rotation = 0.0, const double scale = 1.0, 00205 const int band = 1); 00206 void Load(Cube &cube, Chip &match, Cube &matchChipCube, 00207 const double scale = 1.0, const int band = 1) throw(iException &); 00208 void Load(Cube &cube, const Affine &affine, const bool &keepPoly = true, 00209 const int band = 1); 00210 00211 void SetChipPosition(const double sample, const double line); 00212 00214 inline double CubeSample() const { 00215 return p_cubeSample; 00216 }; 00217 00219 inline double CubeLine() const { 00220 return p_cubeLine; 00221 }; 00222 00223 void SetCubePosition(const double sample, const double line); 00224 00226 double ChipSample() const { 00227 return p_chipSample; 00228 }; 00229 00231 double ChipLine() const { 00232 return p_chipLine; 00233 }; 00234 00235 void SetValidRange(const double minimum = Isis::ValidMinimum, 00236 const double maximum = Isis::ValidMaximum) throw(iException &); 00237 bool IsValid(double percentage); 00238 00245 inline bool IsValid(int sample, int line) { 00246 double value = GetValue(sample, line); 00247 if(value < p_validMinimum) return false; 00248 if(value > p_validMaximum) return false; 00249 return true; 00250 } 00251 00252 Chip Extract(int samples, int lines, int samp, int line) throw(iException &); 00253 void Extract(int samp, int line, Chip &output); 00254 Isis::Statistics *Statistics(); 00255 void Extract(Chip &output, Affine &affine); 00256 void Write(const string &filename); 00257 00258 void SetClipPolygon(const geos::geom::MultiPolygon &clipPolygon); 00259 00260 Chip &operator=(const Chip &other); 00261 00273 const Affine &GetTransform() const { 00274 return (p_affine); 00275 } 00276 00290 void SetTransform(const Affine &affine, const bool &keepPoly = true) { 00291 p_affine = affine; 00292 if(!keepPoly) { 00293 delete p_clipPolygon; 00294 p_clipPolygon = 0; 00295 } 00296 return; 00297 } 00298 00309 const Interpolator::interpType GetReadInterpolator() { 00310 return p_readInterpolator; 00311 } 00312 00313 00325 void SetReadInterpolator(const Interpolator::interpType type) { 00326 if(type == Interpolator::NearestNeighborType || 00327 type == Interpolator::BiLinearType || 00328 type == Interpolator::CubicConvolutionType) { 00329 p_readInterpolator = type; 00330 return; 00331 } 00332 // Interpolator::None is not valid type 00333 string msg = "Invalid Interpolator type. Cannot use ["; 00334 msg += iString(type) + "] to read cube into chip."; 00335 throw iException::Message(iException::Programmer, msg, _FILEINFO_); 00336 } 00337 00338 private: 00339 void Init(const int samples, const int lines); 00340 void Read(Cube &cube, const int band); 00341 vector<int> MovePoints(const int startSamp, const int startLine, 00342 const int endSamp, const int endLine); 00343 bool PointsColinear(const double x0, const double y0, 00344 const double x1, const double y1, 00345 const double x2, const double y2, 00346 const double tol); 00347 00348 00349 int p_chipSamples; 00350 int p_chipLines; 00351 vector<vector <double> > p_buf; 00352 int p_tackSample; 00353 int p_tackLine; 00354 00355 double p_cubeTackSample; 00356 double p_cubeTackLine; 00357 00358 double p_validMinimum; 00359 double p_validMaximum; 00360 00361 double p_chipSample; 00362 double p_chipLine; 00363 double p_cubeSample; 00364 double p_cubeLine; 00365 geos::geom::MultiPolygon *p_clipPolygon; 00366 00367 Affine p_affine; 00368 Interpolator::interpType p_readInterpolator; 00369 string p_filename; 00370 }; 00371 }; 00372 00373 #endif