degate  0.1.2
Public Member Functions | Private Attributes
degate::BoundingBox Class Reference

#include <BoundingBox.h>

List of all members.

Public Member Functions

 BoundingBox ()
 BoundingBox (int min_x, int max_x, int min_y, int max_y)
 BoundingBox (int width, int height)
 BoundingBox (const BoundingBox &)
virtual ~BoundingBox ()
BoundingBox const & get_bounding_box () const
bool in_shape (int x, int y, int max_distance=0) const
bool in_bounding_box (BoundingBox const &bbox) const
 Check if this bounding box is completly within the bounding box given as parameter.
bool operator== (const BoundingBox &other) const
bool operator!= (const BoundingBox &other) const
bool intersects (BoundingBox const &rect) const
bool complete_within (BoundingBox const &rect) const
 Check, if rectangle rect is complete within rectangle represented by this.
unsigned int get_width () const
unsigned int get_height () const
int get_min_x () const
int get_max_x () const
int get_min_y () const
int get_max_y () const
int get_center_x () const
int get_center_y () const
void set_min_x (int min_x)
void set_min_y (int min_y)
void set_max_x (int max_x)
void set_max_y (int max_y)
void set (int min_x, int max_x, int min_y, int max_y)
void shift_x (int delta_x)
void shift_y (int delta_y)
void shift (int delta_x, int delta_y)
void print (std::ostream &os=std::cout, int n_tabs=0) const
std::string to_string () const

Private Attributes

int min_x
int max_x
int min_y
int max_y

Detailed Description

Definition at line 30 of file BoundingBox.h.


Constructor & Destructor Documentation

Definition at line 29 of file BoundingBox.cc.

References max_x, max_y, min_x, and min_y.

                         {
  max_y = min_y = max_x = min_x = 0;
}
BoundingBox::BoundingBox ( int  min_x,
int  max_x,
int  min_y,
int  max_y 
)

Definition at line 33 of file BoundingBox.cc.

                                                                   {
  this->min_x = std::min(min_x, max_x);
  this->max_x = std::max(min_x, max_x);
  this->min_y = std::min(min_y, max_y);
  this->max_y = std::max(min_y, max_y);
}
BoundingBox::BoundingBox ( int  width,
int  height 
)

Definition at line 40 of file BoundingBox.cc.

References max_x, max_y, min_x, and min_y.

                                              {
  this->min_x = 0;
  this->max_x = width;
  this->min_y = 0;
  this->max_y = height;
}

Definition at line 47 of file BoundingBox.cc.

References max_x, max_y, min_x, and min_y.

                                             {
  this->min_x = o.min_x;
  this->max_x = o.max_x;
  this->min_y = o.min_y;
  this->max_y = o.max_y;
}

Definition at line 54 of file BoundingBox.cc.

                          {
}

Member Function Documentation

bool BoundingBox::complete_within ( BoundingBox const &  rect) const

Check, if rectangle rect is complete within rectangle represented by this.

Definition at line 98 of file BoundingBox.cc.

References max_x, max_y, min_x, and min_y.

                                                                {

  return (min_x <= rect.min_x &&
          max_x >= rect.max_x &&
          min_y <= rect.min_y &&
          max_y >= rect.max_y);
}

Definition at line 165 of file BoundingBox.cc.

References get_width(), and min_x.

                                    {
  return min_x + get_width() / 2;
}

Here is the call graph for this function:

Definition at line 169 of file BoundingBox.cc.

References get_height(), and min_y.

                                    {
  return min_y + get_height() / 2;
}

Here is the call graph for this function:

unsigned int BoundingBox::get_height ( ) const
int BoundingBox::get_max_x ( ) const
int BoundingBox::get_max_y ( ) const
int BoundingBox::get_min_x ( ) const
int BoundingBox::get_min_y ( ) const
unsigned int BoundingBox::get_width ( ) const
bool BoundingBox::in_bounding_box ( BoundingBox const &  bbox) const

Check if this bounding box is completly within the bounding box given as parameter.

Definition at line 78 of file BoundingBox.cc.

References max_x, max_y, min_x, and min_y.

Referenced by degate::Circle::in_bounding_box(), degate::Line::in_bounding_box(), and degate::QuadTree< T >::traverse_downto_bounding_box().

                                                               {
  return (min_x >= bbox.min_x &&
          max_x <= bbox.max_x &&
          min_y >= bbox.min_y &&
          max_y <= bbox.max_y);
}

Here is the caller graph for this function:

bool BoundingBox::in_shape ( int  x,
int  y,
int  max_distance = 0 
) const

Definition at line 61 of file BoundingBox.cc.

References max_x, max_y, min_x, and min_y.

Referenced by degate::Line::in_shape().

                                                               {
  return (x >= min_x - max_distance && x <= max_x + max_distance &&
          y >= min_y - max_distance && y <= max_y + max_distance) ? true : false;
}

Here is the caller graph for this function:

bool BoundingBox::intersects ( BoundingBox const &  rect) const

Definition at line 85 of file BoundingBox.cc.

References max_x, max_y, min_x, and min_y.

                                                           {

  return !( rect.min_x > max_x ||
            rect.max_x < min_x ||
            rect.min_y > max_y ||
            rect.max_y < min_y);
}
bool BoundingBox::operator!= ( const BoundingBox other) const

Definition at line 73 of file BoundingBox.cc.

                                                           {
    return !(*this == other);
}
bool BoundingBox::operator== ( const BoundingBox other) const

Definition at line 66 of file BoundingBox.cc.

References max_x, max_y, min_x, and min_y.

                                                           {
    return (min_x == other.min_x &&
            max_x == other.max_x &&
            min_y == other.min_y &&
            max_y == other.max_y);
}
void BoundingBox::print ( std::ostream &  os = std::cout,
int  n_tabs = 0 
) const

Definition at line 180 of file BoundingBox.cc.

References degate::gen_tabs(), and to_string().

                                                         {
  os << gen_tabs(n_tabs) << to_string();
}

Here is the call graph for this function:

void BoundingBox::set ( int  min_x,
int  max_x,
int  min_y,
int  max_y 
)

Definition at line 173 of file BoundingBox.cc.

                                                                {
  this->min_x = std::min(min_x, max_x);
  this->max_x = std::max(min_x, max_x);
  this->min_y = std::min(min_y, max_y);
  this->max_y = std::max(min_y, max_y);
}
void BoundingBox::set_max_x ( int  max_x)

Definition at line 140 of file BoundingBox.cc.

References min_x.

Referenced by degate::TemplateMatching::init(), and degate::GateTemplate::set_width().

                                     {
  this->min_x = std::min(min_x, max_x);
  this->max_x = std::max(min_x, max_x);
}

Here is the caller graph for this function:

void BoundingBox::set_max_y ( int  max_y)

Definition at line 145 of file BoundingBox.cc.

References min_y.

Referenced by degate::TemplateMatching::init(), and degate::GateTemplate::set_height().

                                     {
  this->min_y = std::min(min_y, max_y);
  this->max_y = std::max(min_y, max_y);
}

Here is the caller graph for this function:

void BoundingBox::set_min_x ( int  min_x)

Definition at line 130 of file BoundingBox.cc.

References max_x.

                                     {
  this->min_x = std::min(min_x, max_x);
  this->max_x = std::max(min_x, max_x);
}
void BoundingBox::set_min_y ( int  min_y)

Definition at line 135 of file BoundingBox.cc.

References max_y.

                                     {
  this->min_y = std::min(min_y, max_y);
  this->max_y = std::max(min_y, max_y);
}
void BoundingBox::shift ( int  delta_x,
int  delta_y 
)

Definition at line 160 of file BoundingBox.cc.

References shift_x(), and shift_y().

                                                {
  shift_x(delta_x);
  shift_y(delta_y);
}

Here is the call graph for this function:

void BoundingBox::shift_x ( int  delta_x)

Definition at line 155 of file BoundingBox.cc.

References max_x, and min_x.

Referenced by shift().

                                     {
  min_x += delta_x;
  max_x += delta_x;
}

Here is the caller graph for this function:

void BoundingBox::shift_y ( int  delta_y)

Definition at line 150 of file BoundingBox.cc.

References max_y, and min_y.

Referenced by shift().

                                     {
  min_y += delta_y;
  max_y += delta_y;
}

Here is the caller graph for this function:

std::string BoundingBox::to_string ( ) const

Definition at line 184 of file BoundingBox.cc.

References max_x, max_y, min_x, and min_y.

Referenced by degate::ImageHistogram< double, double >::check_bounding_box(), print(), degate::EMarker::print(), degate::Via::print(), degate::Annotation::print(), degate::GatePort::print(), and degate::Gate::print().

                                       {
  boost::format f("x = %1% .. %2% / y = %3% ... %4%");
  f % min_x % max_x % min_y % max_y;
  return f.str();
}

Here is the caller graph for this function:


Member Data Documentation


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