Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-26 08:16:34

0001 // Created on: 1991-01-08
0002 // Created by: Didier Piffault
0003 // Copyright (c) 1991-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _Bnd_B3f_HeaderFile
0018 #define _Bnd_B3f_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 
0023 class gp_XYZ;
0024 class gp_Pnt;
0025 class gp_Trsf;
0026 class gp_Ax1;
0027 class gp_Ax3;
0028 
0029 class Bnd_B3f
0030 {
0031 public:
0032   DEFINE_STANDARD_ALLOC
0033 
0034   //! Empty constructor.
0035   Bnd_B3f();
0036 
0037   //! Constructor.
0038   Bnd_B3f(const gp_XYZ& theCenter, const gp_XYZ& theHSize);
0039 
0040   //! Returns True if the box is void (non-initialized).
0041   Standard_Boolean IsVoid() const;
0042 
0043   //! Reset the box data.
0044   void Clear();
0045 
0046   //! Update the box by a point.
0047   Standard_EXPORT void Add(const gp_XYZ& thePnt);
0048 
0049   //! Update the box by a point.
0050   void Add(const gp_Pnt& thePnt);
0051 
0052   //! Update the box by another box.
0053   void Add(const Bnd_B3f& theBox);
0054 
0055   //! Query the lower corner: (Center - HSize). You must make sure that
0056   //! the box is NOT VOID (see IsVoid()), otherwise the method returns
0057   //! irrelevant result.
0058   gp_XYZ CornerMin() const;
0059 
0060   //! Query the upper corner: (Center + HSize). You must make sure that
0061   //! the box is NOT VOID (see IsVoid()), otherwise the method returns
0062   //! irrelevant result.
0063   gp_XYZ CornerMax() const;
0064 
0065   //! Query the square diagonal. If the box is VOID (see method IsVoid())
0066   //! then a very big real value is returned.
0067   Standard_Real SquareExtent() const;
0068 
0069   //! Extend the Box by the absolute value of theDiff.
0070   void Enlarge(const Standard_Real theDiff);
0071 
0072   //! Limit the Box by the internals of theOtherBox.
0073   //! Returns True if the limitation takes place, otherwise False
0074   //! indicating that the boxes do not intersect.
0075   Standard_EXPORT Standard_Boolean Limit(const Bnd_B3f& theOtherBox);
0076 
0077   //! Transform the bounding box with the given transformation.
0078   //! The resulting box will be larger if theTrsf contains rotation.
0079   Standard_NODISCARD Standard_EXPORT Bnd_B3f Transformed(const gp_Trsf& theTrsf) const;
0080 
0081   //! Check the given point for the inclusion in the Box.
0082   //! Returns True if the point is outside.
0083   Standard_Boolean IsOut(const gp_XYZ& thePnt) const;
0084 
0085   //! Check a sphere for the intersection with the current box.
0086   //! Returns True if there is no intersection between boxes. If the
0087   //! parameter 'IsSphereHollow' is True, then the intersection is not
0088   //! reported for a box that is completely inside the sphere (otherwise
0089   //! this method would report an intersection).
0090   Standard_EXPORT Standard_Boolean
0091     IsOut(const gp_XYZ&          theCenter,
0092           const Standard_Real    theRadius,
0093           const Standard_Boolean isSphereHollow = Standard_False) const;
0094 
0095   //! Check the given box for the intersection with the current box.
0096   //! Returns True if there is no intersection between boxes.
0097   Standard_Boolean IsOut(const Bnd_B3f& theOtherBox) const;
0098 
0099   //! Check the given box oriented by the given transformation
0100   //! for the intersection with the current box.
0101   //! Returns True if there is no intersection between boxes.
0102   Standard_EXPORT Standard_Boolean IsOut(const Bnd_B3f& theOtherBox, const gp_Trsf& theTrsf) const;
0103 
0104   //! Check the given Line for the intersection with the current box.
0105   //! Returns True if there is no intersection.
0106   //! isRay==True means intersection check with the positive half-line
0107   //! theOverthickness is the addition to the size of the current box
0108   //! (may be negative). If positive, it can be treated as the thickness
0109   //! of the line 'theLine' or the radius of the cylinder along 'theLine'
0110   Standard_EXPORT Standard_Boolean IsOut(const gp_Ax1&          theLine,
0111                                          const Standard_Boolean isRay            = Standard_False,
0112                                          const Standard_Real    theOverthickness = 0.0) const;
0113 
0114   //! Check the given Plane for the intersection with the current box.
0115   //! Returns True if there is no intersection.
0116   Standard_EXPORT Standard_Boolean IsOut(const gp_Ax3& thePlane) const;
0117 
0118   //! Check that the box 'this' is inside the given box 'theBox'. Returns
0119   //! True if 'this' box is fully inside 'theBox'.
0120   Standard_Boolean IsIn(const Bnd_B3f& theBox) const;
0121 
0122   //! Check that the box 'this' is inside the given box 'theBox'
0123   //! transformed by 'theTrsf'. Returns True if 'this' box is fully
0124   //! inside the transformed 'theBox'.
0125   Standard_EXPORT Standard_Boolean IsIn(const Bnd_B3f& theBox, const gp_Trsf& theTrsf) const;
0126 
0127   //! Set the Center coordinates
0128   void SetCenter(const gp_XYZ& theCenter);
0129 
0130   //! Set the HSize (half-diagonal) coordinates.
0131   //! All components of theHSize must be non-negative.
0132   void SetHSize(const gp_XYZ& theHSize);
0133 
0134 protected:
0135   Standard_ShortReal myCenter[3];
0136   Standard_ShortReal myHSize[3];
0137 
0138 private:
0139 };
0140 
0141 #define RealType Standard_ShortReal
0142 #define RealType_hxx <Standard_ShortReal.hxx>
0143 #define Bnd_B3x Bnd_B3f
0144 #define Bnd_B3x_hxx <Bnd_B3f.hxx>
0145 
0146 #include <Bnd_B3x.lxx>
0147 
0148 #undef RealType
0149 #undef RealType_hxx
0150 #undef Bnd_B3x
0151 #undef Bnd_B3x_hxx
0152 
0153 #endif // _Bnd_B3f_HeaderFile