+/*****************************************************************************
+** 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.20 2000/08/19 22:59:06 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
+
+#include <complex>
+
+
+// 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; }
+
+ 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 int idFilter(void) const { return m_idFilter;}
+ const int idDomain(void) const { return m_idDomain;}
+
+ 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;
+
+ double response (double x);
+
+ static double spatialResponse (int fType, double bw, double x, double param);
- double convolve (const double f[], const double dx, const int n, const int np, const FunctionSymmetry func_type) const;
+ static double frequencyResponse (int fType, double bw, double u, double param);
- double convolve (const float f[], const double dx, const int n, const int np, const FunctionSymmetry func_type) const;
+ static double spatialResponseAnalytic (int fType, double bw, double x, double param);
- static double spatialResponseCalc (FilterType fType, double bw, double x, double param, int n);
+ static double spatialResponseCalc (int fType, double bw, double x, double param, int nIntegral);
- static double spatialResponseAnalytic (FilterType fType, double bw, double x, double param);
+ static void setNumIntegral(int nIntegral) {N_INTEGRAL = nIntegral;}
- static double frequencyResponse (FilterType fType, double bw, double u, double param);
+ 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 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);
private:
- double *m_vecFilter;
- double m_bw;
- FilterType m_filterType;
+ int m_nFilterPoints;
+ double m_dBandwidth;
+ double m_dFilterParam;
+ double m_dFilterInc;
+ double m_dFilterMin;
+ double m_dFilterMax;
+ double* m_adFilter;
- double spatialResponseCalc (double x, double param, int n) const;
+ string m_nameFilter;
+ string m_nameDomain;
+ int m_idFilter;
+ int m_idDomain;
- double spatialResponseAnalytic (double x, double param) const;
+ bool m_fail;
+ string m_failMessage;
- double frequencyResponse (double u, double param) const;
+ 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 double sinc (double x, double mult)
- { return (fabs(x) > F_EPSILON ? (sin (x * mult) / x) : 1.0); }
+ 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);
- static double integral_abscos (double u, double w);
+ 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 sinc (double x, double mult)
+ { return (fabs(x) > F_EPSILON ? (sin (x * mult) / x) : 1.0); }
+ 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