Isis 3 Developer Reference
SplineFill.h
Go to the documentation of this file.
1 #ifndef SplineFill_h
2 #define SplineFill_h
3 
27 #include <string>
28 #include <vector>
29 
30 #include "IString.h"
31 #include "Module.h"
32 #include "NumericalApproximation.h"
33 #include "SpecialPixel.h"
34 #include "IException.h"
35 
36 namespace Isis {
37 
47  class SplineFill : public Module {
48 
49  public:
50  // Constructors and Destructor
51  SplineFill() : Module("SplineFill"), _filled(0) { }
52 
53  SplineFill(const Module &c) :
54  Module("SplineFill", c), _filled(0) {
55  fill(c.ref());
56  _history.add(formHistory());
57  }
58 
59  SplineFill(const HiVector &v) :
60  Module("SplineFill"), _filled(0) {
61  fill(v);
62  _history.add(formHistory());
63  }
64  SplineFill(const HiVector &v, const HiHistory &h) :
65  Module("SplineFill", h), _filled(0) {
66  fill(v);
67  _history.add(formHistory());
68  }
69 
71  virtual ~SplineFill() { }
72 
73  void Process(const HiVector &v) {
74  fill(v);
75  _history.clear();
76  _history.add(formHistory());
77  }
78 
79  inline int Filled() const { return (_filled); }
80 
81  private:
82  int _filled;
83 
84  QString formHistory() {
85  QString cfilled(toString(_filled));
86  return (QString("SplineFill(Cubic,Filled[" + cfilled + "])"));
87  }
88 
89  void fill(const HiVector &v) {
90  NumericalApproximation spline(NumericalApproximation::CubicNatural);
91  for (int i = 0 ; i < v.dim() ; i++) {
92  if (!IsSpecial(v[i])) {
93  spline.AddData(i, v[i]);
94  }
95  }
96 
97  // Compute the spline and fill missing data
98  HiVector vout(v.dim());
99  _filled = 0;
100  for (int j = 0 ; j < v.dim() ; j++) {
101  if (IsSpecial(v[j])) {
102  vout[j] = spline.Evaluate(j,NumericalApproximation::NearestEndpoint);
103  _filled++;
104  }
105  else {
106  vout[j] = v[j];
107  }
108  }
109 
110  _data = vout;
111  return;
112  }
113  };
114 
115 } // namespace Isis
116 #endif
117 
const HiVector & ref() const
Return data via a const reference.
Definition: Module.h:126
SplineFill(const Module &c)
Definition: SplineFill.h:53
virtual ~SplineFill()
Destructor.
Definition: SplineFill.h:71
Definition: HiCalTypes.h:43
SplineFill()
Definition: SplineFill.h:51
HiVector _data
Data vector.
Definition: Module.h:166
int Filled() const
Definition: SplineFill.h:79
void clear()
Definition: HiCalTypes.h:78
Compute a low pass filter from a Module class content.
Definition: SplineFill.h:47
HiHistory _history
Hierarchial component history.
Definition: Module.h:167
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Definition: IString.cpp:226
Evaluate() returns the y-value of the nearest endpoint if a is outside of the domain.
Definition: NumericalApproximation.h:811
Cubic Spline interpolation with natural boundary conditions.
Definition: NumericalApproximation.h:728
SplineFill(const HiVector &v, const HiHistory &h)
Definition: SplineFill.h:64
void Process(const HiVector &v)
Default processing behavior makes a reference copy of data array.
Definition: SplineFill.h:73
SplineFill(const HiVector &v)
Definition: SplineFill.h:59
Module manages HiRISE calibration vectors from various sources.
Definition: Module.h:54
bool IsSpecial(const double d)
Returns if the input pixel is special.
Definition: SpecialPixel.h:212
void add(const QString &event)
Definition: HiCalTypes.h:68
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
TNT::Array1D< double > HiVector
1-D Buffer
Definition: HiCalTypes.h:40