Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef __CS_CSRECTREGION_H__
00020 #define __CS_CSRECTREGION_H__
00021
00029 #include "csextern.h"
00030
00031 #include "csgeom/csrect.h"
00032 #include "csutil/array.h"
00033
00034 #ifdef CS_DEBUG
00035
00036
00037 #endif
00038
00039 #ifdef CS_DEBUG_RECT_REG
00040 class csRandomGen;
00041 #endif
00042
00055 class CS_CRYSTALSPACE_EXPORT csRectRegion
00056 {
00057 protected:
00058 static const size_t FRAGMENT_BUFFER_SIZE=64;
00059
00061 csArray<csRect> region;
00063 csRect fragment[FRAGMENT_BUFFER_SIZE];
00065 size_t gather_mark;
00066
00071 void fragmentRect(csRect&, csRect&, int mode);
00072 void nkSplit(csRect& r1, csRect& r2);
00074 void fragmentContainedRect(csRect &r1, csRect &r2);
00076 void markForGather();
00078 void gatherFragments();
00079
00080 public:
00082 csRectRegion();
00084 ~csRectRegion();
00085
00090 void Include(const csRect &rect);
00092 void Exclude(const csRect &rect);
00094 void ClipTo(csRect &clip);
00095
00097 inline size_t Count() const { return region.GetSize(); }
00099 inline const csRect& RectAt(size_t i) const { return region[i]; }
00101 void MakeEmpty();
00102 };
00103
00104
00105
00106 #ifdef CS_DEBUG_RECT_REG
00107
00108
00109
00110
00111
00112
00113 #define CS_RECT_REG_SIZE 100
00114
00115 class CS_CRYSTALSPACE_EXPORT csRectRegionDebug
00116 {
00117 private:
00118 bool area[CS_RECT_REG_SIZE][CS_RECT_REG_SIZE];
00119 csRandomGen* rand;
00120
00121
00122
00123 unsigned int rand_seed;
00124 int num_tests_complete;
00125
00126 public:
00127 csRectRegionDebug();
00128 ~csRectRegionDebug();
00129
00134 void Include(const csRect &rect);
00135
00137 void Exclude(const csRect &rect);
00138
00140 void ClipTo(const csRect &clip);
00141
00143 void MakeEmpty();
00144
00149 void AssertEqual(const csRectRegion &r);
00150
00152 bool CheckBounds(const csRect &clip);
00153
00155 void UnitTest();
00156
00158 csRect RandRect();
00159
00161 csRect RandNonEmptyRect();
00162 };
00163
00164 #endif // CS_DEBUG
00165
00169 #endif // __CS_CSRECTREGION_H__