From 922da0a825ed47896df70d2581ab3ddc7ea7b9c1 Mon Sep 17 00:00:00 2001 From: kgv Date: Wed, 5 Oct 2016 13:52:48 +0300 Subject: [PATCH] 0027931: Coding rules, Precision.hxx - eliminate dead code within PRECISION_OBSOLETE macros --- src/Precision/FILES | 1 - src/Precision/Precision.hxx | 87 +++++--------- src/Precision/Precision.lxx | 229 ------------------------------------ 3 files changed, 29 insertions(+), 288 deletions(-) delete mode 100644 src/Precision/Precision.lxx diff --git a/src/Precision/FILES b/src/Precision/FILES index 727f319209..6e172d2a91 100644 --- a/src/Precision/FILES +++ b/src/Precision/FILES @@ -1,2 +1 @@ Precision.hxx -Precision.lxx diff --git a/src/Precision/Precision.hxx b/src/Precision/Precision.hxx index 790363b00a..9afbb90b23 100644 --- a/src/Precision/Precision.hxx +++ b/src/Precision/Precision.hxx @@ -20,11 +20,9 @@ #include #include #include - #include #include - //! The Precision package offers a set of functions defining precision criteria //! for use in conventional situations when comparing two numbers. //! Generalities @@ -103,7 +101,6 @@ public: DEFINE_STANDARD_ALLOC - //! Returns the recommended precision value //! when checking the equality of two angles (given in radians). //! Standard_Real Angle1 = ... , Angle2 = ... ; @@ -123,8 +120,7 @@ public: //! you can use : //! If ( Abs( D1.D2 ) < Precision::Angular() ) ... //! (although the function IsNormal does exist). - static Standard_Real Angular(); - + static Standard_Real Angular() { return 1.e-12; } //! Returns the recommended precision value when //! checking coincidence of two points in real space. @@ -166,13 +162,12 @@ public: //! distance (1 / 10 millimeter). This distance //! becomes easily measurable, but only within a restricted //! space which contains some small objects of the complete scene. - static Standard_Real Confusion(); - + static Standard_Real Confusion() { return 1.e-7; } //! Returns square of Confusion. //! Created for speed and convenience. - static Standard_Real SquareConfusion(); - + static Standard_Real SquareConfusion() { return Confusion() * Confusion(); } + //! Returns the precision value in real space, frequently //! used by intersection algorithms to decide that a solution is reached. //! This function provides an acceptable level of precision @@ -195,8 +190,8 @@ public: //! The tolerance of intersection is equal to : //! Precision::Confusion() / 100. //! (that is, 1.e-9). - static Standard_Real Intersection(); - + static Standard_Real Intersection() { return Confusion() * 0.01; } + //! Returns the precision value in real space, frequently used //! by approximation algorithms. //! This function provides an acceptable level of precision for @@ -210,15 +205,14 @@ public: //! (that is, 1.e-6). //! You may use a smaller tolerance in an approximation //! algorithm, but this option might be costly. - static Standard_Real Approximation(); - + static Standard_Real Approximation() { return Confusion() * 10.0; } + //! Convert a real space precision to a parametric //! space precision. is the mean value of the //! length of the tangent of the curve or the surface. //! //! Value is P / T - static Standard_Real Parametric (const Standard_Real P, const Standard_Real T); - + static Standard_Real Parametric (const Standard_Real P, const Standard_Real T) { return P / T; } //! Returns a precision value in parametric space, which may be used : //! - to test the coincidence of two points in the real space, @@ -264,8 +258,7 @@ public: //! 2.Pi without impacting on the resulting point. //! Therefore, take great care when adjusting a parametric //! tolerance to your own algorithm. - static Standard_Real PConfusion (const Standard_Real T); - + static Standard_Real PConfusion (const Standard_Real T) { return Parametric (Confusion(), T); } //! Returns a precision value in parametric space, which //! may be used by intersection algorithms, to decide that @@ -280,8 +273,8 @@ public: //! segment whose length is equal to 100. (default value), or T. //! The parametric tolerance of intersection is equal to : //! - Precision::Intersection() / 100., or Precision::Intersection() / T. - static Standard_Real PIntersection (const Standard_Real T); - + static Standard_Real PIntersection (const Standard_Real T) { return Parametric(Intersection(),T); } + //! Returns a precision value in parametric space, which may //! be used by approximation algorithms. The purpose of this //! function is to provide an acceptable level of precision in @@ -295,70 +288,48 @@ public: //! segment whose length is equal to 100. (default value), or T. //! The parametric tolerance of intersection is equal to : //! - Precision::Approximation() / 100., or Precision::Approximation() / T. - static Standard_Real PApproximation (const Standard_Real T); - + static Standard_Real PApproximation (const Standard_Real T) { return Parametric(Approximation(),T); } + //! Convert a real space precision to a parametric //! space precision on a default curve. //! //! Value is Parametric(P,1.e+2) - static Standard_Real Parametric (const Standard_Real P); - + static Standard_Real Parametric (const Standard_Real P) { return Parametric (P, 100.0); } + //! Used to test distances in parametric space on a //! default curve. //! //! This is Precision::Parametric(Precision::Confusion()) - static Standard_Real PConfusion(); - + static Standard_Real PConfusion() { return Parametric (Confusion()); } + //! Used for Intersections in parametric space on a //! default curve. //! //! This is Precision::Parametric(Precision::Intersection()) - static Standard_Real PIntersection(); - + static Standard_Real PIntersection() { return Parametric (Intersection()); } + //! Used for Approximations in parametric space on a //! default curve. //! //! This is Precision::Parametric(Precision::Approximation()) - static Standard_Real PApproximation(); - + static Standard_Real PApproximation() { return Parametric (Approximation()); } + //! Returns True if R may be considered as an infinite //! number. Currently Abs(R) > 1e100 - static Standard_Boolean IsInfinite (const Standard_Real R); - + static Standard_Boolean IsInfinite (const Standard_Real R) { return Abs (R) >= (0.5 * Precision::Infinite()); } + //! Returns True if R may be considered as a positive //! infinite number. Currently R > 1e100 - static Standard_Boolean IsPositiveInfinite (const Standard_Real R); - + static Standard_Boolean IsPositiveInfinite (const Standard_Real R) { return R >= (0.5 * Precision::Infinite()); } + //! Returns True if R may be considered as a negative //! infinite number. Currently R < -1e100 - static Standard_Boolean IsNegativeInfinite (const Standard_Real R); - + static Standard_Boolean IsNegativeInfinite (const Standard_Real R) { return R <= -(0.5 * Precision::Infinite()); } + //! Returns a big number that can be considered as //! infinite. Use -Infinite() for a negative big number. - static Standard_Real Infinite(); - - - - -protected: - - - - - -private: - - - - + static Standard_Real Infinite() { return 2.e+100; } }; - -#include - - - - - #endif // _Precision_HeaderFile diff --git a/src/Precision/Precision.lxx b/src/Precision/Precision.lxx deleted file mode 100644 index d5b698cc9e..0000000000 --- a/src/Precision/Precision.lxx +++ /dev/null @@ -1,229 +0,0 @@ -// Created on: 1993-03-08 -// Created by: Remi LEQUETTE -// Copyright (c) 1993-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -//======================================================================= -//function : Angular -//purpose : -//======================================================================= - -inline Standard_Real Precision::Angular() -{ -#ifdef PRECISION_OBSOLETE - static const Standard_Real Precision_Angular = 1.e-12; - return Precision_Angular; -#else - return 1.e-12; -#endif -} - - -//======================================================================= -//function : Confusion -//purpose : -//======================================================================= - -inline Standard_Real Precision::Confusion() -{ -#ifdef PRECISION_OBSOLETE - static const Standard_Real Precision_Confusion = 1.e-7; - return Precision_Confusion; -#else - return 1.e-7; -#endif -} - - -//======================================================================= -//function : SquareConfusion -//purpose : -//======================================================================= -inline Standard_Real Precision::SquareConfusion() -{ - return Confusion() * Confusion(); -} - - -//======================================================================= -//function : Intersection -//purpose : -//======================================================================= - -inline Standard_Real Precision::Intersection() -{ -#ifdef PRECISION_OBSOLETE - static const Standard_Real Precision_Intersection = Precision::Confusion() / 100.; - return Precision_Intersection; -#else - return Confusion() * 0.01; -#endif -} - - -//======================================================================= -//function : Approximation -//purpose : -//======================================================================= - -inline Standard_Real Precision::Approximation() -{ -#ifdef PRECISION_OBSOLETE - static const Standard_Real Precision_Approximation = Precision::Confusion() * 10.; - return Precision_Approximation; -#else - return Confusion() * 10.; -#endif -} - - -//======================================================================= -//function : Parametric -//purpose : -//======================================================================= - -inline Standard_Real Precision::Parametric(const Standard_Real P, - const Standard_Real T) -{ - return P / T; -} - - -//======================================================================= -//function : PConfusion -//purpose : -//======================================================================= - -inline Standard_Real Precision::PConfusion(const Standard_Real T) -{ - return Parametric(Confusion(),T); -} - - -//======================================================================= -//function : PIntersection -//purpose : -//======================================================================= - -inline Standard_Real Precision::PIntersection(const Standard_Real T) -{ - return Parametric(Intersection(),T); -} - - -//======================================================================= -//function : PApproximation -//purpose : -//======================================================================= - -inline Standard_Real Precision::PApproximation(const Standard_Real T) -{ - return Parametric(Approximation(),T); -} - -//======================================================================= -//function : Parametric -//purpose : -//======================================================================= - -inline Standard_Real Precision::Parametric(const Standard_Real P) -{ -#ifdef PRECISION_OBSOLETE - static const Standard_Real Precision_DefTangent = 1.e+2; - return Parametric(P,Precision_DefTangent); -#else - return Parametric(P, 100.); -#endif -} - - -//======================================================================= -//function : PConfusion -//purpose : -//======================================================================= - -inline Standard_Real Precision::PConfusion() -{ - return Parametric(Confusion()); -} - - -//======================================================================= -//function : PIntersection -//purpose : -//======================================================================= - -inline Standard_Real Precision::PIntersection() -{ - return Parametric(Intersection()); -} - - -//======================================================================= -//function : PApproximation -//purpose : -//======================================================================= - -inline Standard_Real Precision::PApproximation() -{ - return Parametric(Approximation()); -} - -//======================================================================= -//function : IsInfinite -//purpose : -//======================================================================= - -inline Standard_Boolean Precision::IsInfinite(const Standard_Real R) -{ - return Abs(R) >= (0.5*Precision::Infinite()); -} - -//======================================================================= -//function : IsPositiveInfinite -//purpose : -//======================================================================= - -inline Standard_Boolean Precision::IsPositiveInfinite(const Standard_Real R) -{ - return R >= (0.5*Precision::Infinite()); -} - -//======================================================================= -//function : IsNegativeInfinite -//purpose : -//======================================================================= - -inline Standard_Boolean Precision::IsNegativeInfinite(const Standard_Real R) -{ - return R <= -(0.5*Precision::Infinite()); -} - - -//======================================================================= -//function : Infinite -//purpose : -//======================================================================= - -inline Standard_Real Precision::Infinite() -{ -#ifdef PRECISION_OBSOLETE - static const Standard_Real Precision_Infinite = 1.e+100; - static const Standard_Real Precision_InfiniteValue = 2 * Precision_Infinite; - return Precision_InfiniteValue; -#else - return 2.e+100; -#endif -} -