OCCT3D OCCT 8.0.1
OCCT documentation

Search guides and API reference

Enter at least two characters.

    Open CASCADE Technology Reference Manual 8.0.1
    Bnd_Box Class Reference

    Describes a bounding box in 3D space. A bounding box is parallel to the axes of the coordinates system. If it is finite, it is defined by the three intervals: More...

    #include <Bnd_Box.hxx>

    Data Structures

    struct  Limits
     Structure containing the box limits (Xmin, Xmax, Ymin, Ymax, Zmin, Zmax). The values include the gap and account for open directions. More...

    Public Member Functions

    constexpr Bnd_Box () noexcept=default
     Creates an empty Box. The constructed box is qualified Void. Its gap is null.
    constexpr Bnd_Box (const gp_Pnt &theMin, const gp_Pnt &theMax)
     Creates a bounding box, it contains:
    void SetWhole () noexcept
     Sets this bounding box so that it covers the whole of 3D space. It is infinitely long in all directions.
    void SetVoid () noexcept
     Sets this bounding box so that it is empty. All points are outside a void box.
    void Set (const gp_Pnt &P)
     Sets this bounding box so that it bounds.
    void Set (const gp_Pnt &P, const gp_Dir &D)
     Sets this bounding box so that it bounds the half-line defined by point P and direction D, i.e. all points M defined by M=P+u*D, where u is greater than or equal to 0, are inside the bounding volume. This involves first setting this box to be void and then adding the half-line.
    void Update (const double aXmin, const double aYmin, const double aZmin, const double aXmax, const double aYmax, const double aZmax)
     Enlarges this bounding box, if required, so that it contains at least:
    void Update (const double X, const double Y, const double Z)
     Adds a point of coordinates (X,Y,Z) to this bounding box.
    constexpr double GetGap () const noexcept
     Returns the gap of this bounding box.
    void SetGap (const double Tol) noexcept
     Set the gap of this bounding box to abs(Tol).
    void Enlarge (const double Tol) noexcept
     Enlarges the box with a tolerance value. (minvalues-std::abs(<tol>) and maxvalues+std::abs(<tol>)) This means that the minimum values of its X, Y and Z intervals of definition, when they are finite, are reduced by the absolute value of Tol, while the maximum values are increased by the same amount.
    void Get (double &theXmin, double &theYmin, double &theZmin, double &theXmax, double &theYmax, double &theZmax) const
     Returns the bounds of this bounding box. The gap is included. If this bounding box is infinite (i.e. "open"), returned values may be equal to +/- Precision::Infinite(). Standard_ConstructionError exception will be thrown if the box is void. if IsVoid().
    Limits Get () const
     Returns the bounds of this bounding box as a Limits structure. The gap is included. If this bounding box is infinite (i.e. "open"), returned values may be equal to +/- Precision::Infinite(). If the box is void, returns raw internal values. Can be used with C++17 structured bindings:
    double GetXMin () const
     Returns the Xmin value (IsOpenXmin() ? -Precision::Infinite() : Xmin - GetGap()).
    double GetXMax () const
     Returns the Xmax value (IsOpenXmax() ? Precision::Infinite() : Xmax + GetGap()).
    double GetYMin () const
     Returns the Ymin value (IsOpenYmin() ? -Precision::Infinite() : Ymin - GetGap()).
    double GetYMax () const
     Returns the Ymax value (IsOpenYmax() ? Precision::Infinite() : Ymax + GetGap()).
    double GetZMin () const
     Returns the Zmin value (IsOpenZmin() ? -Precision::Infinite() : Zmin - GetGap()).
    double GetZMax () const
     Returns the Zmax value (IsOpenZmax() ? Precision::Infinite() : Zmax + GetGap()).
    gp_Pnt CornerMin () const
     Returns the lower corner of this bounding box. The gap is included. If this bounding box is infinite (i.e. "open"), returned values may be equal to +/- Precision::Infinite(). Standard_ConstructionError exception will be thrown if the box is void. if IsVoid().
    gp_Pnt CornerMax () const
     Returns the upper corner of this bounding box. The gap is included. If this bounding box is infinite (i.e. "open"), returned values may be equal to +/- Precision::Infinite(). Standard_ConstructionError exception will be thrown if the box is void. if IsVoid().
    std::optional< gp_PntCenter () const
     Returns the center of this bounding box. The gap is included. If this bounding box is infinite (i.e. "open"), returned values may be equal to +/- Precision::Infinite(). Returns std::nullopt if the box is void.
    void OpenXmin () noexcept
     The Box will be infinitely long in the Xmin direction.
    void OpenXmax () noexcept
     The Box will be infinitely long in the Xmax direction.
    void OpenYmin () noexcept
     The Box will be infinitely long in the Ymin direction.
    void OpenYmax () noexcept
     The Box will be infinitely long in the Ymax direction.
    void OpenZmin () noexcept
     The Box will be infinitely long in the Zmin direction.
    void OpenZmax () noexcept
     The Box will be infinitely long in the Zmax direction.
    bool IsOpen () const noexcept
     Returns true if this bounding box has at least one open direction.
    bool IsOpenXmin () const noexcept
     Returns true if this bounding box is open in the Xmin direction.
    bool IsOpenXmax () const noexcept
     Returns true if this bounding box is open in the Xmax direction.
    bool IsOpenYmin () const noexcept
     Returns true if this bounding box is open in the Ymin direction.
    bool IsOpenYmax () const noexcept
     Returns true if this bounding box is open in the Ymax direction.
    bool IsOpenZmin () const noexcept
     Returns true if this bounding box is open in the Zmin direction.
    bool IsOpenZmax () const noexcept
     Returns true if this bounding box is open in the Zmax direction.
    bool IsWhole () const noexcept
     Returns true if this bounding box is infinite in all 6 directions (WholeSpace flag).
    bool IsVoid () const noexcept
     Returns true if this bounding box is empty (Void flag).
    bool IsXThin (const double tol) const
     true if xmax-xmin < tol.
    bool IsYThin (const double tol) const
     true if ymax-ymin < tol.
    bool IsZThin (const double tol) const
     true if zmax-zmin < tol.
    bool IsThin (const double tol) const
     Returns true if IsXThin, IsYThin and IsZThin are all true, i.e. if the box is thin in all three dimensions.
    Bnd_Box Transformed (const gp_Trsf &T) const
     Returns a bounding box which is the result of applying the transformation T to this bounding box. Warning Applying a geometric transformation (for example, a rotation) to a bounding box generally increases its dimensions. This is not optimal for algorithms which use it.
    void Add (const Bnd_Box &Other)
     Adds the box <Other> to <me>.
    void Add (const gp_Pnt &P)
     Adds a Pnt to the box.
    void Add (const gp_Pnt &P, const gp_Dir &D)
     Extends <me> from the Pnt.
    void Add (const gp_Dir &D)
     Extends the Box in the given Direction, i.e. adds an half-line. The box may become infinite in 1,2 or 3 directions.
    bool IsOut (const gp_Pnt &P) const
     Returns True if the Pnt is out the box.
    bool IsOut (const gp_Lin &L) const
     Returns False if the line intersects the box.
    bool IsOut (const gp_Pln &P) const
     Returns False if the plane intersects the box.
    bool IsOut (const Bnd_Box &Other) const
     Returns False if the <Box> intersects or is inside <me>.
    bool IsOut (const Bnd_Box &Other, const gp_Trsf &T) const
     Returns False if the transformed <Box> intersects or is inside <me>.
    bool IsOut (const gp_Trsf &T1, const Bnd_Box &Other, const gp_Trsf &T2) const
     Returns False if the transformed <Box> intersects or is inside the transformed box <me>.
    bool IsOut (const gp_Pnt &P1, const gp_Pnt &P2, const gp_Dir &D) const
     Returns False if the flat band lying between two parallel lines represented by their reference points <P1>, <P2> and direction <D> intersects the box.
    bool Contains (const gp_Pnt &theP) const
     Returns True if the point is inside or on the boundary of this box.
    bool Intersects (const Bnd_Box &theOther) const
     Returns True if the other box intersects or is inside this box.
    double Distance (const Bnd_Box &Other) const
     Computes the minimum distance between two boxes.
    void Dump () const
    double SquareExtent () const noexcept
     Computes the squared diagonal of me.
    Bnd_Box FinitePart () const noexcept
     Returns a finite part of an infinite bounding box (returns self if this is already finite box). This can be a Void box in case if its sides has been defined as infinite (Open) without adding any finite points. WARNING! This method relies on Open flags, the infinite points added using Add() method will be returned as is.
    bool HasFinitePart () const noexcept
     Returns TRUE if this box has finite part.
    void DumpJson (Standard_OStream &theOStream, int theDepth=-1) const
     Dumps the content of me into the stream.
    bool InitFromJson (const Standard_SStream &theSStream, int &theStreamPos)
     Inits the content of me from the stream.

    Protected Types

    enum  MaskFlags {
      VoidMask = 0x01 , XminMask = 0x02 , XmaxMask = 0x04 , YminMask = 0x08 ,
      YmaxMask = 0x10 , ZminMask = 0x20 , ZmaxMask = 0x40 , WholeMask = 0x7e
    }
     Bit flags. More...

    Detailed Description

    Describes a bounding box in 3D space. A bounding box is parallel to the axes of the coordinates system. If it is finite, it is defined by the three intervals:

    • [ Xmin,Xmax ],
    • [ Ymin,Ymax ],
    • [ Zmin,Zmax ]. A bounding box may be infinite (i.e. open) in one or more directions. It is said to be:
    • OpenXmin if it is infinite on the negative side of the "X Direction";
    • OpenXmax if it is infinite on the positive side of the "X Direction";
    • OpenYmin if it is infinite on the negative side of the "Y Direction";
    • OpenYmax if it is infinite on the positive side of the "Y Direction";
    • OpenZmin if it is infinite on the negative side of the "Z Direction";
    • OpenZmax if it is infinite on the positive side of the "Z Direction";
    • WholeSpace if it is infinite in all six directions. In this case, any point of the space is inside the box;
    • Void if it is empty. In this case, there is no point included in the box. A bounding box is defined by:
    • six bounds (Xmin, Xmax, Ymin, Ymax, Zmin and Zmax) which limit the bounding box if it is finite,
    • eight flags (OpenXmin, OpenXmax, OpenYmin, OpenYmax, OpenZmin, OpenZmax, WholeSpace and Void) which describe the bounding box if it is infinite or empty, and
    • a gap, which is included on both sides in any direction when consulting the finite bounds of the box.

    Member Enumeration Documentation

    ◆ MaskFlags

    enum Bnd_Box::MaskFlags
    protected

    Bit flags.

    Enumerator
    VoidMask 
    XminMask 
    XmaxMask 
    YminMask 
    YmaxMask 
    ZminMask 
    ZmaxMask 
    WholeMask 

    Constructor & Destructor Documentation

    ◆ Bnd_Box() [1/2]

    Bnd_Box::Bnd_Box ( )
    constexprdefaultnoexcept

    Creates an empty Box. The constructed box is qualified Void. Its gap is null.

    ◆ Bnd_Box() [2/2]

    Bnd_Box::Bnd_Box ( const gp_Pnt & theMin,
    const gp_Pnt & theMax )
    inlineconstexpr

    Creates a bounding box, it contains:

    • minimum/maximum point of bounding box, The constructed box is qualified Void. Its gap is null.

    Member Function Documentation

    ◆ Add() [1/4]

    void Bnd_Box::Add ( const Bnd_Box & Other)

    Adds the box <Other> to <me>.

    ◆ Add() [2/4]

    void Bnd_Box::Add ( const gp_Dir & D)

    Extends the Box in the given Direction, i.e. adds an half-line. The box may become infinite in 1,2 or 3 directions.

    ◆ Add() [3/4]

    void Bnd_Box::Add ( const gp_Pnt & P)

    Adds a Pnt to the box.

    ◆ Add() [4/4]

    void Bnd_Box::Add ( const gp_Pnt & P,
    const gp_Dir & D )

    Extends <me> from the Pnt.

    in the direction <D>.

    ◆ Center()

    std::optional< gp_Pnt > Bnd_Box::Center ( ) const
    nodiscard

    Returns the center of this bounding box. The gap is included. If this bounding box is infinite (i.e. "open"), returned values may be equal to +/- Precision::Infinite(). Returns std::nullopt if the box is void.

    ◆ Contains()

    bool Bnd_Box::Contains ( const gp_Pnt & theP) const
    inlinenodiscard

    Returns True if the point is inside or on the boundary of this box.

    ◆ CornerMax()

    gp_Pnt Bnd_Box::CornerMax ( ) const
    nodiscard

    Returns the upper corner of this bounding box. The gap is included. If this bounding box is infinite (i.e. "open"), returned values may be equal to +/- Precision::Infinite(). Standard_ConstructionError exception will be thrown if the box is void. if IsVoid().

    ◆ CornerMin()

    gp_Pnt Bnd_Box::CornerMin ( ) const
    nodiscard

    Returns the lower corner of this bounding box. The gap is included. If this bounding box is infinite (i.e. "open"), returned values may be equal to +/- Precision::Infinite(). Standard_ConstructionError exception will be thrown if the box is void. if IsVoid().

    ◆ Distance()

    double Bnd_Box::Distance ( const Bnd_Box & Other) const
    nodiscard

    Computes the minimum distance between two boxes.

    ◆ Dump()

    void Bnd_Box::Dump ( ) const

    ◆ DumpJson()

    void Bnd_Box::DumpJson ( Standard_OStream & theOStream,
    int theDepth = -1 ) const

    Dumps the content of me into the stream.

    ◆ Enlarge()

    void Bnd_Box::Enlarge ( const double Tol)
    inlinenoexcept

    Enlarges the box with a tolerance value. (minvalues-std::abs(<tol>) and maxvalues+std::abs(<tol>)) This means that the minimum values of its X, Y and Z intervals of definition, when they are finite, are reduced by the absolute value of Tol, while the maximum values are increased by the same amount.

    ◆ FinitePart()

    Bnd_Box Bnd_Box::FinitePart ( ) const
    inlinenodiscardnoexcept

    Returns a finite part of an infinite bounding box (returns self if this is already finite box). This can be a Void box in case if its sides has been defined as infinite (Open) without adding any finite points. WARNING! This method relies on Open flags, the infinite points added using Add() method will be returned as is.

    ◆ Get() [1/2]

    Limits Bnd_Box::Get ( ) const
    nodiscard

    Returns the bounds of this bounding box as a Limits structure. The gap is included. If this bounding box is infinite (i.e. "open"), returned values may be equal to +/- Precision::Infinite(). If the box is void, returns raw internal values. Can be used with C++17 structured bindings:

    auto [xmin, xmax, ymin, ymax, zmin, zmax] = aBox.Get();
    GLclampd zmax
    Definition OpenGl_glext.h:11033

    ◆ Get() [2/2]

    void Bnd_Box::Get ( double & theXmin,
    double & theYmin,
    double & theZmin,
    double & theXmax,
    double & theYmax,
    double & theZmax ) const

    Returns the bounds of this bounding box. The gap is included. If this bounding box is infinite (i.e. "open"), returned values may be equal to +/- Precision::Infinite(). Standard_ConstructionError exception will be thrown if the box is void. if IsVoid().

    ◆ GetGap()

    double Bnd_Box::GetGap ( ) const
    inlinenodiscardconstexprnoexcept

    Returns the gap of this bounding box.

    ◆ GetXMax()

    double Bnd_Box::GetXMax ( ) const
    nodiscard

    Returns the Xmax value (IsOpenXmax() ? Precision::Infinite() : Xmax + GetGap()).

    ◆ GetXMin()

    double Bnd_Box::GetXMin ( ) const
    nodiscard

    Returns the Xmin value (IsOpenXmin() ? -Precision::Infinite() : Xmin - GetGap()).

    ◆ GetYMax()

    double Bnd_Box::GetYMax ( ) const
    nodiscard

    Returns the Ymax value (IsOpenYmax() ? Precision::Infinite() : Ymax + GetGap()).

    ◆ GetYMin()

    double Bnd_Box::GetYMin ( ) const
    nodiscard

    Returns the Ymin value (IsOpenYmin() ? -Precision::Infinite() : Ymin - GetGap()).

    ◆ GetZMax()

    double Bnd_Box::GetZMax ( ) const
    nodiscard

    Returns the Zmax value (IsOpenZmax() ? Precision::Infinite() : Zmax + GetGap()).

    ◆ GetZMin()

    double Bnd_Box::GetZMin ( ) const
    nodiscard

    Returns the Zmin value (IsOpenZmin() ? -Precision::Infinite() : Zmin - GetGap()).

    ◆ HasFinitePart()

    bool Bnd_Box::HasFinitePart ( ) const
    inlinenodiscardnoexcept

    Returns TRUE if this box has finite part.

    ◆ InitFromJson()

    bool Bnd_Box::InitFromJson ( const Standard_SStream & theSStream,
    int & theStreamPos )

    Inits the content of me from the stream.

    ◆ Intersects()

    bool Bnd_Box::Intersects ( const Bnd_Box & theOther) const
    inlinenodiscard

    Returns True if the other box intersects or is inside this box.

    ◆ IsOpen()

    bool Bnd_Box::IsOpen ( ) const
    inlinenodiscardnoexcept

    Returns true if this bounding box has at least one open direction.

    ◆ IsOpenXmax()

    bool Bnd_Box::IsOpenXmax ( ) const
    inlinenodiscardnoexcept

    Returns true if this bounding box is open in the Xmax direction.

    ◆ IsOpenXmin()

    bool Bnd_Box::IsOpenXmin ( ) const
    inlinenodiscardnoexcept

    Returns true if this bounding box is open in the Xmin direction.

    ◆ IsOpenYmax()

    bool Bnd_Box::IsOpenYmax ( ) const
    inlinenodiscardnoexcept

    Returns true if this bounding box is open in the Ymax direction.

    ◆ IsOpenYmin()

    bool Bnd_Box::IsOpenYmin ( ) const
    inlinenodiscardnoexcept

    Returns true if this bounding box is open in the Ymin direction.

    ◆ IsOpenZmax()

    bool Bnd_Box::IsOpenZmax ( ) const
    inlinenodiscardnoexcept

    Returns true if this bounding box is open in the Zmax direction.

    ◆ IsOpenZmin()

    bool Bnd_Box::IsOpenZmin ( ) const
    inlinenodiscardnoexcept

    Returns true if this bounding box is open in the Zmin direction.

    ◆ IsOut() [1/7]

    bool Bnd_Box::IsOut ( const Bnd_Box & Other) const
    nodiscard

    Returns False if the <Box> intersects or is inside <me>.

    ◆ IsOut() [2/7]

    bool Bnd_Box::IsOut ( const Bnd_Box & Other,
    const gp_Trsf & T ) const
    nodiscard

    Returns False if the transformed <Box> intersects or is inside <me>.

    ◆ IsOut() [3/7]

    bool Bnd_Box::IsOut ( const gp_Lin & L) const
    nodiscard

    Returns False if the line intersects the box.

    ◆ IsOut() [4/7]

    bool Bnd_Box::IsOut ( const gp_Pln & P) const
    nodiscard

    Returns False if the plane intersects the box.

    ◆ IsOut() [5/7]

    bool Bnd_Box::IsOut ( const gp_Pnt & P) const
    nodiscard

    Returns True if the Pnt is out the box.

    ◆ IsOut() [6/7]

    bool Bnd_Box::IsOut ( const gp_Pnt & P1,
    const gp_Pnt & P2,
    const gp_Dir & D ) const
    nodiscard

    Returns False if the flat band lying between two parallel lines represented by their reference points <P1>, <P2> and direction <D> intersects the box.

    ◆ IsOut() [7/7]

    bool Bnd_Box::IsOut ( const gp_Trsf & T1,
    const Bnd_Box & Other,
    const gp_Trsf & T2 ) const
    nodiscard

    Returns False if the transformed <Box> intersects or is inside the transformed box <me>.

    ◆ IsThin()

    bool Bnd_Box::IsThin ( const double tol) const
    nodiscard

    Returns true if IsXThin, IsYThin and IsZThin are all true, i.e. if the box is thin in all three dimensions.

    ◆ IsVoid()

    bool Bnd_Box::IsVoid ( ) const
    inlinenodiscardnoexcept

    Returns true if this bounding box is empty (Void flag).

    ◆ IsWhole()

    bool Bnd_Box::IsWhole ( ) const
    inlinenodiscardnoexcept

    Returns true if this bounding box is infinite in all 6 directions (WholeSpace flag).

    ◆ IsXThin()

    bool Bnd_Box::IsXThin ( const double tol) const
    nodiscard

    true if xmax-xmin < tol.

    ◆ IsYThin()

    bool Bnd_Box::IsYThin ( const double tol) const
    nodiscard

    true if ymax-ymin < tol.

    ◆ IsZThin()

    bool Bnd_Box::IsZThin ( const double tol) const
    nodiscard

    true if zmax-zmin < tol.

    ◆ OpenXmax()

    void Bnd_Box::OpenXmax ( )
    inlinenoexcept

    The Box will be infinitely long in the Xmax direction.

    ◆ OpenXmin()

    void Bnd_Box::OpenXmin ( )
    inlinenoexcept

    The Box will be infinitely long in the Xmin direction.

    ◆ OpenYmax()

    void Bnd_Box::OpenYmax ( )
    inlinenoexcept

    The Box will be infinitely long in the Ymax direction.

    ◆ OpenYmin()

    void Bnd_Box::OpenYmin ( )
    inlinenoexcept

    The Box will be infinitely long in the Ymin direction.

    ◆ OpenZmax()

    void Bnd_Box::OpenZmax ( )
    inlinenoexcept

    The Box will be infinitely long in the Zmax direction.

    ◆ OpenZmin()

    void Bnd_Box::OpenZmin ( )
    inlinenoexcept

    The Box will be infinitely long in the Zmin direction.

    ◆ Set() [1/2]

    void Bnd_Box::Set ( const gp_Pnt & P)

    Sets this bounding box so that it bounds.

    • the point P. This involves first setting this bounding box to be void and then adding the point P.

    ◆ Set() [2/2]

    void Bnd_Box::Set ( const gp_Pnt & P,
    const gp_Dir & D )

    Sets this bounding box so that it bounds the half-line defined by point P and direction D, i.e. all points M defined by M=P+u*D, where u is greater than or equal to 0, are inside the bounding volume. This involves first setting this box to be void and then adding the half-line.

    ◆ SetGap()

    void Bnd_Box::SetGap ( const double Tol)
    inlinenoexcept

    Set the gap of this bounding box to abs(Tol).

    ◆ SetVoid()

    void Bnd_Box::SetVoid ( )
    inlinenoexcept

    Sets this bounding box so that it is empty. All points are outside a void box.

    ◆ SetWhole()

    void Bnd_Box::SetWhole ( )
    inlinenoexcept

    Sets this bounding box so that it covers the whole of 3D space. It is infinitely long in all directions.

    ◆ SquareExtent()

    double Bnd_Box::SquareExtent ( ) const
    inlinenodiscardnoexcept

    Computes the squared diagonal of me.

    ◆ Transformed()

    Bnd_Box Bnd_Box::Transformed ( const gp_Trsf & T) const
    nodiscard

    Returns a bounding box which is the result of applying the transformation T to this bounding box. Warning Applying a geometric transformation (for example, a rotation) to a bounding box generally increases its dimensions. This is not optimal for algorithms which use it.

    ◆ Update() [1/2]

    void Bnd_Box::Update ( const double aXmin,
    const double aYmin,
    const double aZmin,
    const double aXmax,
    const double aYmax,
    const double aZmax )

    Enlarges this bounding box, if required, so that it contains at least:

    • interval [ aXmin,aXmax ] in the "X Direction",
    • interval [ aYmin,aYmax ] in the "Y Direction",
    • interval [ aZmin,aZmax ] in the "Z Direction";

    ◆ Update() [2/2]

    void Bnd_Box::Update ( const double X,
    const double Y,
    const double Z )

    Adds a point of coordinates (X,Y,Z) to this bounding box.


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