LibreOffice Module basegfx (master) 1
Public Types | Public Member Functions | Private Attributes | List of all members
basegfx::B2IBox Class Reference

A two-dimensional interval over integers. More...

#include <b2ibox.hxx>

Collaboration diagram for basegfx::B2IBox:
[legend]

Public Types

typedef sal_Int32 ValueType
 
typedef Int32Traits TraitsType
 

Public Member Functions

 B2IBox ()
 
 B2IBox (const B2ITuple &rTuple)
 Create degenerate interval that's still empty. More...
 
 B2IBox (sal_Int32 x1, sal_Int32 y1, sal_Int32 x2, sal_Int32 y2)
 Create proper interval between the two given points. More...
 
 B2IBox (const B2ITuple &rTuple1, const B2ITuple &rTuple2)
 Create proper interval between the two given points. More...
 
bool isEmpty () const
 Check if the interval set is empty. More...
 
bool operator== (const B2IBox &rBox) const
 
bool operator!= (const B2IBox &rBox) const
 
sal_Int32 getMinX () const
 get lower bound of the set. returns arbitrary values for empty sets. More...
 
sal_Int32 getMinY () const
 get lower bound of the set. returns arbitrary values for empty sets. More...
 
sal_Int32 getMaxX () const
 get upper bound of the set. returns arbitrary values for empty sets. More...
 
sal_Int32 getMaxY () const
 get upper bound of the set. returns arbitrary values for empty sets. More...
 
sal_Int64 getWidth () const
 return difference between upper and lower X value. returns 0 for empty sets. More...
 
sal_Int64 getHeight () const
 return difference between upper and lower Y value. returns 0 for empty sets. More...
 
bool isInside (const B2ITuple &rTuple) const
 yields true if point is contained in set More...
 
void expand (const B2ITuple &rTuple)
 add point to the set, expanding as necessary More...
 
void intersect (const B2IBox &rBox)
 calc set intersection More...
 

Private Attributes

BasicBox maRangeX
 
BasicBox maRangeY
 

Detailed Description

A two-dimensional interval over integers.

This is most easily depicted as a set of integers, bounded by a lower and an upper value - but excluding the upper value. All inbetween values are included in the set (see also http://en.wikipedia.org/wiki/Interval_%28mathematics%29).

The set is half-open, i.e. the lower bound is included, the upper bound not (if you're used to the notation - we're talking about [a,b) here, compared to closed [a,b] or fully open intervals (a,b)).

If you don't need a half-open interval, check B2IRange.

That means, isInside(val) will return true also for values of val=a, but not for val=b.

Alternatively, consider this a rectangle, where the rightmost pixel column and the bottommost pixel row are excluded - this is much like polygon filling. As a result, filling a given rectangle with basebmp::BitmapDevice::fillPolyPolygon(), will affect exactly the same set of pixel as isInside() would return true for.

See also
B2IRange

Definition at line 55 of file b2ibox.hxx.

Member Typedef Documentation

◆ TraitsType

Definition at line 59 of file b2ibox.hxx.

◆ ValueType

typedef sal_Int32 basegfx::B2IBox::ValueType

Definition at line 58 of file b2ibox.hxx.

Constructor & Destructor Documentation

◆ B2IBox() [1/4]

basegfx::B2IBox::B2IBox ( )
inline

Definition at line 61 of file b2ibox.hxx.

◆ B2IBox() [2/4]

basegfx::B2IBox::B2IBox ( const B2ITuple rTuple)
inlineexplicit

Create degenerate interval that's still empty.

Definition at line 64 of file b2ibox.hxx.

◆ B2IBox() [3/4]

basegfx::B2IBox::B2IBox ( sal_Int32  x1,
sal_Int32  y1,
sal_Int32  x2,
sal_Int32  y2 
)
inline

Create proper interval between the two given points.

Definition at line 71 of file b2ibox.hxx.

References basegfx::BasicRange< T, Traits >::expand(), maRangeX, and maRangeY.

◆ B2IBox() [4/4]

basegfx::B2IBox::B2IBox ( const B2ITuple rTuple1,
const B2ITuple rTuple2 
)
inline

Create proper interval between the two given points.

Definition at line 83 of file b2ibox.hxx.

References expand().

Member Function Documentation

◆ expand()

void basegfx::B2IBox::expand ( const B2ITuple rTuple)
inline

add point to the set, expanding as necessary

Definition at line 159 of file b2ibox.hxx.

References basegfx::BasicRange< T, Traits >::expand(), basegfx::Tuple2D< TYPE >::getX(), basegfx::Tuple2D< TYPE >::getY(), maRangeX, and maRangeY.

Referenced by B2IBox().

◆ getHeight()

sal_Int64 basegfx::B2IBox::getHeight ( ) const
inline

return difference between upper and lower Y value. returns 0 for empty sets.

Definition at line 144 of file b2ibox.hxx.

References basegfx::BasicRange< T, Traits >::getRange(), and maRangeY.

◆ getMaxX()

sal_Int32 basegfx::B2IBox::getMaxX ( ) const
inline

get upper bound of the set. returns arbitrary values for empty sets.

Definition at line 126 of file b2ibox.hxx.

References basegfx::BasicRange< T, Traits >::getMaximum(), and maRangeX.

Referenced by basegfx::utils::getCohenSutherlandClipFlags().

◆ getMaxY()

sal_Int32 basegfx::B2IBox::getMaxY ( ) const
inline

get upper bound of the set. returns arbitrary values for empty sets.

Definition at line 132 of file b2ibox.hxx.

References basegfx::BasicRange< T, Traits >::getMaximum(), and maRangeY.

Referenced by basegfx::utils::getCohenSutherlandClipFlags().

◆ getMinX()

sal_Int32 basegfx::B2IBox::getMinX ( ) const
inline

get lower bound of the set. returns arbitrary values for empty sets.

Definition at line 114 of file b2ibox.hxx.

References basegfx::BasicRange< T, Traits >::getMinimum(), and maRangeX.

Referenced by basegfx::utils::getCohenSutherlandClipFlags().

◆ getMinY()

sal_Int32 basegfx::B2IBox::getMinY ( ) const
inline

get lower bound of the set. returns arbitrary values for empty sets.

Definition at line 120 of file b2ibox.hxx.

References basegfx::BasicRange< T, Traits >::getMinimum(), and maRangeY.

Referenced by basegfx::utils::getCohenSutherlandClipFlags().

◆ getWidth()

sal_Int64 basegfx::B2IBox::getWidth ( ) const
inline

return difference between upper and lower X value. returns 0 for empty sets.

Definition at line 138 of file b2ibox.hxx.

References basegfx::BasicRange< T, Traits >::getRange(), and maRangeX.

◆ intersect()

void basegfx::B2IBox::intersect ( const B2IBox rBox)
inline

calc set intersection

Definition at line 166 of file b2ibox.hxx.

References basegfx::BasicRange< T, Traits >::intersect(), maRangeX, and maRangeY.

◆ isEmpty()

bool basegfx::B2IBox::isEmpty ( ) const
inline

Check if the interval set is empty.

Returns
false, if no value is in this set - having a single value included will still return false.

Definition at line 96 of file b2ibox.hxx.

References basegfx::BasicBox::isEmpty(), maRangeX, and maRangeY.

◆ isInside()

bool basegfx::B2IBox::isInside ( const B2ITuple rTuple) const
inline

yields true if point is contained in set

Definition at line 150 of file b2ibox.hxx.

References basegfx::Tuple2D< TYPE >::getX(), basegfx::Tuple2D< TYPE >::getY(), basegfx::BasicBox::isInside(), maRangeX, and maRangeY.

◆ operator!=()

bool basegfx::B2IBox::operator!= ( const B2IBox rBox) const
inline

Definition at line 107 of file b2ibox.hxx.

References maRangeX, and maRangeY.

◆ operator==()

bool basegfx::B2IBox::operator== ( const B2IBox rBox) const
inline

Definition at line 101 of file b2ibox.hxx.

References maRangeX, and maRangeY.

Member Data Documentation

◆ maRangeX

BasicBox basegfx::B2IBox::maRangeX
private

◆ maRangeY

BasicBox basegfx::B2IBox::maRangeY
private

The documentation for this class was generated from the following file: