Belle II Software development
BoundingBox Class Reference

A two dimensional rectangle that keeps track of the extend of a drawing. More...

#include <BoundingBox.h>

Public Member Functions

 BoundingBox ()
 Default constructor for ROOT compatibility. Cell weight defaults to 1.
 
 BoundingBox (float x1, float y1, float x2, float y2)
 Initialises the bounds of the rectangle to the given values. Automatically swaps the x or y values if they are given in a decreasing.
 
void operator&= (const BoundingBox &other)
 Expands the bounding box such that it also covers the given bounding box.
 
void expand (float delta)
 Expands the rectangle in each direction by the given value delta.
 
float getWidth () const
 Getter for the width of the bounding box rectangle.
 
float getHeight () const
 Getter for the height of the bounding box rectangle.
 
float getLeft () const
 Getter for the location of the left of the bounding box rectangle (lower x bound). NAN if unset.
 
float getBottom () const
 Getter for the location of the bottom of the bounding box rectangle (lower y bound). NAN if unset.
 
float getRight () const
 Getter for the location of the right of the bounding box rectangle (upper x bound). NAN if unset.
 
float getTop () const
 Getter for the location of the top of the bounding box rectangle (upper y bound). NAN if unset.
 
void clear ()
 Clears all bounds to NAN.
 

Private Attributes

float m_left
 Memory for the lower x bound of the rectangle.
 
float m_bottom
 Memory for the lower y bound of the rectangle.
 
float m_right
 Memory for the upper x bound of the rectangle.
 
float m_top
 Memory for the upper y bound of the rectangle.
 

Detailed Description

A two dimensional rectangle that keeps track of the extend of a drawing.

Definition at line 21 of file BoundingBox.h.

Constructor & Destructor Documentation

◆ BoundingBox() [1/2]

BoundingBox ( )
inline

Default constructor for ROOT compatibility. Cell weight defaults to 1.

Definition at line 26 of file BoundingBox.h.

26 :
27 m_left(NAN),
28 m_bottom(NAN),
29 m_right(NAN),
30 m_top(NAN)
31 {}
float m_left
Memory for the lower x bound of the rectangle.
Definition: BoundingBox.h:97
float m_bottom
Memory for the lower y bound of the rectangle.
Definition: BoundingBox.h:100
float m_top
Memory for the upper y bound of the rectangle.
Definition: BoundingBox.h:106
float m_right
Memory for the upper x bound of the rectangle.
Definition: BoundingBox.h:103

◆ BoundingBox() [2/2]

BoundingBox ( float  x1,
float  y1,
float  x2,
float  y2 
)
inline

Initialises the bounds of the rectangle to the given values. Automatically swaps the x or y values if they are given in a decreasing.

Definition at line 34 of file BoundingBox.h.

34 :
35 m_left(std::min(x1, x2)),
36 m_bottom(std::min(y1, y2)),
37 m_right(std::max(x1, x2)),
38 m_top(std::max(y1, y2))
39 {}

Member Function Documentation

◆ clear()

void clear ( )
inline

Clears all bounds to NAN.

Definition at line 87 of file BoundingBox.h.

88 {
89 m_left = NAN;
90 m_bottom = NAN;
91 m_right = NAN;
92 m_top = NAN;
93 }

◆ expand()

void expand ( float  delta)
inline

Expands the rectangle in each direction by the given value delta.

Definition at line 54 of file BoundingBox.h.

55 {
56 m_left -= delta;
57 m_bottom -= delta;
58 m_right += delta;
59 m_top += delta;
60 }

◆ getBottom()

float getBottom ( ) const
inline

Getter for the location of the bottom of the bounding box rectangle (lower y bound). NAN if unset.

Definition at line 75 of file BoundingBox.h.

76 { return m_bottom; }

◆ getHeight()

float getHeight ( ) const
inline

Getter for the height of the bounding box rectangle.

Definition at line 67 of file BoundingBox.h.

68 { return getTop() - getBottom(); }
float getBottom() const
Getter for the location of the bottom of the bounding box rectangle (lower y bound)....
Definition: BoundingBox.h:75
float getTop() const
Getter for the location of the top of the bounding box rectangle (upper y bound). NAN if unset.
Definition: BoundingBox.h:83

◆ getLeft()

float getLeft ( ) const
inline

Getter for the location of the left of the bounding box rectangle (lower x bound). NAN if unset.

Definition at line 71 of file BoundingBox.h.

72 { return m_left; }

◆ getRight()

float getRight ( ) const
inline

Getter for the location of the right of the bounding box rectangle (upper x bound). NAN if unset.

Definition at line 79 of file BoundingBox.h.

80 { return m_right; }

◆ getTop()

float getTop ( ) const
inline

Getter for the location of the top of the bounding box rectangle (upper y bound). NAN if unset.

Definition at line 83 of file BoundingBox.h.

84 { return m_top; }

◆ getWidth()

float getWidth ( ) const
inline

Getter for the width of the bounding box rectangle.

Definition at line 63 of file BoundingBox.h.

64 { return getRight() - getLeft(); }
float getRight() const
Getter for the location of the right of the bounding box rectangle (upper x bound)....
Definition: BoundingBox.h:79
float getLeft() const
Getter for the location of the left of the bounding box rectangle (lower x bound)....
Definition: BoundingBox.h:71

◆ operator&=()

void operator&= ( const BoundingBox other)
inline

Expands the bounding box such that it also covers the given bounding box.

Definition at line 42 of file BoundingBox.h.

43 {
44
45 m_left = std::isnan(getLeft()) ? other.getLeft() : std::min(getLeft(), other.getLeft());
46 m_bottom = std::isnan(getBottom()) ? other.getBottom() : std::min(getBottom(), other.getBottom());
47
48 m_right = std::isnan(getRight()) ? other.getRight() : std::max(getRight(), other.getRight());
49 m_top = std::isnan(getTop()) ? other.getTop() : std::max(getTop(), other.getTop());
50
51 }

Member Data Documentation

◆ m_bottom

float m_bottom
private

Memory for the lower y bound of the rectangle.

Definition at line 100 of file BoundingBox.h.

◆ m_left

float m_left
private

Memory for the lower x bound of the rectangle.

Definition at line 97 of file BoundingBox.h.

◆ m_right

float m_right
private

Memory for the upper x bound of the rectangle.

Definition at line 103 of file BoundingBox.h.

◆ m_top

float m_top
private

Memory for the upper y bound of the rectangle.

Definition at line 106 of file BoundingBox.h.


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