Coin: SbBox2f Class Reference

| Coin3D is Free Software, published under the BSD 3-clause license. | https://coin3d.github.io https://www.kongsberg.com/en/kogt/

Public Member Functions | Protected Attributes | Related Symbols | List of all members
SbBox2f Class Reference
Base Classes

The SbBox2f class is a 2 dimensional box with floating point corner coordinates. More...

`#include <Inventor/SbBox2f.h>`

## Public Member Functions
| SbBox2f (void)
| SbBox2f (float xmin, float ymin, float xmax, float ymax)
| SbBox2f (const SbVec2f &minpoint, const SbVec2f &maxpoint)
| SbBox2f (const SbBox2d &box)
| SbBox2f (const SbBox2s &box)
| SbBox2f (const SbBox2i32 &box)
SbBox2f & | setBounds (float xmin, float ymin, float xmax, float ymax)
SbBox2f & | setBounds (const SbVec2f &minpoint, const SbVec2f &maxpoint)
SbBox2f & | setBounds (const SbBox2d &box)
SbBox2f & | setBounds (const SbBox2s &box)
SbBox2f & | setBounds (const SbBox2i32 &box)
void | getBounds (float &xmin, float &ymin, float &xmax, float &ymax) const
void | getBounds (SbVec2f &minpoint, SbVec2f &maxpoint) const
const SbVec2f & | getMin (void) const
SbVec2f & | getMin (void)
const SbVec2f & | getMax (void) const
SbVec2f & | getMax (void)
void | extendBy (const SbVec2f &point)
void | extendBy (const SbBox2f &box)
void | makeEmpty (void)
SbBool | isEmpty (void) const
SbBool | hasArea (void) const
SbBool | intersect (const SbVec2f &point) const
SbBool | intersect (const SbBox2f &box) const
SbVec2f | getClosestPoint (const SbVec2f &point) const
SbVec2f | getCenter (void) const
void | getOrigin (float &originX, float &originY) const
void | getSize (float &sizeX, float &sizeY) const
SbVec2f | getSize (void) const
float | getAspectRatio (void) const

## Protected Attributes
SbVec2f | minpt
SbVec2f | maxpt

## Related Symbols
(Note that these are not member symbols.)
int | operator== (const SbBox2f &b1, const SbBox2f &b2)
int | operator!= (const SbBox2f &b1, const SbBox2f &b2)

## Detailed Description

The SbBox2f class is a 2 dimensional box with floating point corner coordinates.

This box class is used by many other classes in Coin for data exchange and storage. It provides two box corners with floating point coordinates, which is among other things useful for representing screen or canvas dimensions in normalized coordinates.

See also
  SbBox2s, SbBox2d, SbBox3s, SbBox3f, SbBox3d, SbXfBox3f.

## Constructor & Destructor Documentation

## ◆ SbBox2f() [1/6]

SbBox2f::SbBox2f | ( | void |  | ) |
| inline

The default constructor makes an empty box.

## ◆ SbBox2f() [2/6]

SbBox2f::SbBox2f | ( | float | xmin,
|  | float | ymin,
|  | float | xmax,
|  | float | ymax )
| inline

Constructs a box with the given corners.

xmin should be less than xmax and ymin should be less than ymax if you want to make a valid box.

## ◆ SbBox2f() [3/6]

SbBox2f::SbBox2f | ( | const SbVec2f & | min,
|  | const SbVec2f & | max )
| inline

Constructs a box with the given lower left and upper right corners.

The coordinates of min should be less than the coordinates of max if you want to make a valid box.

## ◆ SbBox2f() [4/6]

SbBox2f::SbBox2f | ( | const SbBox2d & | box | ) |
| inlineexplicit

Constructs an SbBox2f instance from the value in an SbBox2d instance.

Since
  Coin 2.5

## ◆ SbBox2f() [5/6]

SbBox2f::SbBox2f | ( | const SbBox2s & | box | ) |
| inlineexplicit

Constructs an SbBox2f instance from the value in an SbBox2s instance.

Since
  Coin 2.5

## ◆ SbBox2f() [6/6]

SbBox2f::SbBox2f | ( | const SbBox2i32 & | box | ) |
| inlineexplicit

Constructs an SbBox2f instance from the value in an SbBox2i32 instance.

Since
  Coin 2.5

## Member Function Documentation

## ◆ setBounds() [1/5]

SbBox2f & SbBox2f::setBounds | ( | float | xmin,
|  | float | ymin,
|  | float | xmax,
|  | float | ymax )
| inline

Reset the boundaries of the box.

xmin should be less than xmax and ymin should be less than ymax if you want to make a valid box.

Returns reference to self.

See also
  getBounds().

## ◆ setBounds() [2/5]

SbBox2f & SbBox2f::setBounds | ( | const SbVec2f & | min,
|  | const SbVec2f & | max )
| inline

Reset the boundaries of the box with the given corners.

The coordinates of min should be less than the coordinates of max if you want to make a valid box.

Returns reference to self.

See also
  getBounds().

## ◆ setBounds() [3/5]

SbBox2f & SbBox2f::setBounds | ( | const SbBox2d & | box | ) |

Reset the boundaries of the box to the boundaries of the given box.

Returns reference to self.

See also
  getBounds()

## ◆ setBounds() [4/5]

SbBox2f & SbBox2f::setBounds | ( | const SbBox2s & | box | ) |

Reset the boundaries of the box to the boundaries of the given box.

Returns reference to self.

See also
  getBounds()

## ◆ setBounds() [5/5]

SbBox2f & SbBox2f::setBounds | ( | const SbBox2i32 & | box | ) |

Reset the boundaries of the box to the boundaries of the given box.

Returns reference to self.

See also
  getBounds()

## ◆ getBounds() [1/2]

void SbBox2f::getBounds | ( | float & | xmin,
|  | float & | ymin,
|  | float & | xmax,
|  | float & | ymax ) const
| inline

Returns the box boundaries.

See also
  setBounds(), getMin(), getMax().

## ◆ getBounds() [2/2]

void SbBox2f::getBounds | ( | SbVec2f & | min,
|  | SbVec2f & | max ) const
| inline

Returns the box corner points.

See also
  setBounds(), getMin(), getMax().

## ◆ getMin() [1/2]

const SbVec2f & SbBox2f::getMin | ( | void |  | ) | const
| inline

Returns the lower left corner of the box.

See also
  getOrigin(), getMax().

## ◆ getMin() [2/2]

SbVec2f & SbBox2f::getMin | ( | void |  | ) |
| inline

Returns a modifiable reference to the lower left corner of the box.

See also
  getOrigin(), getMax().

## ◆ getMax() [1/2]

const SbVec2f & SbBox2f::getMax | ( | void |  | ) | const
| inline

Returns the upper right corner of the box.

See also
  getMin().

## ◆ getMax() [2/2]

SbVec2f & SbBox2f::getMax | ( | void |  | ) |
| inline

Returns the upper right corner of the box.

See also
  getMin().

## ◆ extendBy() [1/2]

void SbBox2f::extendBy | ( | const SbVec2f & | point | ) |

Extend the boundaries of the box by the given point, i.e. make the box fit around the point if it isn't already situated within it.

## ◆ extendBy() [2/2]

void SbBox2f::extendBy | ( | const SbBox2f & | box | ) |

Extend the boundaries of the box by the given box parameter. This is equal to calling the above method twice with the corner points.

## ◆ makeEmpty()

void SbBox2f::makeEmpty | ( | void |  | ) |

Marks this as an empty box.

See also
  isEmpty().

## ◆ isEmpty()

SbBool SbBox2f::isEmpty | ( | void |  | ) | const
| inline

Check if this has been marked as an empty box.

See also
  makeEmpty().

## ◆ hasArea()

SbBool SbBox2f::hasArea | ( | void |  | ) | const
| inline

Check if the box has been correctly specified and by that virtue has "positive" area, i.e. all coordinates of its upper right corner (the maximum point) are greater than the corresponding coordinates of its lower left corner (the minimum point).

## ◆ intersect() [1/2]

SbBool SbBox2f::intersect | ( | const SbVec2f & | point | ) | const

Check if point lies within the boundaries of this box.

## ◆ intersect() [2/2]

SbBool SbBox2f::intersect | ( | const SbBox2f & | box | ) | const

Check if box lies entirely or partially within the boundaries of this box.

## ◆ getClosestPoint()

SbVec2f SbBox2f::getClosestPoint | ( | const SbVec2f & | point | ) | const

Return the point on the box closest to the given point p. If the given point equals the center, the center point on the positive X-side is returned.

## ◆ getCenter()

SbVec2f SbBox2f::getCenter | ( | void |  | ) | const
| inline

Returns the center point of the box.

## ◆ getOrigin()

void SbBox2f::getOrigin | ( | float & | originX,
|  | float & | originY ) const
| inline

Returns the coordinates of the box origin (i.e. the lower left corner).

See also
  getMin().

## ◆ getSize() [1/2]

void SbBox2f::getSize | ( | float & | sizeX,
|  | float & | sizeY ) const
| inline

Returns width and height of box.

## ◆ getSize() [2/2]

SbVec2f SbBox2f::getSize | ( | void |  | ) | const
| inline

Returns width and height of box as a 2D vector.

Since
  Coin 3.0

## ◆ getAspectRatio()

float SbBox2f::getAspectRatio | ( | void |  | ) | const
| inline

Returns aspect ratio of box, which is defined as box width divided on box height.

## Friends And Related Symbol Documentation

## ◆ operator==()

int operator== | ( | const SbBox2f & | b1,
|  | const SbBox2f & | b2 )
| related

Check b1 and b2 for equality.

## ◆ operator!=()

int operator!= | ( | const SbBox2f & | b1,
|  | const SbBox2f & | b2 )
| related

Check b1 and b2 for inequality.

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

- SbBox2f.h
- SbBox2f.cpp