r385: no message
[ctsim.git] / include / filter.h
index 274d7920443ec1f7b5a8e7d67db607eab0ac1042..7b696b29e8553fd89e99d2b7dd67fa53a72a1a47 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.23 2001/01/12 21:53: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
+
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+#ifdef HAVE_FFTW
+#include <fftw.h>
+#include <rfftw.h>
+#endif
+
+
+// CLASS IDENTIFICATION
+//    SignalFilter       A filter used to process signals
+//
+// CONTAINS
+//    signal vector
+//
+//    Can create either a time/spatial waveform or a frequency signal
+//    Waveforms can be created either by direct calculation or by inverse fourier transform
+
 class SignalFilter {
  public:
-
-    SignalFilter (const FilterType filt_type, double bw, double xmin, double xmax, int n, double param, const DomainType domain, const int numInt);
+    static const int FILTER_INVALID;
+    static const int FILTER_ABS_BANDLIMIT;     // filter times |x|
+    static const int FILTER_ABS_SINC;
+    static const int FILTER_ABS_G_HAMMING;
+    static const int FILTER_ABS_COSINE;
+    static const int FILTER_SHEPP;
+    static const int FILTER_BANDLIMIT;
+    static const int FILTER_SINC;
+    static const int FILTER_G_HAMMING;
+    static const int FILTER_COSINE;
+    static const int FILTER_TRIANGLE;
+
+    static const int DOMAIN_INVALID;
+    static const int DOMAIN_FREQUENCY;
+    static const int DOMAIN_SPATIAL;
+    
+    SignalFilter (const char* szFilterName, double dFilterMinimum, double dFilterMaximum, int nFilterPoints, double dBandwidth, double dFilterParam, const char* szDomainName);
+
+    SignalFilter (const int idFilter, double dFilterMinimum, double dFilterMaximum, int nFilterPoints, double dBandwidth, double dFilterParam, const int idDomain);
+
+    SignalFilter (const char* szFilterName, const char* szDomainName, double dBandwidth, double dFilterParam);
 
     ~SignalFilter (void);
 
     double* getFilter (void) const
-      { return m_vecFilter; }
+      { return m_adFilter; }
 
-    double convolve (const double f[], const double dx, const int n, const int np, const FunctionSymmetry func_type) const;
+    bool fail(void) const      {return m_fail;}
+    const std::string& failMessage(void) const {return m_failMessage;}
 
-    double convolve (const float f[], const double dx, const int n, const int np, const FunctionSymmetry func_type) const;
+    const std::string& nameFilter(void) const  { return m_nameFilter;}
+    const std::string& nameDomain(void) const  { return m_nameDomain;}
+    const int idFilter(void) const     { return m_idFilter;}
+    const int idDomain(void) const     { return m_idDomain;}
 
-    static double spatialResponseCalc (FilterType fType, double bw, double x, double param, int n);
+    int getNFilterPoints (void) const  { return m_nFilterPoints; }
+    const double getFilterMin(void) const {return m_dFilterMin;}
+    const double getFilterMax(void) const {return m_dFilterMax;}
+    const double getFilterIncrement(void) const {return m_dFilterInc;}
+    void copyFilterData(double *pdFilter, const int iStart, const int nPoints) const;
 
-    static double spatialResponseAnalytic (FilterType fType, double bw, double x, double param);
+    double response (double x);
 
-    static double frequencyResponse (FilterType fType, double bw, double u, double param);
+    static double spatialResponse (int fType, double bw, double x, double param);
 
- private:
-    double *m_vecFilter;
-    double m_bw;
-    FilterType m_filterType;
+    static double frequencyResponse (int fType, double bw, double u, double param);
 
-    double spatialResponseCalc (double x, double param, int n) const;
+    static double spatialResponseAnalytic (int fType, double bw, double x, double param);
 
-    double spatialResponseAnalytic (double x, double param) const;
+    static double spatialResponseCalc (int fType, double bw, double x, double param, int nIntegral);
 
-    double frequencyResponse (double u, double param) const;
+    static void setNumIntegral(int nIntegral) {N_INTEGRAL = nIntegral;}
 
-    static double sinc (double x, double mult)
-      { return (fabs(x) > F_EPSILON ? (sin (x * mult) / x) : 1.0); }
+  static const int getFilterCount() {return s_iFilterCount;}
+  static const char** getFilterNameArray() {return s_aszFilterName;}
+  static const char** getFilterTitleArray() {return s_aszFilterTitle;}
+  static int convertFilterNameToID (const char* const filterName);
+  static const char* convertFilterIDToName (const int idFilter);
+  static const char* convertFilterIDToTitle (const int idFilter);
 
-    static double integral_abscos (double u, double w);
+  static const int getDomainCount() {return s_iDomainCount;}
+  static const char** getDomainNameArray() {return s_aszDomainName;}
+  static const char** getDomainTitleArray() {return s_aszDomainTitle;}
+  static int convertDomainNameToID (const char* const domainName);
+  static const char* convertDomainIDToName (const int idDomain);
+  static const char* convertDomainIDToTitle (const int idDomain);
 
+  static double sinc (double x)
+      { return (fabs(x) > F_EPSILON ? (sin (x) / x) : 1.0); }
+
+  static double sinc (double x, double mult)
+      { return (fabs(x) > F_EPSILON ? (sin (x * mult) / x) : 1.0); }
+
+ private:
+    int m_nFilterPoints;
+    double m_dBandwidth;
+    double m_dFilterParam;
+    double m_dFilterInc;
+    double m_dFilterMin;
+    double m_dFilterMax;
+    double* m_adFilter;
+
+    std::string m_nameFilter;
+    std::string m_nameDomain;
+    int m_idFilter;
+    int m_idDomain;
+
+    bool m_fail;
+    std::string m_failMessage;
+
+    static const char* s_aszFilterName[];
+    static const char* s_aszFilterTitle[];
+    static const int s_iFilterCount;
+    static const char* s_aszDomainName[];
+    static const char* s_aszDomainTitle[];
+    static const int s_iDomainCount;
+    static int N_INTEGRAL;
+
+    static const bool haveAnalyticSpatial (const int filterID);
+
+    void init (const int idFilter, double dFilterMin, double dFilterMax, int nFilterPoints, double dBandwidth, double dFilterParam, const int idDomain);
+
+    void createFrequencyFilter (double* x) const;
+    void createSpatialFilter (double* x) const;
+
+    double spatialResponseCalc (double x) const;
+    double spatialResponseAnalytic (double x) const;
+    double frequencyResponse (double u) const;
+
+    static double integral_abscos (double u, double w)
+    { return (fabs (u) > F_EPSILON ? (cos (u * w) - 1) / (u * u) + w / u * sin (u * w) : (w * w / 2)); }
 };
 
+#endif