PLaSK library
|
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. | |
Cuboid class.
Allow for some basic operation on cuboid. Has almost identical interface as .
Definition at line 371 of file primitives.hpp.
|
inline |
Construct uninitialized .
Definition at line 409 of file primitives.hpp.
|
inlineconstexpr |
Construct with given lower and upper corner positions.
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 416 of file primitives.hpp.
|
inlineconstexpr |
Construct box.
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 423 of file primitives.hpp.
|
inline |
Return back edge of the box.
Assume that box is already correct.
Definition at line 668 of file primitives.hpp.
Return back edge of the box.
Assume that box is already correct.
Definition at line 662 of file primitives.hpp.
|
inline |
Return bottom edge of the box.
Assume that box is already correct.
Definition at line 716 of file primitives.hpp.
Return bottom edge of the box.
Assume that box is already correct.
Definition at line 710 of file primitives.hpp.
Check if point is inside box.
p | point |
Definition at line 111 of file primitives.cpp.
Get the minimal box which include this
and other
box.
other | box |
this
and other
box Definition at line 152 of file primitives.cpp.
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.
|
inline |
Change i-th coordinate to oposite (mirror).
WARNING This function does not check if it is valid (for efficiency reasons)
flipDir | number of coordinate |
Definition at line 639 of file primitives.hpp.
|
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)
i | number of coordinate |
Definition at line 652 of file primitives.hpp.
|
inline |
Return front edge of the box.
Assume that box is already correct.
Definition at line 680 of file primitives.hpp.
Return front edge of the box.
Assume that box is already correct.
Definition at line 674 of file primitives.hpp.
|
inline |
|
inline |
Definition at line 737 of file primitives.hpp.
|
inline |
Definition at line 741 of file primitives.hpp.
|
inline |
Definition at line 738 of file primitives.hpp.
|
inline |
Definition at line 739 of file primitives.hpp.
|
inline |
Definition at line 740 of file primitives.hpp.
|
inline |
Definition at line 742 of file primitives.hpp.
Calculate size of this in up direction.
Definition at line 388 of file primitives.hpp.
Calculate the biggest box which is included in this and other
box.
other | box to clip |
other
box Definition at line 157 of file primitives.cpp.
Check if this and other boxes have common points.
other | box |
Definition at line 117 of file primitives.cpp.
|
inlinestatic |
Definition at line 426 of file primitives.hpp.
|
inline |
Check if this box is valid (non-empty).
Valid box has: upper.c0 >= lower.c0 && upper.c1 >= lower.c1 && upper.c2 >= lower.c2
true
only if this box is valid (non-empty) Definition at line 614 of file primitives.hpp.
|
inline |
Return left edge of the box.
Assume that box is already correct.
Definition at line 692 of file primitives.hpp.
Return left edge of the box.
Assume that box is already correct.
Definition at line 686 of file primitives.hpp.
Make this box, the minimal one which include this
and other
box.
other | point which should be inside box |
Make this box, the minimal one which include this
and other
box.
other | point which should be inside box |
Definition at line 134 of file primitives.cpp.
Make this box, the minimal one which include this
and given point p
.
p | point which should be inside box |
Definition at line 128 of file primitives.cpp.
Change this to the biggest box which is included in this and other
box.
other | box to clip this |
Definition at line 143 of file primitives.cpp.
|
inline |
Set this box coordinates to invalid once, so isValid() returns false
after this call.
Definition at line 620 of file primitives.hpp.
Translate a point to be inside the box by shifting to the closest edge.
This method assumes that the box is fixed.
p | given point |
Definition at line 162 of file primitives.cpp.
Compare two boxes, this
and r
.
r | box to compare |
this
box and p
don't have equals coordinates Definition at line 100 of file primitives.cpp.
Get translated copy of this.
translation_vec | translation vector |
translation_vec
Definition at line 512 of file primitives.hpp.
Translate this by translation_vec
.
translation_vec | translation vector |
Definition at line 549 of file primitives.hpp.
Get translated copy of this.
translation_vec | translation vector |
translation_vec
Definition at line 521 of file primitives.hpp.
Translate this by translation_vec
.
translation_vec | translation vector |
Definition at line 559 of file primitives.hpp.
Compare two boxes, this
and r
.
r | box to compare |
this
box and p
have equals coordinates Definition at line 96 of file primitives.cpp.
|
inline |
Return right edge of the box.
Assume that box is already correct.
Definition at line 704 of file primitives.hpp.
Return right edge of the box.
Assume that box is already correct.
Definition at line 698 of file primitives.hpp.
Definition at line 730 of file primitives.hpp.
Definition at line 734 of file primitives.hpp.
Definition at line 731 of file primitives.hpp.
Definition at line 732 of file primitives.hpp.
Definition at line 733 of file primitives.hpp.
Definition at line 735 of file primitives.hpp.
|
inline |
Return top edge of the box.
Assume that box is already correct.
Definition at line 728 of file primitives.hpp.
Return top edge of the box.
Assume that box is already correct.
Definition at line 722 of file primitives.hpp.
Translate this by translation_vec
.
translation_vec | translation vector |
Definition at line 540 of file primitives.hpp.
Get translated copy of this.
translation_vec | translation vector |
translation_vec
Definition at line 503 of file primitives.hpp.
Translate this in dir_index
direction by trasnalation_in_dir
.
dir_index | direction index, 0, 1 or 2 |
trasnalation_in_dir | translation in dir_index direction |
Definition at line 579 of file primitives.hpp.
Get translated copy of this.
trasnalation_in_up_dir | translation in up direction |
this
translated up by trasnalation_in_up_dir
Definition at line 530 of file primitives.hpp.
Translate this up by trasnalation_in_up_dir
.
trasnalation_in_up_dir | translation in up direction |
Definition at line 569 of file primitives.hpp.
Print box to stream.
out | print destination, output stream |
to_print | box to print |
Definition at line 604 of file primitives.hpp.
Position of lower corner of cuboid (with minimal all coordinates).
Definition at line 373 of file primitives.hpp.
Position of upper corner of cuboid (with maximal all coordinates).
Definition at line 376 of file primitives.hpp.