Defines a 3D axis-aligned bounding box. More...
#include <cadex/ModelData/Box.hxx>
Public Member Functions | |
Box () | |
Constructor. | |
Box (const Geom::Point &theCorner1, const Geom::Point &theCorner2) | |
Constructor. | |
const Geom::Point & | MinCorner () const |
const Geom::Point & | MaxCorner () const |
const Geom::Point & | Corner (size_t theIdx) const |
Returns one of the bounding box corners. | |
Geom::Point | Center () const |
Returns a center point. | |
void | Add (const Geom::Point &thePoint) |
Adjusts the box corners so that it contains thePoint. | |
void | Add (const Box &theBox) |
Adjusts the box corners so that it contains theBox. | |
void | Clear () |
Resets the box. | |
void | SetXRange (double theMin, double theMax) |
Sets the range of box along X axis to the specified values. | |
void | SetYRange (double theMin, double theMax) |
Sets the range of box along Y axis to the specified values. | |
void | SetZRange (double theMin, double theMax) |
Sets the range of box along Z axis to the specified values. | |
void | SetRange (size_t theIdx, double theMin, double theMax) |
Sets one range of the box to the specified values. | |
double | XRange () const |
Returns the length of range along X axis. | |
double | YRange () const |
Returns the length of range along Y axis. | |
double | ZRange () const |
Returns the length of range along Z axis. | |
double | Range (size_t theIndex) const |
Returns the length of range along specified axis. | |
void | Enlarge (double theX, double theY, double theZ) |
Enlarge the box dimensions by specified values. | |
void | Enlarge (double theSize) |
Enlarge the box dimensions by specified value. | |
Box | Enlarged (double theX, double theY, double theZ) const |
Return the box with dimensions enlarged by specified values. | |
Box | Enlarged (double theSize) const |
Return the box with dimensions enlarged by specified value. | |
bool | IsIn (const Geom::Point &thePoint) const |
Returns true if the point lies inside the box. | |
bool | Intersects (const Box &theOther) const |
Returns the other box has at least one common point with this box. | |
bool | IsInfinite () const |
Returns true if at least one coordinate is infinite. | |
void | Multiply (double theValue) |
Scales box by scalar value. | |
Box | Multiplied (double theValue) const |
Returns the box scaled by scalar value. | |
void | Transform (const Geom::Transformation &theTransformation) |
Transforms the box. | |
Box | Transformed (const Geom::Transformation &theTransformation) const |
Returns the transformed box. | |
Defines a 3D axis-aligned bounding box.
The box is defined via two corners - MinCorner() and MaxCorner() - containing minimum and maximum coordinates respectively.
cadex::ModelData::Box::Box | ( | ) |
Constructor.
Creates a box with infinite boundaries.
cadex::ModelData::Box::Box | ( | const Geom::Point & | theCorner1, |
const Geom::Point & | theCorner2 ) |
Constructor.
Creates a box from 2 points. Minimum corner is determined from the minimum values for each coordinate in the given points. Maximum corner is determined from the maximum values.
void cadex::ModelData::Box::Add | ( | const Geom::Point & | thePoint | ) |
Adjusts the box corners so that it contains thePoint.
Takes into account only finite coordinates of thePoint (those whose absolute value is less than \(10^{100}\)).
Geom::Point cadex::ModelData::Box::Center | ( | ) | const |
Returns a center point.
Returns a middle of the diagonal between MinCorner() and MaxCorner().
void cadex::ModelData::Box::Clear | ( | ) |
Resets the box.
Assigns infinite values to the coordinates, so that IsInfinite() returns true.
const Geom::Point & cadex::ModelData::Box::Corner | ( | size_t | theIdx | ) | const |
Returns one of the bounding box corners.
Corner | Index |
---|---|
Minimum corner | 0 |
Maximum corner | 1 |
void cadex::ModelData::Box::Enlarge | ( | double | theSize | ) |
Enlarge the box dimensions by specified value.
Each box extent is shifted by \(\frac{1}{2}\cdot\mathrm{theSize}\) to the negative and positive side along respective axis.
void cadex::ModelData::Box::Enlarge | ( | double | theX, |
double | theY, | ||
double | theZ ) |
Enlarge the box dimensions by specified values.
Each box extent is shifted by \(\frac{1}{2}\) of the specified shift value to the negative and positive side along respective axis.
Box cadex::ModelData::Box::Enlarged | ( | double | theSize | ) | const |
Return the box with dimensions enlarged by specified value.
Each box extent of the result is shifted by \(\frac{1}{2}\cdot\mathrm{theSize}\) to the negative and positive side along respective axis compared to the original.
Box cadex::ModelData::Box::Enlarged | ( | double | theX, |
double | theY, | ||
double | theZ ) const |
Return the box with dimensions enlarged by specified values.
Each box extent of the result is shifted by \(\frac{1}{2}\) of the specified shift value to the negative and positive side along respective axis compared to the original.
bool cadex::ModelData::Box::IsInfinite | ( | ) | const |
Returns true if at least one coordinate is infinite.
"Infinite" means that coordinate's absolute value is greater than \(10^{100}\).
void cadex::ModelData::Box::Multiply | ( | double | theValue | ) |
Scales box by scalar value.
Performs the scaling transformation of all the points of the box in the form:
\[ P'=\mathrm{theValue}\; P \]
where \(P\) and \(P'\) are the box points before and after transformation respectively and \(\mathrm{theValue}\) is the scale factor.
void cadex::ModelData::Box::SetRange | ( | size_t | theIdx, |
double | theMin, | ||
double | theMax ) |
Sets one range of the box to the specified values.
Range axis | Index |
---|---|
X | 0 |
Y | 1 |
Z | 2 |
void cadex::ModelData::Box::Transform | ( | const Geom::Transformation & | theTransformation | ) |
Transforms the box.
If the transformation does not contain anything besides perhaps a translation, the box dimensions are kept as is and its position is recalcuated accordingly.
If rotation or scale are present, all box corners are transformed and a new axis-aligned box containing them is built. If the box was infinite in one of the directions, the new box will also be infinite in the directions that are results of applying the transformation to the original directions. The new box most likely has larger dimensions than the original.
For more accurate results, it's recommended instead to transform the arguments the box was built from and only then calculate the box.