Isis 3.0 Application Source Code Reference |
Home |
00001 #if !defined(SplineFill_h) 00002 #define SplineFill_h 00003 /** 00004 * @file 00005 * $Revision: 1.2 $ 00006 * $Date: 2008/11/06 00:08:15 $ 00007 * $Id: SplineFill.h,v 1.2 2008/11/06 00:08:15 jwalldren Exp $ 00008 * 00009 * Unless noted otherwise, the portions of Isis written by the USGS are 00010 * public domain. See individual third-party library and package descriptions 00011 * for intellectual property information, user agreements, and related 00012 * information. 00013 * 00014 * Although Isis has been used by the USGS, no warranty, expressed or 00015 * implied, is made by the USGS as to the accuracy and functioning of such 00016 * software and related material nor shall the fact of distribution 00017 * constitute any such warranty, and no responsibility is assumed by the 00018 * USGS in connection therewith. 00019 * 00020 * For additional information, launch 00021 * $ISISROOT/doc//documents/Disclaimers/Disclaimers.html 00022 * in a browser or see the Privacy & Disclaimers page on the Isis website, 00023 * http://isis.astrogeology.usgs.gov, and the USGS privacy and disclaimers on 00024 * http://www.usgs.gov/privacy.html. 00025 */ 00026 00027 #include <string> 00028 #include <vector> 00029 00030 #include "iString.h" 00031 #include "Module.h" 00032 #include "NumericalApproximation.h" 00033 #include "SpecialPixel.h" 00034 #include "iException.h" 00035 00036 namespace Isis { 00037 00038 /** 00039 * @brief Compute a low pass filter from a Module class content 00040 * 00041 * @ingroup Utility 00042 * 00043 * @author 2007-10-09 Kris Becker 00044 * @history 2008-11-05 Jeannie Walldren Replaced references to 00045 * DataInterp class with NumericalApproximation. 00046 */ 00047 class SplineFill : public Module { 00048 00049 public: 00050 // Constructors and Destructor 00051 SplineFill() : Module("SplineFill"), _filled(0) { } 00052 00053 SplineFill(const Module &c) : 00054 Module("SplineFill", c), _filled(0) { 00055 fill(c.ref()); 00056 _history.add(formHistory()); 00057 } 00058 00059 SplineFill(const HiVector &v) : 00060 Module("SplineFill"), _filled(0) { 00061 fill(v); 00062 _history.add(formHistory()); 00063 } 00064 SplineFill(const HiVector &v, const HiHistory &h) : 00065 Module("SplineFill", h), _filled(0) { 00066 fill(v); 00067 _history.add(formHistory()); 00068 } 00069 00070 /** Destructor */ 00071 virtual ~SplineFill() { } 00072 00073 void Process(const HiVector &v) { 00074 fill(v); 00075 _history.clear(); 00076 _history.add(formHistory()); 00077 } 00078 00079 inline int Filled() const { return (_filled); } 00080 00081 private: 00082 int _filled; //!< Number values replaced 00083 00084 std::string formHistory() { 00085 iString cfilled(_filled); 00086 return (std::string("SplineFill(Cubic,Filled[" + cfilled + "])")); 00087 } 00088 00089 void fill(const HiVector &v) { 00090 NumericalApproximation spline(NumericalApproximation::CubicNatural); 00091 for (int i = 0 ; i < v.dim() ; i++) { 00092 if (!IsSpecial(v[i])) { 00093 spline.AddData(i, v[i]); 00094 } 00095 } 00096 00097 // Compute the spline and fill missing data 00098 HiVector vout(v.dim()); 00099 _filled = 0; 00100 for (int j = 0 ; j < v.dim() ; j++) { 00101 if (IsSpecial(v[j])) { 00102 vout[j] = spline.Evaluate(j,NumericalApproximation::NearestEndpoint); 00103 _filled++; 00104 } 00105 else { 00106 vout[j] = v[j]; 00107 } 00108 } 00109 00110 _data = vout; 00111 return; 00112 } 00113 }; 00114 00115 } // namespace Isis 00116 #endif 00117