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 
21 extern "C" {
22  SYS_VISIBILITY_EXPORT extern void newBRAYSampleFilter(void *);
23 }
24 
25 /// Sample filters take raw samples as generated by the renderer and can adjust
26 /// the sample data values prior to sending it to pixel filtering.
28  : public BRAY_FilterBase
29 {
30 public:
32  {
33  public:
34  virtual ~Factory();
35 
36  /// Create an instance of the BRAY_SampleFilter
37  virtual UT_UniquePtr<BRAY_SampleFilter> instance(const UT_Options *o) const = 0;
38  };
40 
41  /// @{
42  /// Access to factory
43  static void listFactories(UT_StringArray &result);
44 
45  static void registerPlugin(const UT_StringHolder &name, FactoryPtr factory);
46 
47  static UT_UniquePtr<BRAY_SampleFilter> instancePlugin(
48  const UT_StringRef &style,
49  const UT_Options *options=nullptr);
50  static void releasePlugin(UT_UniquePtr<BRAY_SampleFilter> p);
51  static void freePluginCache();
52  /// @}
53 
54  // c-tor
56  : BRAY_FilterBase(o)
57  {
58  }
59 
60  // d-tor
61  ~BRAY_SampleFilter() override;
62 
63  /// Sample data for processing
65  {
66  public:
68  : mySize(0)
69  {}
70  SampleData(float **data, // Sample data for each AOV
71  const int *sizes, // Size of each AOV
72  const UT_Vector4 *ndc,
73  int nplanes) // Total number of AOVs
74  : myData(data)
75  , mySizes(sizes)
76  , myNDC(ndc)
77  , mySize(nplanes)
78  {
79  }
80 
81  inline void init(float **data,
82  const int *sizes,
83  const UT_Vector4 *ndc,
84  int nplanes)
85  {
86  myData = data;
87  mySizes = sizes;
88  myNDC = ndc;
89  mySize = nplanes;
90  }
91  /// Number of image planes
92  inline int size() const { return mySize; }
93 
94  /// @{
95  /// Sample data for the given AOV
96  inline float *data(int aov) { return myData[aov]; }
97  inline const float *data(int aov) const { return myData[aov]; }
98  /// @}
99 
100  /// @{
101  /// Sample data for a sample in the given AOV
102  inline float *data(int aov, int sidx)
103  {
104  return myData[aov] + sidx * mySizes[aov];
105  }
106  inline const float *data(int aov, int sidx) const
107  {
108  return myData[aov] + sidx * mySizes[aov];
109  }
110  /// @}
111 
112  /// Get the pixel location for a given sample
113  inline void pixel(int sidx, int &px, int &py)
114  {
115  px = int(myNDC[sidx].x());
116  py = int(myNDC[sidx].y());
117  }
118  /// Get the pixel jitter offset a given sample (offset inside pixel)
119  /// Note that the jitter may be outside the range (0, 1) depending on
120  /// the FIS applied.
121  inline void jitter(int sidx, float &jx, float &jy)
122  {
123  jx = myNDC[sidx].z();
124  jy = myNDC[sidx].w();
125  }
126 
127  /// The tuple size of the AOV
128  inline int size(int p) const { return mySizes[p]; }
129  private:
130  float **myData;
131  const UT_Vector4 *myNDC;
132  const int *mySizes;
133  int mySize;
134  };
135 
136  /// @{
137  /// Methods to be implemented from base class
141  /// @}
142 
143  /// Process the sample data. Each AOV plane of the @c data will point to a
144  /// contiguous array of sample data which contains at least @c npixels of
145  /// data. The filter should be applied to each pixel in the sample data.
146  virtual void filter(SampleData &data, size_t npixels) const = 0;
147 };
148 
150 
151 #endif
GLuint GLsizei const GLuint const GLintptr const GLsizeiptr * sizes
Definition: glcorearb.h:2621
int size(int p) const
The tuple size of the AOV.
typedef int(APIENTRYP RE_PFNGLXSWAPINTERVALSGIPROC)(int)
SYS_VISIBILITY_EXPORT void newBRAYSampleFilter(void *)
#define SYS_VISIBILITY_EXPORT
GLboolean * data
Definition: glcorearb.h:131
UT_UniquePtr< BRAY_SampleFilter > BRAY_SampleFilterPtr
GLint y
Definition: glcorearb.h:103
**But if you need a result
Definition: thread.h:613
int size() const
Number of image planes.
void jitter(int sidx, float &jx, float &jy)
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:39
Base class for image filters. These are any filters which process AOV data.
Sample data for processing.
BRAY_SampleFilter(const UT_Options *o)
GLuint const GLchar * name
Definition: glcorearb.h:786
void init(float **data, const int *sizes, const UT_Vector4 *ndc, int nplanes)
GLint GLenum GLint x
Definition: glcorearb.h:409
UT_UniquePtr< Factory > FactoryPtr
virtual const UT_StringHolder & errorMessage() const
const float * data(int aov) const
IFDmantra py
Definition: HDK_Image.dox:266
A map of string to various well defined value types.
Definition: UT_Options.h:84
virtual const char * className() const =0
Return an identifier for this plugin.
const float * data(int aov, int sidx) const
#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
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)
Definition: format.h:895
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glcorearb.h:1297