PLaSK library

Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | Friends | List of all members
plask::Box3D Struct Reference

Cuboid class. More...

`#include <plask/geometry/primitives.hpp>`

## Public Member Functions
constexpr Vec< 3, double > | size () const
| Calculate size of this.
constexpr double | height () const
| Calculate size of this in up direction.
constexpr double | width () const
| Calculate width of this.
constexpr double | depth () const
| Calculate depth of this.
constexpr Vec< 3, double > | center () const
| Calculate center point.
| Box3D ()
| Construct uninitialized .
constexpr | Box3D (const Vec< 3, double > &lower, const Vec< 3, double > &upper)
| Construct with given lower and upper corner positions.
constexpr | Box3D (double x_lo, double y_lo, double z_lo, double x_up, double y_up, double z_up)
| Construct box.
bool | operator== (const Box3D &r) const
| Compare two boxes, `this` and `r`.
bool | operator!= (const Box3D &r) const
| Compare two boxes, `this` and `r`.
void | fix ()
| Ensure that lower[0] <= upper.c0, lower[1] <= upper[1], and lower[2] <= upper[3].
bool | contains (const Vec< 3, double > &p) const
| Check if point is inside box.
bool | intersects (const Box3D &other) const
| Check if this and other boxes have common points.
void | makeInclude (const Vec< 3, double > &p)
| Make this box, the minimal one which include `this` and given point `p`.
void | makeInclude (const Box3D &other)
| Make this box, the minimal one which include `this` and `other` box.
void | makeIntersection (const Box3D &other)
| Change this to the biggest box which is included in this and `other` box.
Box3D | extension (Box3D other) const
| Get the minimal box which include `this` and `other` box.
Box3D | intersection (Box3D other) const
| Calculate the biggest box which is included in this and `other` box.
Box3D | translated (const Vec< 3, double > &translation_vec) const
| Get translated copy of this.
Box3D | operator+ (const Vec< 3, double > &translation_vec) const
| Get translated copy of this.
Box3D | operator- (const Vec< 3, double > &translation_vec) const
| Get translated copy of this.
Box3D | translatedUp (const double trasnalation_in_up_dir) const
| Get translated copy of this.
void | translate (const Vec< 3, double > &translation_vec)
| Translate this by `translation_vec`.
Box3D & | operator+= (const Vec< 3, double > &translation_vec)
| Translate this by `translation_vec`.
Box3D & | operator-= (const Vec< 3, double > &translation_vec)
| Translate this by `translation_vec`.
void | translateUp (const double trasnalation_in_up_dir)
| Translate this up by `trasnalation_in_up_dir`.
void | translateDir (unsigned dir_index, const double trasnalation_in_dir)
| Translate this in `dir_index` direction by `trasnalation_in_dir`.
void | makeInclude (const Box2D &other)
| Make this box, the minimal one which include `this` and `other` box.
Vec< 3, double > | moveInside (Vec< 3, double > p) const
| Translate a point to be inside the box by shifting to the closest edge.
bool | isValid () const
| Check if this box is valid (non-empty).
void | makeInvalid ()
| Set this box coordinates to invalid once, so isValid() returns `false` after this call.
double | getArea () const
| Calculate area of the box.
void | flip (size_t flipDir)
| Change i-th coordinate to oposite (mirror).
Box3D | flipped (size_t i) const
| Get vector similar to this but with changed i-th coordinate to oposite.
const double & | back () const
| Return back edge of the box.
double & | back ()
| Return back edge of the box.
const double & | front () const
| Return front edge of the box.
double & | front ()
| Return front edge of the box.
const double & | left () const
| Return left edge of the box.
double & | left ()
| Return left edge of the box.
const double & | right () const
| Return right edge of the box.
double & | right ()
| Return right edge of the box.
const double & | bottom () const
| Return bottom edge of the box.
double & | bottom ()
| Return bottom edge of the box.
const double & | top () const
| Return top edge of the box.
double & | top ()
| Return top edge of the box.
void | setBack (double v)
void | setFront (double v)
void | setLeft (double v)
void | setRight (double v)
void | setBottom (double v)
void | setTop (double v)
double | getBack () const
double | getFront () const
double | getLeft () const
double | getRight () const
double | getBottom () const
double | getTop () const

## Static Public Member Functions
static Box3D | invalidInstance ()

## Public Attributes
Vec< 3, double > | lower
| Position of lower corner of cuboid (with minimal all coordinates).
Vec< 3, double > | upper
| Position of upper corner of cuboid (with maximal all coordinates).

## Friends
std::ostream & | operator<< (std::ostream &out, const Box3D &to_print)
| Print box to stream.

## Detailed Description

Cuboid class.

Allow for some basic operation on cuboid. Has almost identical interface as .

Definition at line 373 of file primitives.hpp.

## Constructor & Destructor Documentation

## ◆ Box3D() [1/3]

plask::Box3D::Box3D | ( |  | ) |
| inline

Construct uninitialized .

Definition at line 411 of file primitives.hpp.

## ◆ Box3D() [2/3]

constexpr plask::Box3D::Box3D | ( | const Vec< 3, double > & | lower,
|  | const Vec< 3, double > & | upper
| ) |  |
| inline constexpr

Construct with given lower and upper corner positions.

Parameters

  lower | position of lower corner of cuboid (with minimal all coordinates)
  upper | position of upper corner of cuboid (with maximal all coordinates)

Definition at line 418 of file primitives.hpp.

## ◆ Box3D() [3/3]

constexpr plask::Box3D::Box3D | ( | double | x_lo,
|  | double | y_lo,
|  | double | z_lo,
|  | double | x_up,
|  | double | y_up,
|  | double | z_up
| ) |  |
| inline constexpr

Construct box.

Parameters

  x_lo,y_lo,z_lo | lower corner of box (with minimal all coordinates)
  x_up,y_up,z_up | upper corner of box (with maximal all coordinates)

Definition at line 425 of file primitives.hpp.

## Member Function Documentation

## ◆ back() [1/2]

double & plask::Box3D::back | ( |  | ) |
| inline

Return back edge of the box.

Assume that box is already correct.

Returns
  back edge of the box

Definition at line 670 of file primitives.hpp.

## ◆ back() [2/2]

const double & plask::Box3D::back | ( |  | ) | const
| inline

Return back edge of the box.

Assume that box is already correct.

Returns
  back edge of the box

Definition at line 664 of file primitives.hpp.

## ◆ bottom() [1/2]

double & plask::Box3D::bottom | ( |  | ) |
| inline

Return bottom edge of the box.

Assume that box is already correct.

Returns
  bottom edge of the box

Definition at line 718 of file primitives.hpp.

## ◆ bottom() [2/2]

const double & plask::Box3D::bottom | ( |  | ) | const
| inline

Return bottom edge of the box.

Assume that box is already correct.

Returns
  bottom edge of the box

Definition at line 712 of file primitives.hpp.

## ◆ center()

constexpr Vec< 3, double > plask::Box3D::center | ( |  | ) | const
| inline constexpr

Calculate center point.

Returns
  center of the box

Definition at line 408 of file primitives.hpp.

## ◆ contains()

bool plask::Box3D::contains | ( | const Vec< 3, double > & | p | ) | const

Check if point is inside box.

Parameters

  p | point

Returns
  true only if point is inside this box

Definition at line 111 of file primitives.cpp.

## ◆ depth()

constexpr double plask::Box3D::depth | ( |  | ) | const
| inline constexpr

Calculate depth of this.

Returns
  width of the box

Definition at line 402 of file primitives.hpp.

## ◆ extension()

Box3D plask::Box3D::extension | ( | Box3D | other | ) | const

Get the minimal box which include `this` and `other` box.

Parameters

  other | box

Returns
  the minimal box which include `this` and `other` box

Definition at line 152 of file primitives.cpp.

## ◆ fix()

void plask::Box3D::fix | ( |  | ) |

Ensure that lower[0] <= upper.c0, lower[1] <= upper[1], and lower[2] <= upper[3].

Exchange components of lower and upper if necessary.

Definition at line 104 of file primitives.cpp.

## ◆ flip()

void plask::Box3D::flip | ( | size_t | flipDir | ) |
| inline

Change i-th coordinate to oposite (mirror).

WARNING This function does not check if it is valid (for efficiency reasons)

Parameters

  flipDir | number of coordinate

Definition at line 641 of file primitives.hpp.

## ◆ flipped()

Box3D plask::Box3D::flipped | ( | size_t | i | ) | const
| inline

Get vector similar to this but with changed i-th coordinate to oposite.

WARNING This function does not check if it is valid (for efficiency reasons)

Parameters

  i | number of coordinate

Returns
  box similar to this but with mirrored i-th coordinate

Definition at line 654 of file primitives.hpp.

## ◆ front() [1/2]

double & plask::Box3D::front | ( |  | ) |
| inline

Return front edge of the box.

Assume that box is already correct.

Returns
  front edge of the box

Definition at line 682 of file primitives.hpp.

## ◆ front() [2/2]

const double & plask::Box3D::front | ( |  | ) | const
| inline

Return front edge of the box.

Assume that box is already correct.

Returns
  front edge of the box

Definition at line 676 of file primitives.hpp.

## ◆ getArea()

double plask::Box3D::getArea | ( |  | ) | const
| inline

Calculate area of the box.

Returns
  area of the box

Definition at line 631 of file primitives.hpp.

## ◆ getBack()

double plask::Box3D::getBack | ( |  | ) | const
| inline

Definition at line 739 of file primitives.hpp.

## ◆ getBottom()

double plask::Box3D::getBottom | ( |  | ) | const
| inline

Definition at line 743 of file primitives.hpp.

## ◆ getFront()

double plask::Box3D::getFront | ( |  | ) | const
| inline

Definition at line 740 of file primitives.hpp.

## ◆ getLeft()

double plask::Box3D::getLeft | ( |  | ) | const
| inline

Definition at line 741 of file primitives.hpp.

## ◆ getRight()

double plask::Box3D::getRight | ( |  | ) | const
| inline

Definition at line 742 of file primitives.hpp.

## ◆ getTop()

double plask::Box3D::getTop | ( |  | ) | const
| inline

Definition at line 744 of file primitives.hpp.

## ◆ height()

constexpr double plask::Box3D::height | ( |  | ) | const
| inline constexpr

Calculate size of this in up direction.

Returns
  upper.vert() - lower.up

Definition at line 390 of file primitives.hpp.

## ◆ intersection()

Box3D plask::Box3D::intersection | ( | Box3D | other | ) | const

Calculate the biggest box which is included in this and `other` box.

Parameters

  other | box to clip

Returns
  the biggest box which is included in this and `other` box

Definition at line 157 of file primitives.cpp.

## ◆ intersects()

bool plask::Box3D::intersects | ( | const Box3D & | other | ) | const

Check if this and other boxes have common points.

Parameters

  other | box

Returns
  true only if this and other have common points

Definition at line 117 of file primitives.cpp.

## ◆ invalidInstance()

static Box3D plask::Box3D::invalidInstance | ( |  | ) |
| inline static

Definition at line 428 of file primitives.hpp.

## ◆ isValid()

bool plask::Box3D::isValid | ( |  | ) | const
| inline

Check if this box is valid (non-empty).

Valid box has: upper.c0 >= lower.c0 && upper.c1 >= lower.c1 && upper.c2 >= lower.c2

Returns
  `true` only if this box is valid (non-empty)

Definition at line 616 of file primitives.hpp.

## ◆ left() [1/2]

double & plask::Box3D::left | ( |  | ) |
| inline

Return left edge of the box.

Assume that box is already correct.

Returns
  left edge of the box

Definition at line 694 of file primitives.hpp.

## ◆ left() [2/2]

const double & plask::Box3D::left | ( |  | ) | const
| inline

Return left edge of the box.

Assume that box is already correct.

Returns
  left edge of the box

Definition at line 688 of file primitives.hpp.

## ◆ makeInclude() [1/3]

void plask::Box3D::makeInclude | ( | const Box2D & | other | ) |

Make this box, the minimal one which include `this` and `other` box.

Parameters

  other | point which should be inside box

## ◆ makeInclude() [2/3]

void plask::Box3D::makeInclude | ( | const Box3D & | other | ) |

Make this box, the minimal one which include `this` and `other` box.

Parameters

  other | point which should be inside box

Definition at line 134 of file primitives.cpp.

## ◆ makeInclude() [3/3]

void plask::Box3D::makeInclude | ( | const Vec< 3, double > & | p | ) |

Make this box, the minimal one which include `this` and given point `p`.

Parameters

  p | point which should be inside box

Definition at line 128 of file primitives.cpp.

## ◆ makeIntersection()

void plask::Box3D::makeIntersection | ( | const Box3D & | other | ) |

Change this to the biggest box which is included in this and `other` box.

Parameters

  other | box to clip this

Definition at line 143 of file primitives.cpp.

## ◆ makeInvalid()

void plask::Box3D::makeInvalid | ( |  | ) |
| inline

Set this box coordinates to invalid once, so isValid() returns `false` after this call.

See also
  isValid()

Definition at line 622 of file primitives.hpp.

## ◆ moveInside()

Vec< 3, double > plask::Box3D::moveInside | ( | Vec< 3, double > | p | ) | const

Translate a point to be inside the box by shifting to the closest edge.

This method assumes that the box is fixed.

Parameters

  p | given point

Returns
  point shifted to the boxes

Definition at line 162 of file primitives.cpp.

## ◆ operator!=()

bool plask::Box3D::operator!= | ( | const Box3D & | r | ) | const

Compare two boxes, `this` and `r`.

Parameters

  r | box to compare

Returns
  true only if `this` box and `p` don't have equals coordinates

Definition at line 100 of file primitives.cpp.

## ◆ operator+()

Box3D plask::Box3D::operator+ | ( | const Vec< 3, double > & | translation_vec | ) | const
| inline

Get translated copy of this.

Parameters

  translation_vec | translation vector

Returns
  this translated by `translation_vec`

Definition at line 514 of file primitives.hpp.

## ◆ operator+=()

Box3D & plask::Box3D::operator+= | ( | const Vec< 3, double > & | translation_vec | ) |
| inline

Translate this by `translation_vec`.

Parameters

  translation_vec | translation vector

Definition at line 551 of file primitives.hpp.

## ◆ operator-()

Box3D plask::Box3D::operator- | ( | const Vec< 3, double > & | translation_vec | ) | const
| inline

Get translated copy of this.

Parameters

  translation_vec | translation vector

Returns
  this translated by `translation_vec`

Definition at line 523 of file primitives.hpp.

## ◆ operator-=()

Box3D & plask::Box3D::operator-= | ( | const Vec< 3, double > & | translation_vec | ) |
| inline

Translate this by `translation_vec`.

Parameters

  translation_vec | translation vector

Definition at line 561 of file primitives.hpp.

## ◆ operator==()

bool plask::Box3D::operator== | ( | const Box3D & | r | ) | const

Compare two boxes, `this` and `r`.

Parameters

  r | box to compare

Returns
  true only if `this` box and `p` have equals coordinates

Definition at line 96 of file primitives.cpp.

## ◆ right() [1/2]

double & plask::Box3D::right | ( |  | ) |
| inline

Return right edge of the box.

Assume that box is already correct.

Returns
  right edge of the box

Definition at line 706 of file primitives.hpp.

## ◆ right() [2/2]

const double & plask::Box3D::right | ( |  | ) | const
| inline

Return right edge of the box.

Assume that box is already correct.

Returns
  right edge of the box

Definition at line 700 of file primitives.hpp.

## ◆ setBack()

void plask::Box3D::setBack | ( | double | v | ) |
| inline

Definition at line 732 of file primitives.hpp.

## ◆ setBottom()

void plask::Box3D::setBottom | ( | double | v | ) |
| inline

Definition at line 736 of file primitives.hpp.

## ◆ setFront()

void plask::Box3D::setFront | ( | double | v | ) |
| inline

Definition at line 733 of file primitives.hpp.

## ◆ setLeft()

void plask::Box3D::setLeft | ( | double | v | ) |
| inline

Definition at line 734 of file primitives.hpp.

## ◆ setRight()

void plask::Box3D::setRight | ( | double | v | ) |
| inline

Definition at line 735 of file primitives.hpp.

## ◆ setTop()

void plask::Box3D::setTop | ( | double | v | ) |
| inline

Definition at line 737 of file primitives.hpp.

## ◆ size()

constexpr Vec< 3, double > plask::Box3D::size | ( |  | ) | const
| inline constexpr

Calculate size of this.

Returns
  upper - lower

Definition at line 384 of file primitives.hpp.

## ◆ top() [1/2]

double & plask::Box3D::top | ( |  | ) |
| inline

Return top edge of the box.

Assume that box is already correct.

Returns
  top edge of the box

Definition at line 730 of file primitives.hpp.

## ◆ top() [2/2]

const double & plask::Box3D::top | ( |  | ) | const
| inline

Return top edge of the box.

Assume that box is already correct.

Returns
  top edge of the box

Definition at line 724 of file primitives.hpp.

## ◆ translate()

void plask::Box3D::translate | ( | const Vec< 3, double > & | translation_vec | ) |
| inline

Translate this by `translation_vec`.

Parameters

  translation_vec | translation vector

Definition at line 542 of file primitives.hpp.

## ◆ translated()

Box3D plask::Box3D::translated | ( | const Vec< 3, double > & | translation_vec | ) | const
| inline

Get translated copy of this.

Parameters

  translation_vec | translation vector

Returns
  this translated by `translation_vec`

Definition at line 505 of file primitives.hpp.

## ◆ translateDir()

void plask::Box3D::translateDir | ( | unsigned | dir_index,
|  | const double | trasnalation_in_dir
| ) |  |
| inline

Translate this in `dir_index` direction by `trasnalation_in_dir`.

Parameters

  dir_index | direction index, 0, 1 or 2
  trasnalation_in_dir | translation in `dir_index` direction

Definition at line 581 of file primitives.hpp.

## ◆ translatedUp()

Box3D plask::Box3D::translatedUp | ( | const double | trasnalation_in_up_dir | ) | const
| inline

Get translated copy of this.

Parameters

  trasnalation_in_up_dir | translation in up direction

Returns
  `this` translated up by `trasnalation_in_up_dir`

Definition at line 532 of file primitives.hpp.

## ◆ translateUp()

void plask::Box3D::translateUp | ( | const double | trasnalation_in_up_dir | ) |
| inline

Translate this up by `trasnalation_in_up_dir`.

Parameters

  trasnalation_in_up_dir | translation in up direction

Definition at line 571 of file primitives.hpp.

## ◆ width()

constexpr double plask::Box3D::width | ( |  | ) | const
| inline constexpr

Calculate width of this.

Returns
  width of the box

Definition at line 396 of file primitives.hpp.

## Friends And Related Symbol Documentation

## ◆ operator<<

std::ostream & operator<< | ( | std::ostream & | out,
|  | const Box3D & | to_print
| ) |  |
| friend

Print box to stream.

Parameters

  out | print destination, output stream
  to_print | box to print

Returns
  out stream

Definition at line 606 of file primitives.hpp.

## Member Data Documentation

## ◆ lower

Vec<3, double> plask::Box3D::lower

Position of lower corner of cuboid (with minimal all coordinates).

Definition at line 375 of file primitives.hpp.

## ◆ upper

Vec<3, double> plask::Box3D::upper

Position of upper corner of cuboid (with maximal all coordinates).

Definition at line 378 of file primitives.hpp.

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

- plask/geometry/primitives.hpp
- plask/geometry/primitives.cpp