|
C3D Toolkit
Kernel - 118052, Vision - 2.14.3.1813
|
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 MbPlacement3D &place, const MbVector3D &dir, MbRect &rect) const |
| A projection onto the placement along a vector in either of two directions. 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 MbCube & | GetCube () 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 > | |
| MbCube & | operator|= (const Point &) |
| Enclose a point. | |
| MbCube & | operator|= (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 > ¶m, 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 > ¶m, 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. | |
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.
|
inline |
The constructor by coordinates.
| [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. |
|
inline |
The constructor by two points.
| [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. |
|
inline |
The check for emptiness.
A bounding box is empty if it doesn't contain any points of 3D-space
|
inline |
Initialize by coordinates.
| [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. |
|
inline |
Initialize by two points.
| [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. |
|
inline |
Initialize by two points.
Initialized box is normalized.
| [in] | p0 | - A point of a box corner with minimal coordinates. |
| [in] | p1 | - A point of a box corner with maximal coordinates. |
| 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.
| [in] | r | - A bounding box. |
| [in] | place | - A local coordinate system. |
| 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.
| [in] | place | - A local coordinate system. |
| [out] | rect | - A rectangle covering a required projection. |
| void MbCube::ProjectionRect | ( | const MbPlacement3D & | place, |
| const MbVector3D & | dir, | ||
| MbRect & | rect | ||
| ) | const |
A projection onto the placement along a vector in either of two directions.
Calculates a rectangle covering a projection of the box onto the placement along a vector in either of two directions.
| [in] | place | - A local coordinate system. |
| [in] | dir | - A direction vector. |
| [out] | rect | - A rectangle covering a required projection. |
| 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.
| [in] | pl | - A local coordinate system which defines a plane. |
| [in] | eps | - A metric tolerance. |
| 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.
| [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. |
|
inline |
Enclose a point specified as XYZ.
| [in] | x,y,z | - Coordinates of a point which has to be included in the box. |
|
inline |
Check whether a point is inside the box or not.
|
inline |
Check whether a point is inside the box or not.
| [in] | eps | - A metric tolerance. |
|
inline |
Check whether a box is inside another box or not.
|
inline |
Check whether a box is inside another box or not.
| bool MbCube::Intersect | ( | const MbCube & | other, |
| double | eps = (c3d::MIN_RADIUS+c3d::MIN_RADIUS) |
||
| ) | const |
Whether the box intersects another box or not.
| [in] | other | - Another box. |
| [in] | eps | - A metric tolerance. |
| 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.
| [in] | pl | - A placement which defines a plane. |
| [in] | eps | - A metric tolerance. |
| 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.
| [in] | eps | - A metric tolerance. |
| 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".
| [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. |
| bool MbCube::Intersect | ( | const MbPlacement3D & | placement, |
| double | radius, | ||
| SArray< double > & | param, | ||
| double | delta = Math::metricRegion |
||
| ) | const |
The intersection of the box with a circle.
| [in] | placement | - A circle placement. |
| [in] | radius | - The circle radius. |
| [out] | param | - Intersection points. |
| [in] | delta | - A metric tolerance. |
| bool MbCube::Intersection | ( | const MbCube & | cube1, |
| const MbCube & | cube2, | ||
| double | eps = c3d::MIN_RADIUS |
||
| ) |
A box of intersection of two boxes.
| [in] | cube1,cube2 | - Input boxes. |
| [in] | eps | - A metric tolerance. |
A box of union of two boxes.
| [in] | cube1,cube2 | - Input boxes. |
|
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.
| [in] | point | - The investigated point. |
| double MbCube::DistanceToCube | ( | const MbCube & | cube, |
| double | eps = Math::metricRegion |
||
| ) | const |
Calculate the distance to the box.
It returns zero if the boxes intersect or one is contained in the other.
| [in] | cube | - Other cube. |
| [in] | eps | - A metric tolerance. |
| size_t MbCube::GetVertices | ( | std::vector< MbCartPoint3D > & | points | ) | const |
Give all vertices of the box.
Give all vertices of the box.
| [out] | points | - Vertices. |
| void MbCube::GetVertex | ( | ptrdiff_t | index, |
| MbCartPoint3D & | p | ||
| ) | const |
Get a box vertex by an index.
| [in] | index | - An initial index. 0 <= index <= 7. |
| [out] | p | - Required vertex. |
| void MbCube::GetEdgeCentre | ( | ptrdiff_t | index, |
| MbCartPoint3D & | p | ||
| ) | const |
Give the center of an edge by an index.
| [in] | index | - An initial index. 0 <= index <= 12 ("general number" minus CUBE_VERTEX_COUNT). |
| [out] | p | - Coordinates of an edge center. |
| void MbCube::GetFaceCentre | ( | ptrdiff_t | index, |
| MbCartPoint3D & | p | ||
| ) | const |
Give the center of a face by an index.
| [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. |
| 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.
| [in] | pIndex | - A number of control points. |
| [out] | p | - Coordinates of control point. |
| 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.
| [out] | points | - Control points. |
| size_t MbCube::GetNearestControlIndex | ( | const MbCartPoint3D & | p | ) | const |
Give the number of the nearest control point of the box.
| [in] | p | - An initial point for which the nearest control point of the box is searched. |
| 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.
| [in] | index | - The number of the initial point. |
| 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".
| [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. |