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"
18#include "SpecialPixel.h"
19#include "IException.h"
20
21namespace 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);
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
Definition HiCalTypes.h:30
void clear()
Definition HiCalTypes.h:65
void add(const QString &event)
Definition HiCalTypes.h:55
Module manages HiRISE calibration vectors from various sources.
Definition Module.h:39
HiVector _data
Data vector.
Definition Module.h:151
HiHistory _history
Hierarchial component history.
Definition Module.h:152
@ CubicNatural
Cubic Spline interpolation with natural boundary conditions.
Definition NumericalApproximation.h:734
@ NearestEndpoint
Evaluate() returns the y-value of the nearest endpoint if a is outside of the domain.
Definition NumericalApproximation.h:817
Compute a low pass filter from a Module class content.
Definition SplineFill.h:32
SplineFill()
Definition SplineFill.h:36
SplineFill(const HiVector &v, const HiHistory &h)
Definition SplineFill.h:49
void Process(const HiVector &v)
Default processing behavior makes a reference copy of data array.
Definition SplineFill.h:58
SplineFill(const HiVector &v)
Definition SplineFill.h:44
virtual ~SplineFill()
Destructor.
Definition SplineFill.h:56
SplineFill(const Module &c)
Definition SplineFill.h:38
int Filled() const
Definition SplineFill.h:64
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Definition IString.cpp:211
bool IsSpecial(const double d)
Returns if the input pixel is special.
Definition SpecialPixel.h:197
TNT::Array1D< double > HiVector
1-D Buffer
Definition HiCalTypes.h:27