HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RU_FilterArea.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: RU_FilterArea.h ( RU Library, C++)
7  *
8  * USAGE:
9  * 1) First, set the wrapping modes and the filter type and width.
10  * 2) Then set the texture coordinates. Internally, this will compute
11  * the floating point bounds of the input region required.
12  * 3) Next, query the filter to find out the extents of the input.
13  * Build the input data needed, then
14  * 4) Call the appropriate filter method to filter your arrays.
15  *
16  * COMMENTS:
17  * Filter's a set of "texture" coordinates of an input to the output
18  * region. Note that for straight scaling of images, there are much
19  * better ways of filtering. This is a generic filtering call which
20  * will be more expensive, but provide reasonable filtering of arbitrary
21  * regions. This does assume that there is some continuity to the
22  * texture coordinates. If the texture coordinates are random, this
23  * will still filter, but be very expensive.
24  *
25  * This code assumes that the texture coordinates are in pixel space
26  * That is the 0 to XRes-1 and 0 to YRes-1. The texture coordinates map
27  * to the center of pixels (not the edges). All of this is actually
28  * very important information.
29  *
30  * This code only works on floating point data. It's not really an
31  * RU_Algorithm, but it can be used by RU_Algorithms if required.
32  *
33  * TODO:
34  * - We should be smart and pre-process the deltas on the texture
35  * coordinates. If the minimum delta is bigger than 2, we can do a
36  * quick prefiltering (i.e. making a MIP) then use a smaller filter
37  * width.
38  */
39 
40 #ifndef __RU_FilterArea__
41 #define __RU_FilterArea__
42 
43 #include "RU_API.h"
44 #include <UT/UT_FilterType.h>
45 #include <UT/UT_VectorTypes.h>
46 
47 class UT_Filter;
48 
49 typedef enum {
55 
57 {
58 public:
59  RU_FilterArea();
60  virtual ~RU_FilterArea();
61 
62  // First, set up the filter parameters (use either setFilter func)
63  void setFilter(UT_FilterType xfilter, float xsize,
64  UT_FilterType yfilter, float ysize);
65  void setFilter(UT_Filter *xfilter, float xsize,
66  UT_Filter *yfilter, float ysize);
67  void setWrap(int xwrap, int ywrap);
68  void setBorder(float border[4]);
69 
70 
71  // Second, set the texture coordinates (using 1 of the following)
72  void setTextureCoords(const float *u, const float *v,
73  int rows, int cols,
74  int in_xres, int in_yres,
75  const char *mask = 0);
76  void setFourCornerCoords(const float *u0, const float *v0,
77  const float *u1, const float *v1,
78  int rows, int cols,
79  int in_xres, int in_yres,
80  const char *mask = 0);
81 
82  // Third, get the extents of the input region required
83  void getInputRegion(int &x0, int &x1, int &y0, int &y1);
84 
85  // Fourth, call the sample methods as many times as you like. All of the
86  // sample routines assume that the input is set to the input region
87  // specified above. The input region is inclusive (meaning there are
88  // (x1-x0+1)*(y1-y0+1) pixels.
89  void sample1(float *o, const float *i);
90 
91  void sample3(UT_Vector3 *o, const float *i0, const float *i1,
92  const float *i2);
93 
94  void sample4(UT_Vector4 *o, const float *i0, const float *i1,
95  const float *i2, const float *i3);
96 
97  // Here are some methods to query the state of the filter
98  RU_FILTER_WRAP getXWrap() { return myXWrap; }
99  RU_FILTER_WRAP getYWrap() { return myYWrap; }
100  UT_FilterType getXFilter() { return myXFilterType; }
101  UT_FilterType getYFilter() { return myYFilterType; }
102  float getXSize() { return myXSize; }
103  float getYSize() { return myYSize; }
104 
105 private:
106  // This will return 1 if the filter is valid
107  void setupWindow(float umin, float umax,
108  float vmin, float vmax,
109  int &xsize, int &ysize);
110  // Parameters.
111  UT_FilterType myXFilterType, myYFilterType;
112  UT_Filter *myXFilter, *myYFilter;
113  float myXSize, myYSize;
114  RU_FILTER_WRAP myXWrap, myYWrap;
115  float myBorder[4];
116 
117  const float *myUCoord;
118  const float *myVCoord;
119  const char *myMask;
120  int myRows, myCols;
121  int mySize;
122  float *myDU, *myDV;
123  int myMaxSize;
124 
125  // Computed data
126  float myXSupport, myYSupport; // Real filter size
127  float myMinU, myMaxU;
128  float myMinV, myMaxV;
129  int myInX0, myInX1;
130  int myInY0, myInY1;
131  int myInXRes, myInYRes;
132 
133  // Data used in filtering
134  float *myXWindow, *myYWindow;
135  int *myXPixels, *myYPixels;
136  int myXWindowSize, myYWindowSize;
137 };
138 
139 #endif
RU_FILTER_WRAP getYWrap()
Definition: RU_FilterArea.h:99
float getYSize()
const GLdouble * v
Definition: glcorearb.h:836
#define RU_API
Definition: RU_API.h:10
GLint GLuint mask
Definition: glcorearb.h:123
UT_FilterType
Definition: UT_FilterType.h:16
png_uint_32 i
Definition: png.h:2877
UT_FilterType getYFilter()
RU_FILTER_WRAP
Definition: RU_FilterArea.h:49
float getXSize()
GLfloat v0
Definition: glcorearb.h:815
GLint GLint GLsizei GLint border
Definition: glcorearb.h:107
UT_FilterType getXFilter()
GLfloat GLfloat v1
Definition: glcorearb.h:816
RU_FILTER_WRAP getXWrap()
Definition: RU_FilterArea.h:98