HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
BRAY_SampleFilter.h
Go to the documentation of this file.
1 
2 /*
3  * PROPRIETARY INFORMATION. This software is proprietary to
4  * Side Effects Software Inc., and is not to be reproduced,
5  * transmitted, or disclosed in any way without written permission.
6  *
7  * NAME: BRAY_SampleFilter.h (RAY Library, C++)
8  *
9  * COMMENTS:
10  */
11 
12 #ifndef __BRAY_SampleFilter__
13 #define __BRAY_SampleFilter__
14 
15 #include "BRAY_API.h"
16 #include "BRAY_FilterBase.h"
17 #include <UT/UT_Vector4.h>
18 
19 class UT_Options;
20 class PXL_Raster;
21 
22 extern "C" {
23  SYS_VISIBILITY_EXPORT extern void newBRAYSampleFilter(void *);
24 }
25 
26 /// Sample filters take raw samples as generated by the renderer and can adjust
27 /// the sample data values prior to sending it to pixel filtering.
29  : public BRAY_FilterBase
30 {
31 public:
33  {
34  public:
35  virtual ~Factory();
36 
37  /// Create an instance of the BRAY_SampleFilter
38  virtual UT_UniquePtr<BRAY_SampleFilter> instance(const UT_Options *o) const = 0;
39  };
41 
42  /// @{
43  /// Access to factory
44  static void listFactories(UT_StringArray &result);
45 
46  static void registerPlugin(const UT_StringHolder &name, FactoryPtr factory);
47 
48  static UT_UniquePtr<BRAY_SampleFilter> instancePlugin(
49  const UT_StringRef &style,
50  const UT_Options *options=nullptr);
51  static void releasePlugin(UT_UniquePtr<BRAY_SampleFilter> p);
52  static void freePluginCache();
53  /// @}
54 
55  // c-tor
57  : BRAY_FilterBase(o)
58  {
59  }
60 
61  // d-tor
62  virtual ~BRAY_SampleFilter();
63 
64  /// Sample data for processing
66  {
67  public:
69  : mySize(0)
70  {}
71  SampleData(float **data, // Sample data for each AOV
72  const int *sizes, // Size of each AOV
73  const UT_Vector4 *ndc,
74  int nplanes) // Total number of AOVs
75  : myData(data)
76  , mySizes(sizes)
77  , myNDC(ndc)
78  , mySize(nplanes)
79  {
80  }
81 
82  inline void init(float **data,
83  const int *sizes,
84  const UT_Vector4 *ndc,
85  int nplanes)
86  {
87  myData = data;
88  mySizes = sizes;
89  myNDC = ndc;
90  mySize = nplanes;
91  }
92  /// Number of image planes
93  inline int size() const { return mySize; }
94 
95  /// @{
96  /// Sample data for the given AOV
97  inline float *data(int aov) { return myData[aov]; }
98  inline const float *data(int aov) const { return myData[aov]; }
99  /// @}
100 
101  /// @{
102  /// Sample data for a sample in the given AOV
103  inline float *data(int aov, int sidx)
104  {
105  return myData[aov] + sidx * mySizes[aov];
106  }
107  inline const float *data(int aov, int sidx) const
108  {
109  return myData[aov] + sidx * mySizes[aov];
110  }
111  /// @}
112 
113  /// Get the pixel location for a given sample
114  inline void pixel(int sidx, int &px, int &py)
115  {
116  px = int(myNDC[sidx].x());
117  py = int(myNDC[sidx].y());
118  }
119  /// Get the pixel jitter offset a given sample (offset inside pixel)
120  inline void jitter(int sidx, float &jx, float &jy)
121  {
122  jx = myNDC[sidx].z();
123  jy = myNDC[sidx].w();
124  }
125 
126  /// The tuple size of the AOV
127  inline int size(int p) const { return mySizes[p]; }
128  private:
129  float **myData;
130  const UT_Vector4 *myNDC;
131  const int *mySizes;
132  int mySize;
133  };
134 
135  /// @{
136  /// Methods to be implemented from base class
140  /// @}
141 
142  /// Process the sample data. Each AOV plane of the @c data will point to a
143  /// contiguous array of sample data which contains at least @c npixels of
144  /// data. The filter should be applied to each pixel in the sample data.
145  virtual void filter(SampleData &data, size_t npixels) const = 0;
146 };
147 
149 
150 #endif
int size(int p) const
The tuple size of the AOV.
GLuint const GLchar * name
Definition: glew.h:1814
SYS_VISIBILITY_EXPORT void newBRAYSampleFilter(void *)
#define SYS_VISIBILITY_EXPORT
int size() const
Number of image planes.
void jitter(int sidx, float &jx, float &jy)
Get the pixel jitter offset a given sample (offset inside pixel)
Base class for image filters. These are any filters which process AOV data.
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glew.h:2981
Sample data for processing.
BRAY_SampleFilter(const UT_Options *o)
GLint GLint GLint GLint GLint x
Definition: glew.h:1252
GLint GLint GLint GLint GLint GLint y
Definition: glew.h:1252
GLuint GLsizei const GLuint const GLintptr const GLsizeiptr * sizes
Definition: glew.h:5268
GLint GLenum GLsizei GLint GLsizei const void * data
Definition: glew.h:1379
typedef int(WINAPI *PFNWGLRELEASEPBUFFERDCARBPROC)(HPBUFFERARB hPbuffer
void init(float **data, const int *sizes, const UT_Vector4 *ndc, int nplanes)
virtual const UT_StringHolder & errorMessage() const
const float * data(int aov) const
IFDmantra py
Definition: HDK_Image.dox:266
GLfloat GLfloat p
Definition: glew.h:16321
A map of string to various well defined value types.
Definition: UT_Options.h:42
virtual const char * className() const =0
Return an identifier for this plugin.
const float * data(int aov, int sidx) const
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:47
#define BRAY_API
Definition: BRAY_API.h:12
virtual bool getAOVs(BRAY_FilterInit &init, const UT_StringArray &available, UT_StringArray &write, UT_StringArray &read)=0
GLuint64EXT * result
Definition: glew.h:14007
SampleData(float **data, const int *sizes, const UT_Vector4 *ndc, int nplanes)
void pixel(int sidx, int &px, int &py)
Get the pixel location for a given sample.
float * data(int aov, int sidx)