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
00026
00027
00028
00029
00030 #ifndef __UT_PolyRaster__
00031 #define __UT_PolyRaster__
00032
00033 #include "UT_API.h"
00034 #include "UT_Math.h"
00035
00036 class UT_Vector3;
00037 class UT_prEdge;
00038 class UT_Filter;
00039 class UT_FilterSampleTable;
00040
00041 class UT_API UT_PolyRaster {
00042 public:
00043 UT_PolyRaster();
00044 virtual ~UT_PolyRaster();
00045
00046 #if 0
00047 void setSampleTable(UT_FilterSampleTable *table)
00048 {
00049 mySampleTable = table;
00050 }
00051 #endif
00052 void setFilterWidth(fpreal x=1, fpreal y=1)
00053 {
00054 myXSFilter = x * 0.5F;
00055 myYSFilter = y * 0.5F;
00056 }
00057 void setWindow(fpreal xl, fpreal xr, fpreal yb, fpreal yt)
00058 {
00059 myXMin = xl; myXMax = xr;
00060 myYMin = yb; myYMax = yt;
00061 }
00062 void setResolution(int xsamp, int ysamp)
00063 {
00064 myXres = xsamp;
00065 myYres = ysamp;
00066 }
00067
00068
00069 void initialize();
00070
00071
00072
00073 virtual void sample(int x, int y, fpreal weight);
00074
00075
00076
00077
00078 void rasterize(const float v0[2], const float v1[2],
00079 const float v2[2], int cliptowindow = 1);
00080
00081 protected:
00082 float myXFilter, myYFilter;
00083 float myIXFilter, myIYFilter;
00084 float myXSFilter, myYSFilter;
00085 float myXMin, myXMax, myYMin, myYMax;
00086 int myXres, myYres;
00087
00088 private:
00089 void rasterize(UT_prEdge *head, int clipx) const;
00090 fpreal filterWeight(const float v0[2], const float v1[2],
00091 const float v2[2]) const;
00092
00093
00094 int clipOneEdge(fpreal xl, fpreal xr, fpreal yb, fpreal yt,
00095 float vtx[][2],
00096 const UT_prEdge &edge) const;
00097 int genericClip(const float vtx[][2], int nvtx,
00098 float result[][2],
00099 const UT_prEdge &e0) const;
00100 fpreal genericWeight(float vtx[][2],
00101 int nvtx) const
00102 {
00103 if (nvtx < 3) return nvtx == -1;
00104 return computeWeight(vtx, nvtx);
00105 }
00106 int toScreenX(fpreal sx) const
00107 { return (int)((sx-myXMin)*myIXSinc); }
00108 int floorScreenX(fpreal sx) const
00109 { return (int)SYSfloor((sx-myXMin)*myIXSinc); }
00110 int ceilScreenX(fpreal sx) const
00111 { return (int)SYSceil((sx-myXMin)*myIXSinc); }
00112
00113 fpreal computeWeight(float vtx[][2], int nvtx) const;
00114
00115
00116 fpreal clipOneEdge(fpreal xl, fpreal xr, fpreal yb, fpreal yt,
00117 const UT_prEdge &edge) const;
00118 float myXSinc, myIXSinc;
00119 float myYSinc, myIYSinc;
00120 float myBoxWeight;
00121 #if 0
00122 UT_FilterSample *mySampleTable;
00123 #endif
00124 };
00125
00126 #endif