HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RU_PolyFill.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_PolyFill.h ( RU Library, C++)
7  *
8  * COMMENTS: Polygon rasterization. Polygons are scan converted and the
9  * anti-aliased intensity is put into the resulting plane/planes.
10  *
11  * Ortho rendering is performed on a window (0,0)-(1,1) (meaning
12  * that polgons should have their coordinates set appropriately).
13  *
14  * Rendering process:
15  * 1) Call initialize() and append() with a list of GU_Details to
16  * render. The GU_Details should be made of polygons, other
17  * primitives will be ignored.
18  * 2) Call setResolution with the appropriate sizes
19  * 3) Call doSorting()
20  *
21  * Then, for each tile, simply call scanConvert(). This function is
22  * thread safe.
23  */
24 
25 #ifndef __RU_PolyFill__
26 #define __RU_PolyFill__
27 
28 #include "RU_API.h"
29 #include <UT/UT_Endian.h>
30 #include <UT/UT_Lock.h>
31 #include <UT/UT_ValArray.h>
32 #include <UT/UT_Vector4.h>
33 
34 #include <TIL/TIL_Tile.h>
35 
36 #include <TIL/TIL_Pixel.h>
37 
38 #include "RU_Feather.h" // for RU_FeatherDropoff
39 
41 {
44 };
45 
46 class GEO_Detail;
47 
48 class ru_Triangle;
49 class ru_Bucket;
50 
51 class ru_FeatherTriangle;
53 class UT_Ramp;
54 
56 {
57 public:
59  int num_threads = 1);
60 
61  ~RU_PolyFill();
62 
63  void clearGeometry();
64  void initialize(const GEO_Detail *gdp);
65  void append(const GEO_Detail *gdp);
66  void initializeFeather(const GEO_Detail *gdp);
67  void addTriangle(float x0, float y0,
68  float x1, float y1,
69  float x2, float y2);
70  void addFeatherTriangle(float x0, float y0,
71  float x1, float y1,
72  float x2, float y2,
73  int quad_index);
74 
75  // Set the resolution, where the image size is (imagex x imagey),
76  // and the size of a tile is (tilex x tiley).
77  void setResolution(int imagex, int imagey,
78  int tilex, int tiley,
79  float tolx = 0.001F);
80  void doSorting();
81 
82  // Set super-sampling (8x8 by default). Normal mode only.
83  void setSampling(int xs, int ys);
84 
85  // set the dropoff function. Feather mode only (0 @edge, 1 = size pix away)
86  void setDropoff(int size,float (*dropfunc)(float));
88  { myFeatherDropoff = dropoff; }
89  void setDropoffRamp(UT_Ramp &ramp);
90 
91  // The tx, ty parameters refer to the tile to render.
92  void scanConvert(TIL_TileList *tilelist,
93  int tx, int ty,
94  const UT_Vector4 &color,
95  int thread_index);
96 
97 private:
98  void scanConvertNormal(TIL_TileList *tilelist,
99  int tx, int ty,
100  const UT_Vector4 &color,
101  int thread_index);
102  void scanConvertFeather(TIL_TileList *tilelist,
103  int tx, int ty,
104  const UT_Vector4 &color,
105  int thread_index);
106 
107 
108  // The coordinates are relative to the tile origin
109  void (RU_PolyFill::*myWritePixel)(void *data, int x, int y,
110  int stride, float coverage,
111  int thread);
112 
113  void writePixel8(void *data, int x, int y,int stride, float coverage,
114  int thread);
115  void writePixel8F(void *data, int x, int y,int stride, float coverage,
116  int thread);
117  void writePixel16(void *data, int x, int y,int stride, float coverage,
118  int thread);
119  void writePixel16F(void *data, int x, int y,int stride, float coverage,
120  int thread);
121  void writePixel32(void *data, int x, int y,int stride, float coverage,
122  int thread);
123  void writePixel32F(void *data, int x, int y,int stride, float coverage,
124  int thread);
125  void writePixelFloat16(void *data, int x, int y,int stride, float coverage,
126  int thread);
127  void writePixelFloat(void *data, int x, int y,int stride, float coverage,
128  int thread);
129 
130  void clearAndDestroy();
131 
132  // Common data
133  RU_PolyFillMethod myFillMethod;
134  int myNumThreads;
135  ru_Triangle *myTriangles;
136  ru_Bucket *myBuckets;
137  ru_FeatherTriangle *myFeatherTriangles;
138  ru_Bucket *myFeatherBuckets;
139  int myBucketCount;
140  float *myPLeft, *myPBottom;
141  float myXInc, myYInc;
142  float myXTol;
143  int myImageX, myImageY;
144  int myXres, myYres; // In Buckets
145  int myTileX, myTileY; // Tile sizes
146 
147  // Normal method data
148  int mySampleSize;
149  float *mySamples;
150  uint64 myFullMask;
151  uint64 **myMaskBuffer;
152  float myFullCount;
153  UT_Lock mySampleLock;
154 
155  // Feather method data
156  float **myFillBuffer;
157  UT_BilinearSampleQuad2D *myFeatherQuads;
158  int myFeatherSize;
159  RU_FeatherDropoff myFeatherDropoff;
160 
161  // Fill data
162  int myFastConvert;
163  TIL_DataFormat myFormat;
164  TIL_Pixel<unsigned char,0> *mySlow8;
165  TIL_Pixel<unsigned char,1> *myFast8;
166  TIL_Pixel<unsigned short,0> *mySlow16;
167  TIL_Pixel<unsigned short,1> *myFast16;
168  TIL_Pixel<unsigned int,0> *mySlow32;
169  TIL_Pixel<unsigned int,1> *myFast32;
170 
171 public: // for callback func only
173 };
174 
175 #endif
void
Definition: png.h:1083
GLboolean * data
Definition: glcorearb.h:131
#define RU_API
Definition: RU_API.h:10
GLint y
Definition: glcorearb.h:103
unsigned long long uint64
Definition: SYS_Types.h:117
GLdouble GLdouble x2
Definition: glad.h:2349
RU_FeatherDropoff
Definition: RU_Feather.h:27
#define TIL_DataFormat
Definition: TIL_Defines.h:65
RU_PolyFillMethod
Definition: RU_PolyFill.h:40
GLint GLenum GLboolean GLsizei stride
Definition: glcorearb.h:872
GLdouble y1
Definition: glad.h:2349
OPENVDB_API void initialize()
Global registration of native Grid, Transform, Metadata and Point attribute types. Also initializes blosc (if enabled).
Definition: logging.h:294
GLint GLenum GLint x
Definition: glcorearb.h:409
GLsizeiptr size
Definition: glcorearb.h:664
**Note that the tasks the is the thread number *for the or if it s being executed by a non pool thread(this *can happen in cases where the whole pool is occupied and the calling *thread contributes to running the work load).**Thread pool.Have fun
GLuint color
Definition: glcorearb.h:1261
Utility class for containing a color ramp.
Definition: UT_Ramp.h:92
void setDropoff(RU_FeatherDropoff dropoff)
Definition: RU_PolyFill.h:87
GLdouble GLdouble GLdouble y2
Definition: glad.h:2349
Definition: format.h:895
UT_FloatArray myFeatherLUT
Definition: RU_PolyFill.h:172