PLaSK library
Loading...
Searching...
No Matches
plask::Box3D Struct Reference

Cuboid class. More...

#include <plask/geometry/primitives.hpp>

Public Member Functions

constexpr Vec< 3, doublesize () 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, doublecenter () 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.
 
Box3Doperator+= (const Vec< 3, double > &translation_vec)
 Translate this by translation_vec.
 
Box3Doperator-= (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, doublemoveInside (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 doubleback () const
 Return back edge of the box.
 
doubleback ()
 Return back edge of the box.
 
const doublefront () const
 Return front edge of the box.
 
doublefront ()
 Return front edge of the box.
 
const doubleleft () const
 Return left edge of the box.
 
doubleleft ()
 Return left edge of the box.
 
const doubleright () const
 Return right edge of the box.
 
doubleright ()
 Return right edge of the box.
 
const doublebottom () const
 Return bottom edge of the box.
 
doublebottom ()
 Return bottom edge of the box.
 
const doubletop () const
 Return top edge of the box.
 
doubletop ()
 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, doublelower
 Position of lower corner of cuboid (with minimal all coordinates).
 
Vec< 3, doubleupper
 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 371 of file primitives.hpp.

Constructor & Destructor Documentation

◆ Box3D() [1/3]

plask::Box3D::Box3D ( )
inline

Construct uninitialized .

Definition at line 409 of file primitives.hpp.

◆ Box3D() [2/3]

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

Construct with given lower and upper corner positions.

Parameters
lowerposition of lower corner of cuboid (with minimal all coordinates)
upperposition of upper corner of cuboid (with maximal all coordinates)

Definition at line 416 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 
)
inlineconstexpr

Construct box.

Parameters
x_lo,y_lo,z_lolower corner of box (with minimal all coordinates)
x_up,y_up,z_upupper corner of box (with maximal all coordinates)

Definition at line 423 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 668 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 662 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 716 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 710 of file primitives.hpp.

◆ center()

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

Calculate center point.

Returns
center of the box

Definition at line 406 of file primitives.hpp.

◆ contains()

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

Check if point is inside box.

Parameters
ppoint
Returns
true only if point is inside this box

Definition at line 111 of file primitives.cpp.

◆ depth()

constexpr double plask::Box3D::depth ( ) const
inlineconstexpr

Calculate depth of this.

Returns
width of the box

Definition at line 400 of file primitives.hpp.

◆ extension()

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

Get the minimal box which include this and other box.

Parameters
otherbox
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
flipDirnumber of coordinate

Definition at line 639 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
inumber of coordinate
Returns
box similar to this but with mirrored i-th coordinate

Definition at line 652 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 680 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 674 of file primitives.hpp.

◆ getArea()

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

Calculate area of the box.

Returns
area of the box

Definition at line 629 of file primitives.hpp.

◆ getBack()

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

Definition at line 737 of file primitives.hpp.

◆ getBottom()

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

Definition at line 741 of file primitives.hpp.

◆ getFront()

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

Definition at line 738 of file primitives.hpp.

◆ getLeft()

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

Definition at line 739 of file primitives.hpp.

◆ getRight()

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

Definition at line 740 of file primitives.hpp.

◆ getTop()

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

Definition at line 742 of file primitives.hpp.

◆ height()

constexpr double plask::Box3D::height ( ) const
inlineconstexpr

Calculate size of this in up direction.

Returns
upper.vert() - lower.up

Definition at line 388 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
otherbox 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
otherbox
Returns
true only if this and other have common points

Definition at line 117 of file primitives.cpp.

◆ invalidInstance()

static Box3D plask::Box3D::invalidInstance ( )
inlinestatic

Definition at line 426 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 614 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 692 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 686 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
otherpoint 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
otherpoint 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
ppoint 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
otherbox 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 620 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
pgiven 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
rbox 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_vectranslation vector
Returns
this translated by translation_vec

Definition at line 512 of file primitives.hpp.

◆ operator+=()

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

Translate this by translation_vec.

Parameters
translation_vectranslation vector

Definition at line 549 of file primitives.hpp.

◆ operator-()

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

Get translated copy of this.

Parameters
translation_vectranslation vector
Returns
this translated by translation_vec

Definition at line 521 of file primitives.hpp.

◆ operator-=()

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

Translate this by translation_vec.

Parameters
translation_vectranslation vector

Definition at line 559 of file primitives.hpp.

◆ operator==()

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

Compare two boxes, this and r.

Parameters
rbox 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 704 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 698 of file primitives.hpp.

◆ setBack()

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

Definition at line 730 of file primitives.hpp.

◆ setBottom()

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

Definition at line 734 of file primitives.hpp.

◆ setFront()

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

Definition at line 731 of file primitives.hpp.

◆ setLeft()

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

Definition at line 732 of file primitives.hpp.

◆ setRight()

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

Definition at line 733 of file primitives.hpp.

◆ setTop()

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

Definition at line 735 of file primitives.hpp.

◆ size()

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

Calculate size of this.

Returns
upper - lower

Definition at line 382 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 728 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 722 of file primitives.hpp.

◆ translate()

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

Translate this by translation_vec.

Parameters
translation_vectranslation vector

Definition at line 540 of file primitives.hpp.

◆ translated()

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

Get translated copy of this.

Parameters
translation_vectranslation vector
Returns
this translated by translation_vec

Definition at line 503 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_indexdirection index, 0, 1 or 2
trasnalation_in_dirtranslation in dir_index direction

Definition at line 579 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_dirtranslation in up direction
Returns
this translated up by trasnalation_in_up_dir

Definition at line 530 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_dirtranslation in up direction

Definition at line 569 of file primitives.hpp.

◆ width()

constexpr double plask::Box3D::width ( ) const
inlineconstexpr

Calculate width of this.

Returns
width of the box

Definition at line 394 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
outprint destination, output stream
to_printbox to print
Returns
out stream

Definition at line 604 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 373 of file primitives.hpp.

◆ upper

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

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

Definition at line 376 of file primitives.hpp.


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