38 class UT_InclusiveRectImpl;
 
   39 class UT_ExclusiveRectImpl;
 
   41 template <
typename T> 
class UT_Rect;
 
  137                                     { _r.set(v1, v2, v3, v4); }
 
  139                                     { _r.set(v[0], v[1], v[2], v[3]); }
 
  167                                     { px -= 
x1(); py -= 
y1(); }
 
  171                                     { px += 
x1(); py += 
y1(); }
 
  175     void flipX(
int awidth)          { _r.flipX( awidth ); }
 
  176     void flipY(
int aheight)         { _r.flipY( aheight ); }
 
  202     void inset(
int dx, 
int dy);
 
  205     void inset(
int dx1, 
int dy1, 
int dx2, 
int dy2);
 
  226     int x()
 const               { 
return _r.x(); }
 
  227     int y()
 const               { 
return _r.y(); }
 
  228     int x1()
 const              { 
return _r.x1(); }
 
  229     int y1()
 const              { 
return _r.y1(); }
 
  234     void setX(
int x_)           { _r.setX(x_); }
 
  235     void setY(
int y_)           { _r.setY(y_); }
 
  240     void setX1(
int x_)          { _r.setX1(x_); }
 
  241     void setY1(
int y_)          { _r.setY1(y_); }
 
  246     int w()
 const               { 
return _r.width(); }
 
  247     int h()
 const               { 
return _r.height(); }
 
  248     int width()
 const           { 
return _r.width(); }
 
  249     int height()
 const          { 
return _r.height(); }
 
  260     int x2()
 const              { 
return _r.x2(); }
 
  261     int y2()
 const              { 
return _r.y2(); }
 
  265     void setX2(
int x_)          { _r.setX2(x_); }
 
  266     void setY2(
int y_)          { _r.setY2(y_); }
 
  270     int x2e()
 const             { 
return _r.x2e(); }
 
  271     int y2e()
 const             { 
return _r.y2e(); }
 
  281     int centerX()
 const         { 
return (_r.x1() + _r.x2()) / 2; }
 
  282     int centerY()
 const         { 
return (_r.y1() + _r.y2()) / 2; }
 
  292     void getDim(
int &x_, 
int &y_, 
int &w_, 
int &h_)
 const 
  294     void getIncl(
int &x1_, 
int &y1_, 
int &x2_, 
int &y2_)
 const 
  295                 { x1_ = 
x(); y1_ = 
y(); x2_ = 
x2(); y2_ = 
y2(); }
 
  296     void getExcl(
int &x1_, 
int &y1_, 
int &x2_, 
int &y2_)
 const 
  297                 { x1_ = 
x(); y1_ = 
y(); x2_ = 
x2e(); y2_ = 
y2e(); }
 
  305     void setDim(
int x_, 
int y_, 
int w_, 
int h_)
 
  308                 { 
setDim(v[0], v[1], v[2], v[3]); }
 
  309     void setIncl(
int x1_, 
int y1_, 
int x2_, 
int y2_)
 
  312                 { 
setIncl(v[0], v[1], v[2], v[3]); }
 
  313     void setExcl(
int x1_, 
int y1_, 
int x2_, 
int y2_)
 
  316                 { 
setExcl(v[0], v[1], v[2], v[3]); }
 
  323     const int *
data()
 const     { 
return _r.data(); }
 
  324     int *
data()                 { 
return _r.data(); }
 
  330         SYShashCombine(h, 
y());
 
  331         SYShashCombine(h, 
width());
 
  332         SYShashCombine(h, 
height());
 
  338         int64 mem = inclusive ? 
sizeof(*this) : 0;
 
  339         mem += _r.getMemoryUsage(
false);
 
  344     void dump(
const char *msg=
"") 
const;
 
  356 class UT_BaseRectImpl
 
  359     UT_BaseRectImpl() { }
 
  360     UT_BaseRectImpl( 
int v0, 
int v1, 
int v2, 
int v3 )
 
  361         { 
set( v0, v1, v2, v3 ); }
 
  362     UT_BaseRectImpl( 
const UT_BaseRectImpl &
r )
 
  363         { 
set( r.myVals[0], r.myVals[1], r.myVals[2], r.myVals[3] ); }
 
  365     UT_BaseRectImpl &
operator=( 
const UT_BaseRectImpl &
r )
 
  368             set( r.myVals[0], r.myVals[1], r.myVals[2], r.myVals[3] );
 
  377         { myVals[0] = 
v0; myVals[1] = 
v1; myVals[2] = 
v2; myVals[3] = 
v3; }
 
  379     int &operator()(
int i)              { 
return myVals[i]; }
 
  380     int operator()(
int i)
 const         { 
return myVals[i]; }
 
  382     const int * 
data()
 const            { 
return myVals; }
 
  383     int *       
data()                  { 
return myVals; }
 
  385     int64 getMemoryUsage(
bool inclusive)
 const 
  386     { 
return inclusive ? 
sizeof(*this) : 0; }
 
  390     int I2D( 
int v1, 
int v2 )
 const     { 
return v2 - v1 + 1; }
 
  391     int D2I( 
int v, 
int d )
 const       { 
return v + d - 1; }
 
  392     int E2D( 
int v1, 
int v2 )
 const     { 
return v2 - 
v1; }
 
  393     int D2E( 
int v, 
int d )
 const       { 
return v + d; }
 
  394     int E2I( 
int v2 )
 const             { 
return v2 - 1; }
 
  395     int I2E( 
int v2 )
 const             { 
return v2 + 1; }
 
  404 class UT_DimRectImpl : 
public UT_BaseRectImpl
 
  417     void clear()            { 
set( 0, 0, 0, 0 ); }
 
  428             setWidth(-
width() + 2); 
 
  438     void flipX(
int w)       { myVals[0] = flipI(
x2(), w); }
 
  439     void flipY(
int h)       { myVals[1] = flipI(
y2(), h); }
 
  442     int x()
 const           { 
return myVals[0]; }
 
  443     int y()
 const           { 
return myVals[1]; }
 
  444     int width()
 const       { 
return myVals[2]; }
 
  445     int height()
 const      { 
return myVals[3]; }
 
  447     int x1()
 const          { 
return x(); }
 
  448     int y1()
 const          { 
return y(); }
 
  449     int x2()
 const          { 
return D2I(
x(), 
width()); }
 
  450     int y2()
 const          { 
return D2I(
y(), 
height()); }
 
  451     int x2e()
 const         { 
return I2E(
x2()); }
 
  452     int y2e()
 const         { 
return I2E(
y2()); }
 
  454     void setWidth(
int w)        { myVals[2] = 
w; }
 
  455     void setHeight(
int h)       { myVals[3] = 
h; }
 
  457     void setX(
int x_)           { myVals[0] = x_; }
 
  458     void setY(
int y_)           { myVals[1] = y_; }
 
  459     void setX1(
int x_)          { myVals[2] += myVals[0]-x_; myVals[0] = x_; }
 
  460     void setY1(
int y_)          { myVals[3] += myVals[1]-y_; myVals[1] = y_; }
 
  461     void setX2(
int x_)          { myVals[2] = I2D(myVals[0], x_); }
 
  462     void setY2(
int y_)          { myVals[3] = I2D(myVals[1], y_); }
 
  463     void setX2e(
int x_)         { myVals[2] = E2D(myVals[0], x_); }
 
  464     void setY2e(
int y_)         { myVals[3] = E2D(myVals[1], y_); }
 
  468 class UT_InclusiveRectImpl : 
public UT_BaseRectImpl
 
  471     UT_InclusiveRectImpl()  { }
 
  481     void clear()            { 
set( 0, 0, -1, -1 ); }
 
  484     bool isValid()
 const    { 
return (x1() <= x2e()) && (
y1() <= y2e()); }
 
  489         if (myVals[0] > myVals[2])
 
  490             UTswap(myVals[2], myVals[0]);
 
  491         if (myVals[1] > myVals[3])
 
  492             UTswap(myVals[1], myVals[3]);
 
  498         myVals[0] = flipI(x1(), w);
 
  499         myVals[2] = flipI(
x2(), w);
 
  500         UTswap(myVals[0], myVals[2]);
 
  504         myVals[1] = flipI(
y1(), h);
 
  505         myVals[3] = flipI(
y2(), h);
 
  506         UTswap(myVals[1], myVals[3]);
 
  510     int x1()
 const          { 
return myVals[0]; }
 
  511     int y1()
 const          { 
return myVals[1]; }
 
  512     int x2()
 const          { 
return myVals[2]; }
 
  513     int y2()
 const          { 
return myVals[3]; }
 
  514     int x2e()
 const         { 
return I2E(
x2()); }
 
  515     int y2e()
 const         { 
return I2E(
y2()); }
 
  517     int x()
 const           { 
return x1(); }
 
  518     int y()
 const           { 
return y1(); }
 
  519     int width()
 const       { 
return I2D(x1(), 
x2()); }
 
  520     int height()
 const      { 
return I2D(
y1(), 
y2()); }
 
  522     void setWidth(
int w)        { myVals[2] = D2I(myVals[0], w); }
 
  523     void setHeight(
int h)       { myVals[3] = D2I(myVals[1], h); }
 
  525     void setX(
int x_)           { myVals[2] = x_ + 
width()-1; myVals[0] = x_; }
 
  526     void setY(
int y_)           { myVals[3] = y_ +
height()-1; myVals[1] = y_; }
 
  527     void setX1(
int x_)          { myVals[0] = x_; }
 
  528     void setY1(
int y_)          { myVals[1] = y_; }
 
  529     void setX2(
int x_)          { myVals[2] = x_; }
 
  530     void setY2(
int y_)          { myVals[3] = y_; }
 
  531     void setX2e(
int x_)         { myVals[2] = E2I(x_); }
 
  532     void setY2e(
int y_)         { myVals[3] = E2I(y_); }
 
  535 class UT_ExclusiveRectImpl : 
public UT_BaseRectImpl
 
  538     UT_ExclusiveRectImpl()  { }
 
  548     void clear()            { 
set( 0, 0, 0, 0 ); }
 
  551     bool isValid()
 const    { 
return x1() <= x2e() && 
y1() <= y2e(); }
 
  556         if (myVals[0] > myVals[2])
 
  558             UTswap(myVals[2], myVals[0]);
 
  562         if (myVals[1] > myVals[3])
 
  564             UTswap(myVals[1], myVals[3]);
 
  573         myVals[0] = I2E(flipI(x1(), w));    
 
  574         myVals[2] = flipI(
x2(), w);
 
  575         UTswap(myVals[0], myVals[2]);
 
  579         myVals[1] = I2E(flipI(
y1(), h));    
 
  580         myVals[3] = flipI(
y2(), h);
 
  581         UTswap(myVals[1], myVals[3]);
 
  585     int x1()
 const          { 
return myVals[0]; }
 
  586     int y1()
 const          { 
return myVals[1]; }
 
  587     int x2e()
 const         { 
return myVals[2]; }
 
  588     int y2e()
 const         { 
return myVals[3]; }
 
  589     int x2()
 const          { 
return E2I(x2e()); }
 
  590     int y2()
 const          { 
return E2I(y2e()); }
 
  592     int x()
 const           { 
return x1(); }
 
  593     int y()
 const           { 
return y1(); }
 
  594     int width()
 const       { 
return E2D(x1(), x2e()); }
 
  595     int height()
 const      { 
return E2D(
y1(), y2e()); }
 
  597     void setWidth(
int w)        { myVals[2] = D2E(myVals[0], w); }
 
  598     void setHeight(
int h)       { myVals[3] = D2E(myVals[1], h); }
 
  600     void setX(
int x_)           { myVals[2] = x_ +  
width(); myVals[0] = x_; }
 
  601     void setY(
int y_)           { myVals[3] = y_ + 
height(); myVals[1] = y_; }
 
  602     void setX1(
int x_)          { myVals[0] = x_; }
 
  603     void setY1(
int y_)          { myVals[1] = y_; }
 
  604     void setX2(
int x_)          { myVals[2] = I2E(x_); }
 
  605     void setY2(
int y_)          { myVals[3] = I2E(y_); }
 
  606     void setX2e(
int x_)         { myVals[2] = x_; }
 
  607     void setY2e(
int y_)         { myVals[3] = y_; }
 
  616 #define UT_HASH_RECT(TYPE) \ 
  618         template <> struct hash<TYPE> { \ 
  619         size_t      operator()(const TYPE &r) const { return r.hash(); } \ 
  621     SYS_FORCE_INLINE size_t hash_value(const TYPE &r) { return r.hash(); } \ 
  632 template <
typename T>
 
  643 #define UT_RECT_OP_EQUALS(T1,T2) \ 
  644     inline bool operator==( const T1 &r1, const T2 &r2 ) \ 
  645         { return (r1.x() == r2.x() && r1.y() == r2.y() \ 
  646                 && r1.width() == r2.width() \ 
  647                 && r1.height() == r2.height()); } 
  653     UT_RECT_OP_EQUALS(UT_InclusiveRect,UT_InclusiveRect)
 
  656     UT_RECT_OP_EQUALS(UT_ExclusiveRect,UT_InclusiveRect)
 
  657     UT_RECT_OP_EQUALS(UT_ExclusiveRect,UT_ExclusiveRect)
 
  658 #undef UT_RECT_OP_EQUALS 
  660 #define UT_RECT_OP_NOT_EQUALS(T1,T2) \ 
  661     inline bool operator!=( const T1 &r1, const T2 &r2 ) \ 
  662         { return !(r1 == r2); } 
  664     UT_RECT_OP_NOT_EQUALS(UT_DimRect,UT_DimRect)
 
  665     UT_RECT_OP_NOT_EQUALS(UT_DimRect,UT_InclusiveRect)
 
  666     UT_RECT_OP_NOT_EQUALS(UT_DimRect,UT_ExclusiveRect)
 
  667     UT_RECT_OP_NOT_EQUALS(UT_InclusiveRect,UT_DimRect)
 
  668     UT_RECT_OP_NOT_EQUALS(UT_InclusiveRect,UT_InclusiveRect)
 
  669     UT_RECT_OP_NOT_EQUALS(UT_InclusiveRect,UT_ExclusiveRect)
 
  670     UT_RECT_OP_NOT_EQUALS(UT_ExclusiveRect,UT_DimRect)
 
  671     UT_RECT_OP_NOT_EQUALS(UT_ExclusiveRect,UT_InclusiveRect)
 
  672     UT_RECT_OP_NOT_EQUALS(UT_ExclusiveRect,UT_ExclusiveRect)
 
  673 #undef UT_RECT_OP_NOT_EQUALS 
  675 #define UT_RECT_COPY_TO_DIM(T1,T2) \ 
  676     inline T1::T1( const T2 &r ) \ 
  677         : UT_BaseRectImpl( r.x(), r.y(), r.width(), r.height() ) { } \ 
  678     inline T1 & T1::operator=(const T2 &r) \ 
  679                 { set( r.x(), r.y(), r.width(), r.height() ); return *this; } 
  680 #define UT_RECT_COPY_TO_INCLUSIVE(T1,T2) \ 
  681     inline T1::T1( const T2 &r ) \ 
  682         : UT_BaseRectImpl( r.x1(), r.y1(), r.x2(), r.y2() ) { } \ 
  683     inline T1 & T1::operator=(const T2 &r) \ 
  684                 { set( r.x1(), r.y1(), r.x2(), r.y2() ); return *this; } 
  685 #define UT_RECT_COPY_TO_EXCLUSIVE(T1,T2) \ 
  686     inline T1::T1( const T2 &r ) \ 
  687         : UT_BaseRectImpl( r.x1(), r.y1(), r.x2e(), r.y2e() ) { } \ 
  688     inline T1 & T1::operator=(const T2 &r) \ 
  689                 { set( r.x1(), r.y1(), r.x2e(), r.y2e() ); return *this; } 
  691     UT_RECT_COPY_TO_DIM(UT_DimRectImpl,UT_DimRect)
 
  692     UT_RECT_COPY_TO_DIM(UT_DimRectImpl,UT_InclusiveRect)
 
  693     UT_RECT_COPY_TO_DIM(UT_DimRectImpl,UT_ExclusiveRect)
 
  694     UT_RECT_COPY_TO_INCLUSIVE(UT_InclusiveRectImpl,UT_DimRect)
 
  695     UT_RECT_COPY_TO_INCLUSIVE(UT_InclusiveRectImpl,UT_InclusiveRect)
 
  696     UT_RECT_COPY_TO_INCLUSIVE(UT_InclusiveRectImpl,UT_ExclusiveRect)
 
  697     UT_RECT_COPY_TO_EXCLUSIVE(UT_ExclusiveRectImpl,UT_DimRect)
 
  698     UT_RECT_COPY_TO_EXCLUSIVE(UT_ExclusiveRectImpl,UT_InclusiveRect)
 
  699     UT_RECT_COPY_TO_EXCLUSIVE(UT_ExclusiveRectImpl,UT_ExclusiveRect)
 
  700 #undef UT_RECT_COPY_TO_DIM 
  701 #undef UT_RECT_COPY_TO_INCLUSIVE 
  702 #undef UT_RECT_COPY_TO_EXCLUSIVE 
  706 #endif // __UT_Rect_h__ 
void getDim(int &x_, int &y_, int &w_, int &h_) const 
Get rectangle values. 
 
int * data()
Native data access. 
 
GLenum GLuint GLsizei bufsize
 
void setY2e(int y_)
Set upper-right corner (exclusive), without changing lower-left. 
 
int x2() const 
Get upper-right corner (inclusive) 
 
void setIncl(int x1_, int y1_, int x2_, int y2_)
Set rectangle values. 
 
int centerY() const 
Get center. 
 
int64 getMemoryUsage(bool inclusive) const 
 
bool contains(const T &r) const 
Returns true if T is entirely contained by this rectangle. 
 
__hostdev__ bool isValid(GridType gridType, GridClass gridClass)
return true if the combination of GridType and GridClass is valid. 
 
void setY1(int y_)
Set lower-left corner, without changing the upper-right corner. 
 
void setDim(int v[4])
Set rectangle values. 
 
void setX2(int x_)
Set upper-right corner (inclusive), without changing lower-left. 
 
const int * data() const 
Native data access. 
 
UT_Rect & operator=(const UT_DimRect &r)
Assignment operator. Can convert from any rect type. 
 
int h() const 
Get width/height dimensions. 
 
std::size_t SYS_HashType
Define the type for hash values. 
 
void set(int v[4])
Set the native rect type values. 
 
bool isValid() const 
Return true if rectangle is valid (true if empty) 
 
UT_Rect(int v1, int v2, int v3, int v4)
Construct with native rect type values. 
 
GLfloat GLfloat GLfloat v2
 
UT_Rect(int v[4])
Construct with native rect type values. 
 
GLfloat GLfloat GLfloat GLfloat v3
 
int x2e() const 
Get upper-right corner (exclusive) 
 
static UT_Rect zero()
Convenience method for creating an empty rect. 
 
int operator()(int i) const 
Native data access. 
 
UT_Rect & operator=(const UT_ExclusiveRect &r)
Assignment operator. Can convert from any rect type. 
 
std::ostream & operator<<(std::ostream &ostr, const DataType &a)
 
void setX2e(int x_)
Set upper-right corner (exclusive), without changing lower-left. 
 
void enlarge(const T &r)
Enlarge this rectangle to include the given rectangle (ie. a union) 
 
void setX(int x_)
Set the lower-left corner position, always maintaining the size. 
 
GLint GLsizei GLsizei height
 
void inset(int dx, int dy)
Inset the rect by a dx and dy margins. 
 
bool overlapY(const T &r) const 
Returns true if the given side would overlap the other rectangle if projected onto it...
 
void setExcl(int v[4])
Set rectangle values. 
 
bool isInsideY(int py) const 
Returns true if the rectangle contains the given coord. 
 
void setHeight(int aheight)
Set the width/height, always maintaining the lower-left position. 
 
bool overlapX(const T &r) const 
Returns true if the given side would overlap the other rectangle if projected onto it...
 
constexpr auto set(type rhs) -> int
 
bool intersect(const T &r)
Intersect this rectangle with the given one. Returns if result is valid. 
 
bool isInside(int px, int py) const 
Returns true if the given point is within the rectangle. 
 
void set(int v1, int v2, int v3, int v4)
Set the native rect type values. 
 
void getRelative(int &px, int &py) const 
Get relative coordinates from absolute. 
 
GLint GLint GLsizei GLint GLenum format
 
void flipY(int aheight)
Flip rectangle within the given width/height. 
 
int UTinclusiveFlip(int v, int d)
Flip a particular coordinate value according to the given dimension. 
 
UT_Rect< UT_ExclusiveRectImpl > UT_ExclusiveRect
Integer rectangle class which stores its data as exclusive lower-left to upper-right (x1...
 
int & operator()(int i)
Native data access. 
 
int x() const 
Get lower-left corner. 
 
int w() const 
Get width/height dimensions. 
 
void dump(UT_WorkBuffer &wbuf, const char *msg="") const 
 
int x1() const 
Get lower-left corner. 
 
void getAbsolute(int &px, int &py) const 
Get absolute coordinates from relative. 
 
UT_Rect< UT_InclusiveRectImpl > UT_InclusiveRect
Integer rectangle class which stores its data as inclusive lower-left to upper-right (x1...
 
UT_Rect< UT_DimRectImpl > UT_DimRect
 
int width() const 
Get width/height dimensions. 
 
void clamp(int &px, int &py) const 
Clamp the coordinates to be inclusive of this rect (ie. make it inside) 
 
void setExcl(int x1_, int y1_, int x2_, int y2_)
Set rectangle values. 
 
bool isEmpty() const 
Return true if rectangle is empty. 
 
void setY2(int y_)
Set upper-right corner (inclusive), without changing lower-left. 
 
GLfloat GLfloat GLfloat GLfloat h
 
SYS_FORCE_INLINE SYS_HashType hash() const 
 
UT_Rect(const UT_InclusiveRect &r)
Conversion constructor. 
 
void getExcl(int &x1_, int &y1_, int &x2_, int &y2_) const 
Get rectangle values. 
 
Base Integer Rectangle class. 
 
UT_Rect(const UT_ExclusiveRect &r)
Conversion constructor. 
 
LeafData & operator=(const LeafData &)=delete
 
UT_Rect(const UT_DimRect &r)
Conversion constructor. 
 
int y() const 
Get lower-left corner. 
 
void setX1(int x_)
Set lower-left corner, without changing the upper-right corner. 
 
void clear()
Clear rect to empty. 
 
GLubyte GLubyte GLubyte GLubyte w
 
void setWidth(int awidth)
Set the width/height, always maintaining the lower-left position. 
 
int height() const 
Get width/height dimensions. 
 
bool isInsideX(int px) const 
Returns true if the rectangle contains the given coord. 
 
int y2() const 
Get upper-right corner (inclusive) 
 
GLdouble GLdouble GLdouble y2
 
void setY(int y_)
Set the lower-left corner position, always maintaining the size. 
 
void scale(fpreal factor)
Scale by given factor. 
 
void setIncl(int v[4])
Set rectangle values. 
 
UT_Rect & operator=(const UT_InclusiveRect &r)
Assignment operator. Can convert from any rect type. 
 
int y1() const 
Get lower-left corner. 
 
int y2e() const 
Get upper-right corner (exclusive) 
 
void flipX(int awidth)
Flip rectangle within the given width/height. 
 
void setDim(int x_, int y_, int w_, int h_)
Set rectangle values. 
 
void translate(int x, int y)
Translate by given offset. 
 
void getIncl(int &x1_, int &y1_, int &x2_, int &y2_) const 
Get rectangle values. 
 
int centerX() const 
Get center.