Kaim::Box2i Class Reference

Kaim::Box2i Class Reference

#include <box2i.h>

Class Description

2d axis aligned box of 32bits integers. Very Important: CountX() returns m_max.x - m_min.x + 1.

+ Examples:

Functions

 Box2i ()
 Set { {+infinite, +infinite}, {-infinite, -infinite} }. More...
 
 Box2i (const Vec2i &min_, const Vec2i &max_)
 
 Box2i (KyInt32 min_x, KyInt32 min_y, KyInt32 max_x, KyInt32 max_y)
 
bool operator== (const Box2i &other) const
 
bool operator!= (const Box2i &other) const
 
void Clear ()
 Set { {+infinite, +infinite}, {-infinite, -infinite} }. More...
 
bool IsValid () const
 
void MakeZero ()
 set {{0,0},{0,0}} More...
 
void Set (const Vec2i &min_, const Vec2i &max_)
 
void Set (KyInt32 min_x, KyInt32 min_y, KyInt32 max_x, KyInt32 max_y)
 
void SetSafe (const Vec2i &min_, const Vec2i &max_)
 check if values max_ - min_ does overflow More...
 
void SetMin (const Vec2i &min_)
 
void SetMax (const Vec2i &max_)
 
const Vec2iMin () const
 
const Vec2iMax () const
 
const Vec2iCountXY () const
 Return { m_max.x - m_min.x + 1, m_max.y - m_min.y + 1}. More...
 
KyInt32 CountX () const
 Return m_max.x - m_min.x + 1. More...
 
KyInt32 CountY () const
 Return m_max.y - m_min.y + 1. More...
 

East North West South

KyInt32 East () const
 
KyInt32 North () const
 
KyInt32 West () const
 
KyInt32 South () const
 
Vec2i NorthEast () const
 
Vec2i NorthWest () const
 
Vec2i SouthWest () const
 
Vec2i SouthEast () const
 

DoesContain

bool DoesContain (const Vec2i &pos) const
 
bool DoesContainStrictly (const Vec2i &pos) const
 
bool DoesContainNeighbor (const Vec2i &pos, CardinalDir dir) const
 precondition: pos is inside More...
 

Index

KyInt32 GetRowMajorIndex (const Vec2i &pos) const
 Compute index of position in box, where index is incremented in a outer-loop on Y and inner-loop on X. More...
 
KyInt32 GetRowMajorIndexFromLocalPos (const Vec2i &localPos) const
 Compute index of position in box, where index is incremented in a outer-loop on Y and inner-loop on X localPos is relative to m_min. More...
 

Expand

void ExpandByPos (const Vec2i &pos)
 
void ExpandByPos (const Vec3i &pos)
 
void ExpandByTriangle (const Triangle3i &triangle)
 
void ExpandByBox (const Box2i &box)
 

Enlarge

void Enlarge (KyInt32 enlargement)
 
void GetEnlarged (KyInt32 enlargement, Box2i &enlarged) const
 
Box2i GetEnlarged (KyInt32 enlargement) const
 

Intersect

bool IntersectWith (const Box2i &box)
 Sets itself as its intersection with box, return true if itself and box do intersect. More...
 
bool DoesIntersectWith (const Box2i &box) const
 
bool SetAsIntersection (const Box2i &box_1, const Box2i &box_2)
 Sets itself as the intersection of box_1 and box_2, return true if box_1 and box_2 do intersect. More...
 

Public Data

Vec2i m_min
 
Vec2i m_max
 

Constructor & Destructor Documentation

Kaim::Box2i::Box2i ( )
inline

Set { {+infinite, +infinite}, {-infinite, -infinite} }.

Member Function Documentation

void Kaim::Box2i::Clear ( )
inline

Set { {+infinite, +infinite}, {-infinite, -infinite} }.

KyInt32 Kaim::Box2i::CountX ( ) const
inline

Return m_max.x - m_min.x + 1.

const Vec2i& Kaim::Box2i::CountXY ( ) const
inline

Return { m_max.x - m_min.x + 1, m_max.y - m_min.y + 1}.

KyInt32 Kaim::Box2i::CountY ( ) const
inline

Return m_max.y - m_min.y + 1.

bool Kaim::Box2i::DoesContainNeighbor ( const Vec2i pos,
CardinalDir  dir 
) const
inline

precondition: pos is inside

KyInt32 Kaim::Box2i::GetRowMajorIndex ( const Vec2i pos) const
inline

Compute index of position in box, where index is incremented in a outer-loop on Y and inner-loop on X.

^Y
+---+---#########################---+--
| | # 6 | 7 | 8 | 9 | 10| 11# |
+---+---#---+---+---+---+---+---#---+--
| | # 0 | 1 | 2 | 3 | 4 | 5 # |
+---+---#########################---+--
| | | | | | | | | |
+---+---+---+---+---+---+---+---+---+-> X
KyInt32 Kaim::Box2i::GetRowMajorIndexFromLocalPos ( const Vec2i localPos) const
inline

Compute index of position in box, where index is incremented in a outer-loop on Y and inner-loop on X localPos is relative to m_min.

bool Kaim::Box2i::IntersectWith ( const Box2i box)
inline

Sets itself as its intersection with box, return true if itself and box do intersect.

void Kaim::Box2i::MakeZero ( )
inline

set {{0,0},{0,0}}

bool Kaim::Box2i::SetAsIntersection ( const Box2i box_1,
const Box2i box_2 
)
inline

Sets itself as the intersection of box_1 and box_2, return true if box_1 and box_2 do intersect.

void Kaim::Box2i::SetSafe ( const Vec2i min_,
const Vec2i max_ 
)
inline

check if values max_ - min_ does overflow


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