Isis Developer Reference
SplineFill.h
Go to the documentation of this file.
1 #ifndef SplineFill_h
2 #define SplineFill_h
3 
10 /* SPDX-License-Identifier: CC0-1.0 */
11 
12 #include <string>
13 #include <vector>
14 
15 #include "IString.h"
16 #include "Module.h"
17 #include "NumericalApproximation.h"
18 #include "SpecialPixel.h"
19 #include "IException.h"
20 
21 namespace Isis {
22 
32  class SplineFill : public Module {
33 
34  public:
35  // Constructors and Destructor
36  SplineFill() : Module("SplineFill"), _filled(0) { }
37 
38  SplineFill(const Module &c) :
39  Module("SplineFill", c), _filled(0) {
40  fill(c.ref());
41  _history.add(formHistory());
42  }
43 
44  SplineFill(const HiVector &v) :
45  Module("SplineFill"), _filled(0) {
46  fill(v);
47  _history.add(formHistory());
48  }
49  SplineFill(const HiVector &v, const HiHistory &h) :
50  Module("SplineFill", h), _filled(0) {
51  fill(v);
52  _history.add(formHistory());
53  }
54 
56  virtual ~SplineFill() { }
57 
58  void Process(const HiVector &v) {
59  fill(v);
60  _history.clear();
61  _history.add(formHistory());
62  }
63 
64  inline int Filled() const { return (_filled); }
65 
66  private:
67  int _filled;
68 
69  QString formHistory() {
70  QString cfilled(toString(_filled));
71  return (QString("SplineFill(Cubic,Filled[" + cfilled + "])"));
72  }
73 
74  void fill(const HiVector &v) {
75  NumericalApproximation spline(NumericalApproximation::CubicNatural);
76  for (int i = 0 ; i < v.dim() ; i++) {
77  if (!IsSpecial(v[i])) {
78  spline.AddData(i, v[i]);
79  }
80  }
81 
82  // Compute the spline and fill missing data
83  HiVector vout(v.dim());
84  _filled = 0;
85  for (int j = 0 ; j < v.dim() ; j++) {
86  if (IsSpecial(v[j])) {
87  vout[j] = spline.Evaluate(j,NumericalApproximation::NearestEndpoint);
88  _filled++;
89  }
90  else {
91  vout[j] = v[j];
92  }
93  }
94 
95  _data = vout;
96  return;
97  }
98  };
99 
100 } // namespace Isis
101 #endif
Isis::SplineFill::SplineFill
SplineFill()
Definition: SplineFill.h:36
Isis::Module::_history
HiHistory _history
Hierarchial component history.
Definition: Module.h:152
Isis::SplineFill::~SplineFill
virtual ~SplineFill()
Destructor.
Definition: SplineFill.h:56
Isis::HiHistory::clear
void clear()
Definition: HiCalTypes.h:65
Isis::Module
Module manages HiRISE calibration vectors from various sources.
Definition: Module.h:39
Isis::Module::ref
const HiVector & ref() const
Return data via a const reference.
Definition: Module.h:111
SpecialPixel.h
Isis::SplineFill
Compute a low pass filter from a Module class content.
Definition: SplineFill.h:32
NumericalApproximation.h
Isis::SplineFill::Filled
int Filled() const
Definition: SplineFill.h:64
Isis::HiHistory
Definition: HiCalTypes.h:30
Isis::toString
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Definition: IString.cpp:211
Isis::IsSpecial
bool IsSpecial(const double d)
Returns if the input pixel is special.
Definition: SpecialPixel.h:197
IString.h
Isis::NumericalApproximation::NearestEndpoint
@ NearestEndpoint
Evaluate() returns the y-value of the nearest endpoint if a is outside of the domain.
Definition: NumericalApproximation.h:817
Isis::Module::_data
HiVector _data
Data vector.
Definition: Module.h:151
Isis::HiVector
TNT::Array1D< double > HiVector
1-D Buffer
Definition: HiCalTypes.h:27
Isis::HiHistory::add
void add(const QString &event)
Definition: HiCalTypes.h:55
IException.h
Isis::SplineFill::SplineFill
SplineFill(const Module &c)
Definition: SplineFill.h:38
Isis::SplineFill::SplineFill
SplineFill(const HiVector &v, const HiHistory &h)
Definition: SplineFill.h:49
Isis::SplineFill::Process
void Process(const HiVector &v)
Default processing behavior makes a reference copy of data array.
Definition: SplineFill.h:58
Isis::SplineFill::SplineFill
SplineFill(const HiVector &v)
Definition: SplineFill.h:44
Module.h
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16
Isis::NumericalApproximation::CubicNatural
@ CubicNatural
Cubic Spline interpolation with natural boundary conditions.
Definition: NumericalApproximation.h:734