r126: *** empty log message ***
[ctsim.git] / include / filter.h
index 274d7920443ec1f7b5a8e7d67db607eab0ac1042..19266a0edbce9e909d39bb127436f7de8a86fa68 100644 (file)
+/*****************************************************************************
+** FILE IDENTIFICATION
+**
+**     Name:         filter.h
+**      Purpose:      Signal filter header file
+**     Programmer:   Kevin Rosenberg
+**     Date Started: June 2000
+**
+**  This is part of the CTSim program
+**  Copyright (C) 1983-2000 Kevin Rosenberg
+**
+**  $Id: filter.h,v 1.5 2000/06/30 02:03:27 kevin Exp $
+**
+**  This program is free software; you can redistribute it and/or modify
+**  it under the terms of the GNU General Public License (version 2) as
+**  published by the Free Software Foundation.
+**
+**  This program is distributed in the hope that it will be useful,
+**  but WITHOUT ANY WARRANTY; without even the implied warranty of
+**  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+**  GNU General Public License for more details.
+**
+**  You should have received a copy of the GNU General Public License
+**  along with this program; if not, write to the Free Software
+**  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+******************************************************************************/
+
+#ifndef FILTER_H
+#define FILTER_H
+
 class SignalFilter {
  public:
 
-    SignalFilter (const FilterType filt_type, double bw, double xmin, double xmax, int n, double param, const DomainType domain, const int numInt);
+    typedef enum {        
+       FILTER_INVALID,
+       FILTER_BANDLIMIT, 
+       FILTER_SINC,
+       FILTER_G_HAMMING,
+       FILTER_COSINE,
+       FILTER_TRIANGLE,
+       FILTER_ABS_BANDLIMIT,   // filter times |x| 
+       FILTER_ABS_SINC, 
+       FILTER_ABS_G_HAMMING,
+       FILTER_ABS_COSINE,
+       FILTER_SHEPP
+    } FilterID;
+
+    typedef enum {
+       FILTER_METHOD_INVALID,
+       FILTER_METHOD_CONVOLUTION,
+       FILTER_METHOD_FOURIER,
+       FILTER_METHOD_FFT,
+       FILTER_METHOD_FFT_ZEROPAD_2,
+       FILTER_METHOD_FFT_ZEROPAD_4,
+       FILTER_METHOD_FFT_ZEROPAD_6
+    } FilterMethodID;
+
+    typedef enum {
+       DOMAIN_INVALID,
+       DOMAIN_FREQUENCY,
+       DOMAIN_SPATIAL 
+    } DomainID;
+    
+    static const char FILTER_ABS_BANDLIMIT_STR[]= "abs_bandlimit";
+    static const char FILTER_ABS_SINC_STR[]=      "abs_sinc";
+    static const char FILTER_ABS_COS_STR[]=       "abs_cos";
+    static const char FILTER_ABS_HAMMING_STR[]=   "abs_hamming";
+    static const char FILTER_SHEPP_STR[]=         "shepp";
+    static const char FILTER_BANDLIMIT_STR[]=     "bandlimit";
+    static const char FILTER_SINC_STR[]=          "sinc";
+    static const char FILTER_COS_STR[]=           "cos";
+    static const char FILTER_HAMMING_STR[]=       "hamming";
+    static const char FILTER_TRIANGLE_STR[]=      "triangle";
+    
+    static const char FILTER_METHOD_CONVOLUTION_STR[]=  "convolution";
+    static const char FILTER_METHOD_FOURIER_STR[]=      "fourier";
+    static const char FILTER_METHOD_FFT_STR[]=          "fft";
+    static const char FILTER_METHOD_FFT_ZEROPAD_2_STR[]="fft_zeropad2";
+    static const char FILTER_METHOD_FFT_ZEROPAD_4_STR[]="fft_zeropad4";
+    static const char FILTER_METHOD_FFT_ZEROPAD_6_STR[]="fft_zeropad6";
+
+    static const char DOMAIN_FREQUENCY_STR[]=    "frequency";
+    static const char DOMAIN_SPATIAL_STR[]= "spatial";
+
+
+    SignalFilter (const char* filterName, double bw, double xmin, double xmax, int n, double param, const char* domainName, const int numIntegral = 0);
+
+    SignalFilter (const FilterID filt_type, double bw, double xmin, double xmax, int n, double param, const DomainID domain, const int numIntegral = 0);
+
+    SignalFilter (const char* filterName, const char* domainName, double bw, double param, int numIntegral = 0);
 
     ~SignalFilter (void);
 
     double* getFilter (void) const
       { return m_vecFilter; }
 
-    double convolve (const double f[], const double dx, const int n, const int np, const FunctionSymmetry func_type) const;
+    double convolve (const double f[], const double dx, const int n, const int np) const;
+
+    double convolve (const float f[], const double dx, const int n, const int np) const;
+
+    bool fail(void) const      {return m_fail;}
+    const string& failMessage(void) const {return m_failMessage;}
+
+    const string& nameFilter(void) const       { return m_nameFilter;}
+    const string& nameDomain(void) const       { return m_nameDomain;}
+    const FilterID idFilter(void) const        { return m_idFilter;}
+    const DomainID idDomain(void) const        { return m_idDomain;}
 
-    double convolve (const float f[], const double dx, const int n, const int np, const FunctionSymmetry func_type) const;
+    double response (double x);
 
-    static double spatialResponseCalc (FilterType fType, double bw, double x, double param, int n);
+    static double spatialResponse (FilterID fType, double bw, double x, double param, int nIntegral = 0);
 
-    static double spatialResponseAnalytic (FilterType fType, double bw, double x, double param);
+    static double frequencyResponse (FilterID fType, double bw, double u, double param);
 
-    static double frequencyResponse (FilterType fType, double bw, double u, double param);
+    static double spatialResponseCalc (FilterID fType, double bw, double x, double param, int n);
+
+    static double spatialResponseAnalytic (FilterID fType, double bw, double x, double param);
 
  private:
-    double *m_vecFilter;
     double m_bw;
-    FilterType m_filterType;
-
-    double spatialResponseCalc (double x, double param, int n) const;
+    int m_nPoints;
+    double m_xmin;
+    double m_xmax;
+    double* m_vecFilter;
+    bool m_fail;
+    string m_failMessage;
+    string m_nameFilter;
+    string m_nameFilterMethod;
+    string m_nameDomain;
+    FilterID m_idFilter;
+    FilterMethodID m_idFilterMethod;
+    DomainID m_idDomain;
+    double m_filterParam;
+    int m_numIntegral;
+
+    static FilterID convertFilterNameToID (const char* filterName);
+    static const char* convertFilterIDToName (const FilterID filterID);
+    static const DomainID convertDomainNameToID (const char* domainName);
+    static const char* convertDomainIDToName (const DomainID domainID);
+
+    void init (const FilterID filt_type, double bw, double xmin, double xmax, int n, double param, const DomainID domain, const int numInt);
+
+double spatialResponseCalc (double x, double param, int n) const;
 
     double spatialResponseAnalytic (double x, double param) const;
 
@@ -36,3 +153,5 @@ class SignalFilter {
 
 };
 
+
+#endif