From: Pasukhin Dmitry Date: Wed, 19 Nov 2025 11:34:04 +0000 (+0000) Subject: Foundation Classes - Modernize Bnd_B2 and Bnd_B3 (#838) X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=851ac10c1215874027b840c19a78a5d9f0d6e10f;p=occt.git Foundation Classes - Modernize Bnd_B2 and Bnd_B3 (#838) - Replace C-style arrays with std::array for internal storage (myCenter and myHSize fields) - Add constexpr noexcept constructors for all variants (default, gp_XY/gp_XYZ, and std::array overloads) - Add public getter methods Center() and HSize() for direct read access to internal fields - Add setter overloads accepting std::array parameters - Mark appropriate methods as constexpr and noexcept for compile-time evaluation and optimization guarantees - Clean up boolean comparisons (remove explicit Standard_True/False checks) --- diff --git a/src/FoundationClasses/TKMath/Bnd/Bnd_B2.hxx b/src/FoundationClasses/TKMath/Bnd/Bnd_B2.hxx index 00c52813df..e9494bcd25 100644 --- a/src/FoundationClasses/TKMath/Bnd/Bnd_B2.hxx +++ b/src/FoundationClasses/TKMath/Bnd/Bnd_B2.hxx @@ -25,6 +25,8 @@ #include #include +#include + //! Template class for 2D bounding box. //! This is a base template that is instantiated for Standard_Real and Standard_ShortReal. template @@ -34,16 +36,20 @@ public: DEFINE_STANDARD_ALLOC //! Empty constructor. - Bnd_B2(); + constexpr Bnd_B2() noexcept; + + //! Constructor. + constexpr Bnd_B2(const gp_XY& theCenter, const gp_XY& theHSize) noexcept; //! Constructor. - Bnd_B2(const gp_XY& theCenter, const gp_XY& theHSize); + constexpr Bnd_B2(const std::array& theCenter, + const std::array& theHSize) noexcept; //! Returns True if the box is void (non-initialized). - Standard_Boolean IsVoid() const; + constexpr Standard_Boolean IsVoid() const noexcept; //! Reset the box data. - void Clear(); + void Clear() noexcept; //! Update the box by a point. void Add(const gp_XY& thePnt); @@ -57,19 +63,19 @@ public: //! Query a box corner: (Center - HSize). You must make sure that //! the box is NOT VOID (see IsVoid()), otherwise the method returns //! irrelevant result. - gp_XY CornerMin() const; + gp_XY CornerMin() const noexcept; //! Query a box corner: (Center + HSize). You must make sure that //! the box is NOT VOID (see IsVoid()), otherwise the method returns //! irrelevant result. - gp_XY CornerMax() const; + gp_XY CornerMax() const noexcept; //! Query the square diagonal. If the box is VOID (see method IsVoid()) //! then a very big real value is returned. - Standard_Real SquareExtent() const; + constexpr Standard_Real SquareExtent() const noexcept; //! Extend the Box by the absolute value of theDiff. - void Enlarge(const Standard_Real theDiff); + void Enlarge(const Standard_Real theDiff) noexcept; //! Limit the Box by the internals of theOtherBox. //! Returns True if the limitation takes place, otherwise False @@ -82,7 +88,7 @@ public: //! Check the given point for the inclusion in the Box. //! Returns True if the point is outside. - Standard_Boolean IsOut(const gp_XY& thePnt) const; + constexpr Standard_Boolean IsOut(const gp_XY& thePnt) const noexcept; //! Check a circle for the intersection with the current box. //! Returns True if there is no intersection between boxes. @@ -92,7 +98,7 @@ public: //! Check the given box for the intersection with the current box. //! Returns True if there is no intersection between boxes. - Standard_Boolean IsOut(const Bnd_B2& theOtherBox) const; + constexpr Standard_Boolean IsOut(const Bnd_B2& theOtherBox) const noexcept; //! Check the given box oriented by the given transformation //! for the intersection with the current box. @@ -110,7 +116,7 @@ public: //! Check that the box 'this' is inside the given box 'theBox'. Returns //! True if 'this' box is fully inside 'theBox'. - Standard_Boolean IsIn(const Bnd_B2& theBox) const; + constexpr Standard_Boolean IsIn(const Bnd_B2& theBox) const noexcept; //! Check that the box 'this' is inside the given box 'theBox' //! transformed by 'theTrsf'. Returns True if 'this' box is fully @@ -118,19 +124,33 @@ public: Standard_Boolean IsIn(const Bnd_B2& theBox, const gp_Trsf2d& theTrsf) const; //! Set the Center coordinates - void SetCenter(const gp_XY& theCenter); + void SetCenter(const gp_XY& theCenter) noexcept; + + //! Set the Center coordinates + void SetCenter(const std::array& theCenter) noexcept; //! Set the HSize (half-diagonal) coordinates. //! All components of theHSize must be non-negative. - void SetHSize(const gp_XY& theHSize); + void SetHSize(const gp_XY& theHSize) noexcept; + + //! Set the HSize (half-diagonal) coordinates. + //! All components of theHSize must be non-negative. + void SetHSize(const std::array& theHSize) noexcept; + + //! Get the Center coordinates + constexpr const std::array& Center() const noexcept; + + //! Get the HSize (half-diagonal) coordinates + constexpr const std::array& HSize() const noexcept; protected: - static Standard_Boolean compareDist(const RealType aHSize[2], const RealType aDist[2]) + static constexpr Standard_Boolean compareDist(const RealType aHSize[2], + const RealType aDist[2]) noexcept { return (std::abs(aDist[0]) > aHSize[0] || std::abs(aDist[1]) > aHSize[1]); } - static Standard_Boolean compareDistD(const gp_XY& aHSize, const gp_XY& aDist) + static Standard_Boolean compareDistD(const gp_XY& aHSize, const gp_XY& aDist) noexcept { return (std::abs(aDist.X()) > aHSize.X() || std::abs(aDist.Y()) > aHSize.Y()); } @@ -139,33 +159,42 @@ protected: static constexpr RealType THE_RealLast = RealType(1e30); private: - RealType myCenter[2]; - RealType myHSize[2]; + std::array myCenter; + std::array myHSize; }; //================================================================================================= template -inline Bnd_B2::Bnd_B2() +constexpr inline Bnd_B2::Bnd_B2() noexcept + : myCenter{THE_RealLast, THE_RealLast}, + myHSize{-THE_RealLast, -THE_RealLast} { - Clear(); } //================================================================================================= template -inline Bnd_B2::Bnd_B2(const gp_XY& theCenter, const gp_XY& theHSize) +constexpr inline Bnd_B2::Bnd_B2(const gp_XY& theCenter, const gp_XY& theHSize) noexcept + : myCenter{RealType(theCenter.X()), RealType(theCenter.Y())}, + myHSize{RealType(theHSize.X()), RealType(theHSize.Y())} +{ +} + +//================================================================================================= + +template +constexpr inline Bnd_B2::Bnd_B2(const std::array& theCenter, + const std::array& theHSize) noexcept + : myCenter(theCenter), + myHSize(theHSize) { - myCenter[0] = RealType(theCenter.X()); - myCenter[1] = RealType(theCenter.Y()); - myHSize[0] = RealType(theHSize.X()); - myHSize[1] = RealType(theHSize.Y()); } //================================================================================================= template -inline void Bnd_B2::Clear() +inline void Bnd_B2::Clear() noexcept { myCenter[0] = THE_RealLast; myCenter[1] = THE_RealLast; @@ -176,7 +205,7 @@ inline void Bnd_B2::Clear() //================================================================================================= template -inline Standard_Boolean Bnd_B2::IsVoid() const +constexpr inline Standard_Boolean Bnd_B2::IsVoid() const noexcept { return (myHSize[0] < -1e-5); } @@ -194,7 +223,7 @@ inline void Bnd_B2::Add(const gp_Pnt2d& thePnt) template inline void Bnd_B2::Add(const Bnd_B2& theBox) { - if (theBox.IsVoid() == Standard_False) + if (!theBox.IsVoid()) { Add(theBox.CornerMin()); Add(theBox.CornerMax()); @@ -204,7 +233,7 @@ inline void Bnd_B2::Add(const Bnd_B2& theBox) //================================================================================================= template -inline gp_XY Bnd_B2::CornerMin() const +inline gp_XY Bnd_B2::CornerMin() const noexcept { return gp_XY(myCenter[0] - myHSize[0], myCenter[1] - myHSize[1]); } @@ -212,7 +241,7 @@ inline gp_XY Bnd_B2::CornerMin() const //================================================================================================= template -inline gp_XY Bnd_B2::CornerMax() const +inline gp_XY Bnd_B2::CornerMax() const noexcept { return gp_XY(myCenter[0] + myHSize[0], myCenter[1] + myHSize[1]); } @@ -220,7 +249,7 @@ inline gp_XY Bnd_B2::CornerMax() const //================================================================================================= template -inline Standard_Real Bnd_B2::SquareExtent() const +constexpr inline Standard_Real Bnd_B2::SquareExtent() const noexcept { return 4 * (myHSize[0] * myHSize[0] + myHSize[1] * myHSize[1]); } @@ -228,7 +257,7 @@ inline Standard_Real Bnd_B2::SquareExtent() const //================================================================================================= template -inline void Bnd_B2::SetCenter(const gp_XY& theCenter) +inline void Bnd_B2::SetCenter(const gp_XY& theCenter) noexcept { myCenter[0] = RealType(theCenter.X()); myCenter[1] = RealType(theCenter.Y()); @@ -237,7 +266,7 @@ inline void Bnd_B2::SetCenter(const gp_XY& theCenter) //================================================================================================= template -inline void Bnd_B2::SetHSize(const gp_XY& theHSize) +inline void Bnd_B2::SetHSize(const gp_XY& theHSize) noexcept { myHSize[0] = RealType(theHSize.X()); myHSize[1] = RealType(theHSize.Y()); @@ -246,7 +275,39 @@ inline void Bnd_B2::SetHSize(const gp_XY& theHSize) //================================================================================================= template -inline void Bnd_B2::Enlarge(const Standard_Real aDiff) +inline void Bnd_B2::SetCenter(const std::array& theCenter) noexcept +{ + myCenter = theCenter; +} + +//================================================================================================= + +template +inline void Bnd_B2::SetHSize(const std::array& theHSize) noexcept +{ + myHSize = theHSize; +} + +//================================================================================================= + +template +constexpr inline const std::array& Bnd_B2::Center() const noexcept +{ + return myCenter; +} + +//================================================================================================= + +template +constexpr inline const std::array& Bnd_B2::HSize() const noexcept +{ + return myHSize; +} + +//================================================================================================= + +template +inline void Bnd_B2::Enlarge(const Standard_Real aDiff) noexcept { const RealType aD = RealType(std::abs(aDiff)); myHSize[0] += aD; @@ -256,7 +317,7 @@ inline void Bnd_B2::Enlarge(const Standard_Real aDiff) //================================================================================================= template -inline Standard_Boolean Bnd_B2::IsOut(const gp_XY& thePnt) const +constexpr inline Standard_Boolean Bnd_B2::IsOut(const gp_XY& thePnt) const noexcept { return (std::abs(RealType(thePnt.X()) - myCenter[0]) > myHSize[0] || std::abs(RealType(thePnt.Y()) - myCenter[1]) > myHSize[1]); @@ -265,7 +326,8 @@ inline Standard_Boolean Bnd_B2::IsOut(const gp_XY& thePnt) const //================================================================================================= template -inline Standard_Boolean Bnd_B2::IsOut(const Bnd_B2& theBox) const +constexpr inline Standard_Boolean Bnd_B2::IsOut( + const Bnd_B2& theBox) const noexcept { return (std::abs(theBox.myCenter[0] - myCenter[0]) > theBox.myHSize[0] + myHSize[0] || std::abs(theBox.myCenter[1] - myCenter[1]) > theBox.myHSize[1] + myHSize[1]); @@ -274,7 +336,8 @@ inline Standard_Boolean Bnd_B2::IsOut(const Bnd_B2& theBox) //================================================================================================= template -inline Standard_Boolean Bnd_B2::IsIn(const Bnd_B2& theBox) const +constexpr inline Standard_Boolean Bnd_B2::IsIn( + const Bnd_B2& theBox) const noexcept { return (std::abs(theBox.myCenter[0] - myCenter[0]) < theBox.myHSize[0] - myHSize[0] && std::abs(theBox.myCenter[1] - myCenter[1]) < theBox.myHSize[1] - myHSize[1]); @@ -332,7 +395,7 @@ Standard_Boolean Bnd_B2::Limit(const Bnd_B2& theBox) const RealType diffC[2] = {theBox.myCenter[0] - myCenter[0], theBox.myCenter[1] - myCenter[1]}; const RealType sumH[2] = {theBox.myHSize[0] + myHSize[0], theBox.myHSize[1] + myHSize[1]}; // check the condition IsOut - if (compareDist(sumH, diffC) == Standard_False) + if (!compareDist(sumH, diffC)) { const RealType diffH[2] = {theBox.myHSize[0] - myHSize[0], theBox.myHSize[1] - myHSize[1]}; if (diffC[0] - diffH[0] > 0.) @@ -406,7 +469,7 @@ Standard_Boolean Bnd_B2::IsOut(const gp_XY& theCenter, const Standard_Boolean isCircleHollow) const { Standard_Boolean aResult(Standard_True); - if (isCircleHollow == Standard_False) + if (!isCircleHollow) { // vector from the center of the circle to the nearest box face const Standard_Real aDist[2] = { @@ -522,7 +585,7 @@ template Standard_Boolean Bnd_B2::IsOut(const gp_XY& theP0, const gp_XY& theP1) const { Standard_Boolean aResult(Standard_True); - if (IsVoid() == Standard_False) + if (!IsVoid()) { // Intersect the line containing the segment. const gp_XY aSegDelta(theP1 - theP0); diff --git a/src/FoundationClasses/TKMath/Bnd/Bnd_B3.hxx b/src/FoundationClasses/TKMath/Bnd/Bnd_B3.hxx index bbd8749c48..f9ae09dac2 100644 --- a/src/FoundationClasses/TKMath/Bnd/Bnd_B3.hxx +++ b/src/FoundationClasses/TKMath/Bnd/Bnd_B3.hxx @@ -27,6 +27,8 @@ #include #include +#include + //! Template class for 3D bounding box. //! This is a base template that is instantiated for Standard_Real and Standard_ShortReal. template @@ -36,16 +38,20 @@ public: DEFINE_STANDARD_ALLOC //! Empty constructor. - Bnd_B3(); + constexpr Bnd_B3() noexcept; + + //! Constructor. + constexpr Bnd_B3(const gp_XYZ& theCenter, const gp_XYZ& theHSize) noexcept; //! Constructor. - Bnd_B3(const gp_XYZ& theCenter, const gp_XYZ& theHSize); + constexpr Bnd_B3(const std::array& theCenter, + const std::array& theHSize) noexcept; //! Returns True if the box is void (non-initialized). - Standard_Boolean IsVoid() const; + constexpr Standard_Boolean IsVoid() const noexcept; //! Reset the box data. - void Clear(); + void Clear() noexcept; //! Update the box by a point. void Add(const gp_XYZ& thePnt); @@ -59,19 +65,19 @@ public: //! Query the lower corner: (Center - HSize). You must make sure that //! the box is NOT VOID (see IsVoid()), otherwise the method returns //! irrelevant result. - gp_XYZ CornerMin() const; + gp_XYZ CornerMin() const noexcept; //! Query the upper corner: (Center + HSize). You must make sure that //! the box is NOT VOID (see IsVoid()), otherwise the method returns //! irrelevant result. - gp_XYZ CornerMax() const; + gp_XYZ CornerMax() const noexcept; //! Query the square diagonal. If the box is VOID (see method IsVoid()) //! then a very big real value is returned. - Standard_Real SquareExtent() const; + constexpr Standard_Real SquareExtent() const noexcept; //! Extend the Box by the absolute value of theDiff. - void Enlarge(const Standard_Real theDiff); + void Enlarge(const Standard_Real theDiff) noexcept; //! Limit the Box by the internals of theOtherBox. //! Returns True if the limitation takes place, otherwise False @@ -84,7 +90,7 @@ public: //! Check the given point for the inclusion in the Box. //! Returns True if the point is outside. - Standard_Boolean IsOut(const gp_XYZ& thePnt) const; + constexpr Standard_Boolean IsOut(const gp_XYZ& thePnt) const noexcept; //! Check a sphere for the intersection with the current box. //! Returns True if there is no intersection between boxes. If the @@ -97,7 +103,7 @@ public: //! Check the given box for the intersection with the current box. //! Returns True if there is no intersection between boxes. - Standard_Boolean IsOut(const Bnd_B3& theOtherBox) const; + constexpr Standard_Boolean IsOut(const Bnd_B3& theOtherBox) const noexcept; //! Check the given box oriented by the given transformation //! for the intersection with the current box. @@ -120,7 +126,7 @@ public: //! Check that the box 'this' is inside the given box 'theBox'. Returns //! True if 'this' box is fully inside 'theBox'. - Standard_Boolean IsIn(const Bnd_B3& theBox) const; + constexpr Standard_Boolean IsIn(const Bnd_B3& theBox) const noexcept; //! Check that the box 'this' is inside the given box 'theBox' //! transformed by 'theTrsf'. Returns True if 'this' box is fully @@ -128,20 +134,34 @@ public: Standard_Boolean IsIn(const Bnd_B3& theBox, const gp_Trsf& theTrsf) const; //! Set the Center coordinates - void SetCenter(const gp_XYZ& theCenter); + void SetCenter(const gp_XYZ& theCenter) noexcept; + + //! Set the Center coordinates + void SetCenter(const std::array& theCenter) noexcept; //! Set the HSize (half-diagonal) coordinates. //! All components of theHSize must be non-negative. - void SetHSize(const gp_XYZ& theHSize); + void SetHSize(const gp_XYZ& theHSize) noexcept; + + //! Set the HSize (half-diagonal) coordinates. + //! All components of theHSize must be non-negative. + void SetHSize(const std::array& theHSize) noexcept; + + //! Get the Center coordinates + constexpr const std::array& Center() const noexcept; + + //! Get the HSize (half-diagonal) coordinates + constexpr const std::array& HSize() const noexcept; protected: - static Standard_Boolean compareDist(const RealType aHSize[3], const RealType aDist[3]) + static constexpr Standard_Boolean compareDist(const RealType aHSize[3], + const RealType aDist[3]) noexcept { return (std::abs(aDist[0]) > aHSize[0] || std::abs(aDist[1]) > aHSize[1] || std::abs(aDist[2]) > aHSize[2]); } - static Standard_Boolean compareDistD(const gp_XYZ& aHSize, const gp_XYZ& aDist) + static Standard_Boolean compareDistD(const gp_XYZ& aHSize, const gp_XYZ& aDist) noexcept { return (std::abs(aDist.X()) > aHSize.X() || std::abs(aDist.Y()) > aHSize.Y() || std::abs(aDist.Z()) > aHSize.Z()); @@ -151,35 +171,42 @@ protected: static constexpr RealType THE_RealLast = RealType(1e30); private: - RealType myCenter[3]; - RealType myHSize[3]; + std::array myCenter; + std::array myHSize; }; //================================================================================================= template -inline Bnd_B3::Bnd_B3() +constexpr inline Bnd_B3::Bnd_B3() noexcept + : myCenter{THE_RealLast, THE_RealLast, THE_RealLast}, + myHSize{-THE_RealLast, -THE_RealLast, -THE_RealLast} { - Clear(); } //================================================================================================= template -inline Bnd_B3::Bnd_B3(const gp_XYZ& theCenter, const gp_XYZ& theHSize) +constexpr inline Bnd_B3::Bnd_B3(const gp_XYZ& theCenter, const gp_XYZ& theHSize) noexcept + : myCenter{RealType(theCenter.X()), RealType(theCenter.Y()), RealType(theCenter.Z())}, + myHSize{RealType(theHSize.X()), RealType(theHSize.Y()), RealType(theHSize.Z())} { - myCenter[0] = RealType(theCenter.X()); - myCenter[1] = RealType(theCenter.Y()); - myCenter[2] = RealType(theCenter.Z()); - myHSize[0] = RealType(theHSize.X()); - myHSize[1] = RealType(theHSize.Y()); - myHSize[2] = RealType(theHSize.Z()); } //================================================================================================= template -inline void Bnd_B3::Clear() +constexpr inline Bnd_B3::Bnd_B3(const std::array& theCenter, + const std::array& theHSize) noexcept + : myCenter(theCenter), + myHSize(theHSize) +{ +} + +//================================================================================================= + +template +inline void Bnd_B3::Clear() noexcept { myCenter[0] = THE_RealLast; myCenter[1] = THE_RealLast; @@ -192,7 +219,7 @@ inline void Bnd_B3::Clear() //================================================================================================= template -inline Standard_Boolean Bnd_B3::IsVoid() const +constexpr inline Standard_Boolean Bnd_B3::IsVoid() const noexcept { return (myHSize[0] < -1e-5); } @@ -210,7 +237,7 @@ inline void Bnd_B3::Add(const gp_Pnt& thePnt) template inline void Bnd_B3::Add(const Bnd_B3& theBox) { - if (theBox.IsVoid() == Standard_False) + if (!theBox.IsVoid()) { Add(theBox.CornerMin()); Add(theBox.CornerMax()); @@ -220,7 +247,7 @@ inline void Bnd_B3::Add(const Bnd_B3& theBox) //================================================================================================= template -inline gp_XYZ Bnd_B3::CornerMin() const +inline gp_XYZ Bnd_B3::CornerMin() const noexcept { return gp_XYZ(myCenter[0] - myHSize[0], myCenter[1] - myHSize[1], myCenter[2] - myHSize[2]); } @@ -228,7 +255,7 @@ inline gp_XYZ Bnd_B3::CornerMin() const //================================================================================================= template -inline gp_XYZ Bnd_B3::CornerMax() const +inline gp_XYZ Bnd_B3::CornerMax() const noexcept { return gp_XYZ(myCenter[0] + myHSize[0], myCenter[1] + myHSize[1], myCenter[2] + myHSize[2]); } @@ -236,7 +263,7 @@ inline gp_XYZ Bnd_B3::CornerMax() const //================================================================================================= template -inline Standard_Real Bnd_B3::SquareExtent() const +constexpr inline Standard_Real Bnd_B3::SquareExtent() const noexcept { return 4 * (myHSize[0] * myHSize[0] + myHSize[1] * myHSize[1] + myHSize[2] * myHSize[2]); } @@ -244,7 +271,7 @@ inline Standard_Real Bnd_B3::SquareExtent() const //================================================================================================= template -inline void Bnd_B3::SetCenter(const gp_XYZ& theCenter) +inline void Bnd_B3::SetCenter(const gp_XYZ& theCenter) noexcept { myCenter[0] = RealType(theCenter.X()); myCenter[1] = RealType(theCenter.Y()); @@ -254,7 +281,7 @@ inline void Bnd_B3::SetCenter(const gp_XYZ& theCenter) //================================================================================================= template -inline void Bnd_B3::SetHSize(const gp_XYZ& theHSize) +inline void Bnd_B3::SetHSize(const gp_XYZ& theHSize) noexcept { myHSize[0] = RealType(theHSize.X()); myHSize[1] = RealType(theHSize.Y()); @@ -264,7 +291,39 @@ inline void Bnd_B3::SetHSize(const gp_XYZ& theHSize) //================================================================================================= template -inline void Bnd_B3::Enlarge(const Standard_Real aDiff) +inline void Bnd_B3::SetCenter(const std::array& theCenter) noexcept +{ + myCenter = theCenter; +} + +//================================================================================================= + +template +inline void Bnd_B3::SetHSize(const std::array& theHSize) noexcept +{ + myHSize = theHSize; +} + +//================================================================================================= + +template +constexpr inline const std::array& Bnd_B3::Center() const noexcept +{ + return myCenter; +} + +//================================================================================================= + +template +constexpr inline const std::array& Bnd_B3::HSize() const noexcept +{ + return myHSize; +} + +//================================================================================================= + +template +inline void Bnd_B3::Enlarge(const Standard_Real aDiff) noexcept { const Standard_Real aD = std::abs(aDiff); myHSize[0] += RealType(aD); @@ -275,7 +334,7 @@ inline void Bnd_B3::Enlarge(const Standard_Real aDiff) //================================================================================================= template -inline Standard_Boolean Bnd_B3::IsOut(const gp_XYZ& thePnt) const +constexpr inline Standard_Boolean Bnd_B3::IsOut(const gp_XYZ& thePnt) const noexcept { return (std::abs(RealType(thePnt.X()) - myCenter[0]) > myHSize[0] || std::abs(RealType(thePnt.Y()) - myCenter[1]) > myHSize[1] @@ -285,7 +344,8 @@ inline Standard_Boolean Bnd_B3::IsOut(const gp_XYZ& thePnt) const //================================================================================================= template -inline Standard_Boolean Bnd_B3::IsOut(const Bnd_B3& theBox) const +constexpr inline Standard_Boolean Bnd_B3::IsOut( + const Bnd_B3& theBox) const noexcept { return (std::abs(theBox.myCenter[0] - myCenter[0]) > theBox.myHSize[0] + myHSize[0] || std::abs(theBox.myCenter[1] - myCenter[1]) > theBox.myHSize[1] + myHSize[1] @@ -295,7 +355,8 @@ inline Standard_Boolean Bnd_B3::IsOut(const Bnd_B3& theBox) //================================================================================================= template -inline Standard_Boolean Bnd_B3::IsIn(const Bnd_B3& theBox) const +constexpr inline Standard_Boolean Bnd_B3::IsIn( + const Bnd_B3& theBox) const noexcept { return (std::abs(theBox.myCenter[0] - myCenter[0]) < theBox.myHSize[0] - myHSize[0] && std::abs(theBox.myCenter[1] - myCenter[1]) < theBox.myHSize[1] - myHSize[1] @@ -373,7 +434,7 @@ Standard_Boolean Bnd_B3::Limit(const Bnd_B3& theBox) theBox.myHSize[1] + myHSize[1], theBox.myHSize[2] + myHSize[2]}; // check the condition IsOut - if (compareDist(sumH, diffC) == Standard_False) + if (!compareDist(sumH, diffC)) { const RealType diffH[3] = {theBox.myHSize[0] - myHSize[0], theBox.myHSize[1] - myHSize[1], @@ -474,7 +535,7 @@ Standard_Boolean Bnd_B3::IsOut(const gp_XYZ& theCenter, const Standard_Boolean isSphereHollow) const { Standard_Boolean aResult(Standard_True); - if (isSphereHollow == Standard_False) + if (!isSphereHollow) { // vector from the center of the sphere to the nearest box face const Standard_Real aDist[3] = {