C3D Toolkit  Kernel - 117982, Vision - 2.9.2.2

The bounding box. More...

#include <mb_cube.h>

+ Collaboration diagram for MbCube:

Public Member Functions

 MbCube ()
 The empty constructor.
 
 MbCube (const MbCube &init)
 Copy constructor.
 
 MbCube (double xmin, double ymin, double zmin, double xmax, double ymax, double zmax, bool normalize=false)
 The constructor by coordinates. More...
 
 MbCube (const MbCartPoint3D &p0, const MbCartPoint3D &p1, bool normalize=false)
 The constructor by two points. More...
 
bool IsEmpty () const
 The check for emptiness. More...
 
void SetEmpty ()
 Set empty ("reverted").
 
void Set (double xmin, double ymin, double zmin, double xmax, double ymax, double zmax, bool normalize=false)
 Initialize by coordinates. More...
 
void Set (const MbCartPoint3D &p0, const MbCartPoint3D &p1, bool normalize=false)
 Initialize by two points. More...
 
void Init (const MbCube &init)
 Initialize by another bounding box.
 
void Init (const MbCartPoint3D &p0, const MbCartPoint3D &p1)
 Initialize by two points. More...
 
void AddRect (const MbRect &r, const MbPlacement3D &place)
 Add bounding box. More...
 
void ProjectionRect (const MbPlacement3D &place, MbRect &rect) const
 A projection onto the placement. More...
 
void ProjectionRect (const MbCurve3D &curve, bool ext, MbRect1D &rect) const
 Calculate a parametric interval of the curve covering the projection of the box on the curve.
 
void Normalize ()
 Normalize itself.
 
MbeItemLocation GetLocation (const MbPlacement3D &pl, double eps) const
 Define the box position relative to the plane. More...
 
bool InsideLocation (const MbPlacement3D &place, MbRect &rect, double eps) const
 Define the box position relative to the tube. More...
 
void Include (double x, double y, double z)
 Enclose a point specified as XYZ. More...
 
template<class Point >
void Include (const Point &)
 Enclose a point.
 
double GetVolume (double eps=Math::metricRegion) const
 Give the volume of a box.
 
double GetSquare (double eps=Math::metricRegion) const
 Give half of the area of the box faces.
 
double GetLengthX () const
 Give the size of the X side of a box.
 
double GetLengthY () const
 Give the size of the Y side of a box.
 
double GetLengthZ () const
 Give the size of the Z side of a box.
 
double GetDiagonal () const
 Give the size of box diagonal.
 
double DistanceToPoint (const MbCartPoint3D &point) const
 Calculate the distance to the nearest boundary of the bounding box. More...
 
double DistanceToPoint2 (const MbCartPoint3D &point) const
 Calculate the square of distance to a point.
 
double DistanceToCube (const MbCube &cube, double eps=Math::metricRegion) const
 Calculate the distance to the box. More...
 
void Enlarge (double delta)
 Expand the box in all directions on a "delta" amount.
 
void Enlarge (double dx, double dy, double dz)
 Expand the box in all directions on a corresponding amount.
 
void Move (const MbVector3D &to)
 Translate along a vector.
 
void Transform (const MbMatrix3D &matrix)
 Transform according to the matrix.
 
void Scale (double sx, double sy, double sz)
 Scale.
 
bool IsSame (const MbCube &other, double accuracy) const
 Determine whether an object is equal?
 
double GetMin (size_t k) const
 Access to a coordinate by an index.
 
double GetMax (size_t k) const
 Access to a coordinate by an index.
 
double GetSideLength (size_t k) const
 Get side length.
 
const MbCubeGetCube () const
 Give itself.
 
size_t GetVerticesCount () const
 Number of vertices.
 
size_t GetVertices (std::vector< MbCartPoint3D > &points) const
 Give all vertices of the box. More...
 
void GetVertex (ptrdiff_t index, MbCartPoint3D &p) const
 Get a box vertex by an index. More...
 
void GetEdgeCentre (ptrdiff_t index, MbCartPoint3D &p) const
 Give the center of an edge by an index. More...
 
void GetFaceCentre (ptrdiff_t index, MbCartPoint3D &p) const
 Give the center of a face by an index. More...
 
void GetCentre (MbCartPoint3D &p) const
 Give the box center.
 
void GetCenter (MbCartPoint3D &p) const
 Give the box center.
 
MbCartPoint3D Centre () const
 The center of bounding box.
 
bool GetControlPoint (size_t pIndex, MbCartPoint3D &p) const
 Give a box control point by its number. More...
 
size_t GetControlPoints (SArray< MbCartPoint3D > &points) const
 Give all control points of the box. More...
 
size_t GetNearestControlIndex (const MbCartPoint3D &p) const
 Give the number of the nearest control point of the box. More...
 
size_t GetFixedControlIndex (size_t index) const
 Give the number of the opposite point. More...
 
bool CalculateMatrix (size_t pIndex, const MbCartPoint3D &point, const MbCartPoint3D &fixedPoint, bool useFixed, bool isotropy, MbMatrix3D &matrix) const
 Calculate a deformation matrix. More...
 
Functions for access to fields.
void SetXMin (double s)
 Set the minimal coordinate by X.
 
void SetYMin (double s)
 Set the minimal coordinate by Y.
 
void SetZMin (double s)
 Set the minimal coordinate by Z.
 
void SetXMax (double s)
 Set the maximal coordinate by X.
 
void SetYMax (double s)
 Set the maximal coordinate by Y.
 
void SetZMax (double s)
 Set the maximal coordinate by Z.
 
double GetXMin () const
 Give the minimal coordinate by X.
 
double GetYMin () const
 Give the minimal coordinate by Y.
 
double GetZMin () const
 Give the minimal coordinate by Z.
 
double GetXMax () const
 Give the maximal coordinate by X.
 
double GetYMax () const
 Give the maximal coordinate by Y.
 
double GetZMax () const
 Give the maximal coordinate by Z.
 
Overload of logical operations.
void operator= (const MbCube &)
 Assign a value.
 
template<class Point >
MbCubeoperator|= (const Point &)
 Enclose a point.
 
MbCubeoperator|= (const MbCube &)
 Enclose a bounding box.
 
bool operator== (const MbCube &) const
 The equality operator.
 
bool operator!= (const MbCube &) const
 The inequality operator.
 
The boolean operations of a box with a point, line, plane and another box.
template<class Point >
bool Contains (const Point &) const
 Check whether a point is inside the box or not. More...
 
template<class Point >
bool Contains (const Point &, double eps) const
 Check whether a point is inside the box or not. More...
 
bool Contains (const MbCube &) const
 Check whether a box is inside another box or not. More...
 
bool Contains (const MbCube &, double eps) const
 Check whether a box is inside another box or not. More...
 
bool Intersect (const MbCube &other, double eps=(c3d::MIN_RADIUS+c3d::MIN_RADIUS)) const
 Whether the box intersects another box or not. More...
 
bool Intersect (const MbPlacement3D &pl, double eps=c3d::MIN_RADIUS) const
 Whether the box intersects the XY plane of a local coordinate system or not. More...
 
bool Intersect (const MbCartPoint3D &, const MbVector3D &, double eps=Math::metricRegion) const
 Whether the box intersects the line or not. More...
 
bool Intersect (const MbCartPoint3D &p, const MbVector3D &axis, SArray< double > &param, double delta=Math::metricRegion) const
 Find an intersection of a line with the box "surface". More...
 
bool Intersect (const MbPlacement3D &placement, double radius, SArray< double > &param, double delta=Math::metricRegion) const
 The intersection of the box with a circle. More...
 
bool Intersection (const MbCube &cube1, const MbCube &cube2, double eps=c3d::MIN_RADIUS)
 A box of intersection of two boxes. More...
 
bool Union (const MbCube &cube1, const MbCube &cube2)
 A box of union of two boxes. More...
 

Static Public Member Functions

static size_t GetDimension ()
 The number of point coordinates.
 

Public Attributes

MbCartPoint3D pmin
 A point of a box diagonal with minimal coordinates.
 
MbCartPoint3D pmax
 A point of a box diagonal with maximal coordinates.
 

Detailed Description

The bounding box.

The bounding box is a domain (block) of 3D-space bounded by parallelepiped with edges parallel to the axes of coordinate system.
It is used for quick estimation of the proximity or non-intersection of three-dimensional objects, which are contained in the "box". Faces of "box" are parallel to planes of coordinate system. The bounding box is described by a pair of points which are located on the main diagonal of a box.

Constructor & Destructor Documentation

◆ MbCube() [1/2]

MbCube::MbCube ( double  xmin,
double  ymin,
double  zmin,
double  xmax,
double  ymax,
double  zmax,
bool  normalize = false 
)
inline

The constructor by coordinates.

Parameters
[in]xmin,ymin,zmin- Coordinates of a box corner point with minimal coordinates.
[in]xmax,ymax,zmax- Coordinates of a box corner point with maximal coordinates.
[in]normalize- Normalize itself.

◆ MbCube() [2/2]

MbCube::MbCube ( const MbCartPoint3D p0,
const MbCartPoint3D p1,
bool  normalize = false 
)
inline

The constructor by two points.

Parameters
[in]p0- A point of a box corner with minimal coordinates.
[in]p1- A point of a box corner with maximal coordinates.
[in]normalize- Normalize itself.

Member Function Documentation

◆ IsEmpty()

bool MbCube::IsEmpty ( ) const
inline

The check for emptiness.

A bounding box is empty if it doesn't contain any points of 3D-space

◆ Set() [1/2]

void MbCube::Set ( double  xmin,
double  ymin,
double  zmin,
double  xmax,
double  ymax,
double  zmax,
bool  normalize = false 
)
inline

Initialize by coordinates.

Parameters
[in]xmin,ymin,zmin- Coordinates of a box corner point with minimal coordinates.
[in]xmax,ymax,zmax- Coordinates of a box corner point with maximal coordinates.
[in]normalize- Normalize itself.

◆ Set() [2/2]

void MbCube::Set ( const MbCartPoint3D p0,
const MbCartPoint3D p1,
bool  normalize = false 
)
inline

Initialize by two points.

Parameters
[in]p0- A point of a box corner with minimal coordinates.
[in]p1- A point of a box corner with maximal coordinates.
[in]normalize- Normalize itself.

◆ Init()

void MbCube::Init ( const MbCartPoint3D p0,
const MbCartPoint3D p1 
)
inline

Initialize by two points.

Initialized box is normalized.

Parameters
[in]p0- A point of a box corner with minimal coordinates.
[in]p1- A point of a box corner with maximal coordinates.

◆ AddRect()

void MbCube::AddRect ( const MbRect r,
const MbPlacement3D place 
)

Add bounding box.

A bounding box is added in the local coordinate system of the initial box.

Parameters
[in]r- A bounding box.
[in]place- A local coordinate system.

◆ ProjectionRect()

void MbCube::ProjectionRect ( const MbPlacement3D place,
MbRect rect 
) const

A projection onto the placement.

Calculates a rectangle covering a projection of the box onto the placement.

Parameters
[in]place- A local coordinate system.
[out]rect- A rectangle covering a required projection.

◆ GetLocation()

MbeItemLocation MbCube::GetLocation ( const MbPlacement3D pl,
double  eps 
) const

Define the box position relative to the plane.

Define the box position relative to the plane XY of a local coordinate system, the Z axis of the local coordinate system is not taken into account here.

Parameters
[in]pl- A local coordinate system which defines a plane.
[in]eps- A metric tolerance.
Returns
Iloc_OnItem - box intersects the XY plane of a local coordinate system,
iloc_InItem - box is located over the XY plane of a local coordinate system,
iloc_OutOfItem - box is located under the XY plane of a local coordinate system.

◆ InsideLocation()

bool MbCube::InsideLocation ( const MbPlacement3D place,
MbRect rect,
double  eps 
) const

Define the box position relative to the tube.

Determine whether the box is inside the tube of rectangular section, given by a rectangle in the XY plane of a local coordinate system.

Parameters
[in]place- A local coordinate system in the XY plane of which a tube section is located.
[in]rect- A rectangle which defines a tube section.
[in]eps- A metric tolerance.
Returns
Returns true if the box is inside the tube.

◆ Include()

void MbCube::Include ( double  x,
double  y,
double  z 
)
inline

Enclose a point specified as XYZ.

Parameters
[in]x,y,z- Coordinates of a point which has to be included in the box.

◆ Contains() [1/4]

template<class Point >
bool MbCube::Contains ( const Point &  p) const
inline

Check whether a point is inside the box or not.

Returns
Returns true if it is inside.

◆ Contains() [2/4]

template<class Point >
bool MbCube::Contains ( const Point &  p,
double  eps 
) const
inline

Check whether a point is inside the box or not.

Parameters
[in]eps- A metric tolerance.
Returns
Returns true if it is inside.

◆ Contains() [3/4]

bool MbCube::Contains ( const MbCube box) const
inline

Check whether a box is inside another box or not.

Returns
Returns true if a box contains another.

◆ Contains() [4/4]

bool MbCube::Contains ( const MbCube box,
double  eps 
) const
inline

Check whether a box is inside another box or not.

Returns
Returns true if a box contains another.

◆ Intersect() [1/5]

bool MbCube::Intersect ( const MbCube other,
double  eps = (c3d::MIN_RADIUS+c3d::MIN_RADIUS) 
) const

Whether the box intersects another box or not.

Parameters
[in]other- Another box.
[in]eps- A metric tolerance.
Returns
Returns true if it intersects.

◆ Intersect() [2/5]

bool MbCube::Intersect ( const MbPlacement3D pl,
double  eps = c3d::MIN_RADIUS 
) const

Whether the box intersects the XY plane of a local coordinate system or not.

Parameters
[in]pl- A placement which defines a plane.
[in]eps- A metric tolerance.
Returns
Returns true if it intersects.

◆ Intersect() [3/5]

bool MbCube::Intersect ( const MbCartPoint3D ,
const MbVector3D ,
double  eps = Math::metricRegion 
) const

Whether the box intersects the line or not.

A line is given by a point and vector.

Parameters
[in]eps- A metric tolerance.
Returns
Returns true if it intersects.

◆ Intersect() [4/5]

bool MbCube::Intersect ( const MbCartPoint3D p,
const MbVector3D axis,
SArray< double > &  param,
double  delta = Math::metricRegion 
) const

Find an intersection of a line with the box "surface".

Parameters
[in]p- The point on the line.
[in]axis- A vector which defines the direction of the line.
[out]param- Intersection points.
[in]delta- A metric tolerance.
Returns
Returns true if intersection exists,
false otherwise.

◆ Intersect() [5/5]

bool MbCube::Intersect ( const MbPlacement3D placement,
double  radius,
SArray< double > &  param,
double  delta = Math::metricRegion 
) const

The intersection of the box with a circle.

Parameters
[in]placement- A circle placement.
[in]radius- The circle radius.
[out]param- Intersection points.
[in]delta- A metric tolerance.
Returns
Returns true if intersection exists,
false otherwise.

◆ Intersection()

bool MbCube::Intersection ( const MbCube cube1,
const MbCube cube2,
double  eps = c3d::MIN_RADIUS 
)

A box of intersection of two boxes.

Parameters
[in]cube1,cube2- Input boxes.
[in]eps- A metric tolerance.
Returns
Returns true if intersection exists,
false otherwise.

◆ Union()

bool MbCube::Union ( const MbCube cube1,
const MbCube cube2 
)

A box of union of two boxes.

Parameters
[in]cube1,cube2- Input boxes.
Returns
Returns false if the result box is empty,
true otherwise.

◆ DistanceToPoint()

double MbCube::DistanceToPoint ( const MbCartPoint3D point) const
inline

Calculate the distance to the nearest boundary of the bounding box.

The calculated distance is negative if the point is inside, and is positive if it is outside.

Parameters
[in]point- The investigated point.
Returns
Returns the distance to the boundary.

◆ DistanceToCube()

double MbCube::DistanceToCube ( const MbCube cube,
double  eps = Math::metricRegion 
) const

Calculate the distance to the box.

It returns zero if the boexs intersect or one is contained in the other.

Parameters
[in]cube- Other cube.
[in]eps- A metric tolerance.
Returns
Returns the distance to the boundary.

◆ GetVertices()

size_t MbCube::GetVertices ( std::vector< MbCartPoint3D > &  points) const

Give all vertices of the box.

Give all vertices of the box.

Parameters
[out]points- Vertices.
Returns
The number of vertices. Null if the box is empty.

◆ GetVertex()

void MbCube::GetVertex ( ptrdiff_t  index,
MbCartPoint3D p 
) const

Get a box vertex by an index.

Parameters
[in]index- An initial index. 0 <= index <= 7.
[out]p- Required vertex.

◆ GetEdgeCentre()

void MbCube::GetEdgeCentre ( ptrdiff_t  index,
MbCartPoint3D p 
) const

Give the center of an edge by an index.

Parameters
[in]index- An initial index. 0 <= index <= 12 ("general number" minus CUBE_VERTEX_COUNT).
[out]p- Coordinates of an edge center.

◆ GetFaceCentre()

void MbCube::GetFaceCentre ( ptrdiff_t  index,
MbCartPoint3D p 
) const

Give the center of a face by an index.

Parameters
[in]index- An initial index. 0 <= index <= 5 ("general number" minus CUBE_VERTEX_COUNT minus CUBE_EDGES_COUNT).
[out]p- Coordinates of an edge center.

◆ GetControlPoint()

bool MbCube::GetControlPoint ( size_t  pIndex,
MbCartPoint3D p 
) const

Give a box control point by its number.

General numeration of box control points: 0-7 vertices, 8-19 middles of edges, 20-25 centers of faces.

Parameters
[in]pIndex- A number of control points.
[out]p- Coordinates of control point.
Returns
Returns false if the box is empty or the index has an invalid value,
true otherwise.

◆ GetControlPoints()

size_t MbCube::GetControlPoints ( SArray< MbCartPoint3D > &  points) const

Give all control points of the box.

All control points of the box: 8 vertices, 12 middles of edges, 6 centers of faces.

Parameters
[out]points- Control points.
Returns
The number of control points. Null if the box is empty.

◆ GetNearestControlIndex()

size_t MbCube::GetNearestControlIndex ( const MbCartPoint3D p) const

Give the number of the nearest control point of the box.

Parameters
[in]p- An initial point for which the nearest control point of the box is searched.
Returns
A number of a point.

◆ GetFixedControlIndex()

size_t MbCube::GetFixedControlIndex ( size_t  index) const

Give the number of the opposite point.

For a box point with the "index" number give the number of the opposite point, which can be used as fixed.

Parameters
[in]index- The number of the initial point.
Returns
A number of the opposite point.

◆ CalculateMatrix()

bool MbCube::CalculateMatrix ( size_t  pIndex,
const MbCartPoint3D point,
const MbCartPoint3D fixedPoint,
bool  useFixed,
bool  isotropy,
MbMatrix3D matrix 
) const

Calculate a deformation matrix.

A deformation matrix is calculated according to the new position of box control point "point" with the index "pIndex".

Parameters
[in]pIndex- A number of a moved point (0-7 vertices, 8-19 middles of edges, 20-25 centers of faces).
[in]point- A point with which the box point with the "pIndex" number has to be joined.
[in]fixedPoint- A fixed point. It is used if useFixed = true.
[in]useFixed- Use a fixed point (true); if useFixed = false, then the opposite point of the box will be fixed.
[in]isotropy- The same scales of the axes (true); the scales are proportional to the shift projections of the considered point on the sides of the box (false)
[out]matrix- Calculated transformation matrix.
Returns
Returns true if the matrix was found.

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