r126: *** empty log message ***
[ctsim.git] / include / filter.h
index b544a1f2132ac16671cbab6bde3e6c320cebcbbf..19266a0edbce9e909d39bb127436f7de8a86fa68 100644 (file)
@@ -1,7 +1,33 @@
+/*****************************************************************************
+** 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:
 
@@ -18,17 +44,50 @@ class SignalFilter {
        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_FREQ,
+       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 char* filterName, double bw, double xmin, double xmax, int n, double param, const char* domainName, const int numInt);
+    SignalFilter (const FilterID filt_type, double bw, double xmin, double xmax, int n, double param, const DomainID domain, const int numIntegral = 0);
 
-    SignalFilter (const FilterID filt_type, double bw, double xmin, double xmax, int n, double param, const DomainID domain, const int numInt);
+    SignalFilter (const char* filterName, const char* domainName, double bw, double param, int numIntegral = 0);
 
     ~SignalFilter (void);
 
@@ -40,19 +99,23 @@ class SignalFilter {
     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;}
 
-    static double response (const char* const FilterName, const char* const DomainName, double bw, double x, double param);
+    double response (double x);
+
+    static double spatialResponse (FilterID fType, double bw, double x, double param, int nIntegral = 0);
+
+    static double frequencyResponse (FilterID 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);
 
-    static double frequencyResponse (FilterID fType, double bw, double u, double param);
-
  private:
     double m_bw;
     int m_nPoints;
@@ -60,24 +123,15 @@ class SignalFilter {
     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;
-
-    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 DOMAIN_FREQ_STR[]=    "freq";
-    static const char DOMAIN_SPATIAL_STR[]= "spatial";
+    double m_filterParam;
+    int m_numIntegral;
 
     static FilterID convertFilterNameToID (const char* filterName);
     static const char* convertFilterIDToName (const FilterID filterID);