00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef __UT_Filter__
00026 #define __UT_Filter__
00027
00028 #include "UT_API.h"
00029 #include <SYS/SYS_Types.h>
00030 #include "UT_FilterType.h"
00031
00032 class UT_Filter;
00033
00034
00035 class UT_API UT_FilterWindow {
00036 public:
00037 UT_FilterWindow();
00038 ~UT_FilterWindow();
00039
00040 void setWeights(const UT_Filter &filter,
00041 fpreal center, fpreal radius,
00042 int res, UT_FilterWrap mode)
00043 {
00044 fpreal iradius = 0.5F / radius;
00045 setWeights(filter, center, radius, iradius, res, mode);
00046 }
00047 void setWeights(const UT_Filter &filter, fpreal center,
00048 fpreal radius, fpreal iradius,
00049 int res, UT_FilterWrap mode);
00050
00051
00052
00053
00054 void initWeights(fpreal center, fpreal radius);
00055
00056
00057
00058
00059 void fillWeights(fpreal *weights, const UT_Filter &filter,
00060 fpreal center, fpreal iradius,
00061 int res, UT_FilterWrap mode);
00062
00063 void allocWeights(int size);
00064 float *getWeights() { return myWeights; }
00065 const float *getWeights() const { return myWeights; }
00066 int getStart() const { return myStart; }
00067 int getEnd() const { return myEnd; }
00068 int getSize() const { return mySize; }
00069 float getVisible() const { return myVisible; }
00070
00071 void trim(int min, int max);
00072
00073 private:
00074 float *myWeights;
00075 int myStart, myEnd, mySize, myAlloc;
00076 float myVisible;
00077 };
00078
00079
00080 class UT_API UT_Filter {
00081 public:
00082
00083 static UT_FilterType lookupFilter(const char *name);
00084 static const char *getFilterName(UT_FilterType type);
00085 static const char *getFilterLabel(UT_FilterType type);
00086
00087
00088 static UT_Filter *getFilter(UT_FilterType type);
00089
00090
00091 static UT_Filter *getFilter(float (*evalfunc)(float, void *),
00092 int size, int support = 2,
00093 void *data = 0);
00094
00095 static void releaseFilter(UT_Filter *filter);
00096 void access() { myRefCount++; }
00097
00098 UT_FilterType getType() const;
00099
00100
00101
00102
00103 virtual fpreal getWeight(fpreal l, fpreal r) const = 0;
00104
00105
00106
00107 virtual fpreal getFastWeight(fpreal l, fpreal r) const = 0;
00108
00109
00110 virtual fpreal getFastArea(fpreal l) const = 0;
00111
00112
00113
00114 fpreal getAreaWeight(fpreal l, fpreal r, fpreal b, fpreal t) const
00115 {
00116 return getWeight(l, r) * getWeight(b, t);
00117 }
00118 fpreal getFastAreaWeight(fpreal l, fpreal r,
00119 fpreal b, fpreal t) const
00120 {
00121 return getFastWeight(l, r) * getFastWeight(b, t);
00122 }
00123
00124
00125 fpreal getSupport() const { return mySupport; }
00126
00127 public:
00128 virtual ~UT_Filter();
00129
00130 protected:
00131 UT_Filter() { myRefCount = 0; }
00132
00133 int myRefCount;
00134 float mySupport;
00135 };
00136
00137 #endif