Test for 0022778: Bug in BRepMesh
[occt.git] / src / Precision / Precision.lxx
1 // Created on: 1993-03-08
2 // Created by: Remi LEQUETTE
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
5 //
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
10 //
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13 //
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
20
21
22
23 //=======================================================================
24 //function : Angular
25 //purpose  : 
26 //=======================================================================
27
28 inline Standard_Real  Precision::Angular()
29 {
30 #ifdef PRECISION_OBSOLETE
31   static const Standard_Real Precision_Angular        = 1.e-12;
32   return Precision_Angular;
33 #else
34   return 1.e-12;
35 #endif
36 }
37
38
39 //=======================================================================
40 //function : Confusion
41 //purpose  : 
42 //=======================================================================
43
44 inline Standard_Real  Precision::Confusion()
45 {
46 #ifdef PRECISION_OBSOLETE
47   static const Standard_Real Precision_Confusion      = 1.e-7;
48   return Precision_Confusion;
49 #else
50   return 1.e-7;
51 #endif
52 }
53
54
55 //=======================================================================
56 //function : SquareConfusion
57 //purpose  : 
58 //=======================================================================
59 inline Standard_Real Precision::SquareConfusion()
60 {
61   return Confusion() * Confusion();
62 }
63
64
65 //=======================================================================
66 //function : Intersection
67 //purpose  : 
68 //=======================================================================
69
70 inline Standard_Real  Precision::Intersection()
71 {
72 #ifdef PRECISION_OBSOLETE
73   static const Standard_Real Precision_Intersection   = Precision::Confusion() / 100.;
74   return Precision_Intersection;
75 #else
76   return Confusion() * 0.01;
77 #endif
78 }
79
80
81 //=======================================================================
82 //function : Approximation
83 //purpose  : 
84 //=======================================================================
85
86 inline Standard_Real  Precision::Approximation()
87 {
88 #ifdef PRECISION_OBSOLETE
89   static const Standard_Real Precision_Approximation  = Precision::Confusion() * 10.;
90   return Precision_Approximation;
91 #else
92   return Confusion() * 10.;
93 #endif
94 }
95
96
97 //=======================================================================
98 //function : Parametric
99 //purpose  : 
100 //=======================================================================
101
102 inline Standard_Real  Precision::Parametric(const Standard_Real P,
103                                             const Standard_Real T)
104 {
105   return P / T;
106 }
107
108
109 //=======================================================================
110 //function : PConfusion
111 //purpose  : 
112 //=======================================================================
113
114 inline Standard_Real  Precision::PConfusion(const Standard_Real T)
115 {
116   return Parametric(Confusion(),T);
117 }
118
119
120 //=======================================================================
121 //function : PIntersection
122 //purpose  : 
123 //=======================================================================
124
125 inline Standard_Real  Precision::PIntersection(const Standard_Real T)
126 {
127   return Parametric(Intersection(),T);
128 }
129
130
131 //=======================================================================
132 //function : PApproximation
133 //purpose  : 
134 //=======================================================================
135
136 inline Standard_Real  Precision::PApproximation(const Standard_Real T)
137 {
138   return Parametric(Approximation(),T);
139 }
140
141 //=======================================================================
142 //function : Parametric
143 //purpose  : 
144 //=======================================================================
145
146 inline Standard_Real  Precision::Parametric(const Standard_Real P)
147 {
148 #ifdef PRECISION_OBSOLETE
149   static const Standard_Real Precision_DefTangent     = 1.e+2;
150   return Parametric(P,Precision_DefTangent);
151 #else
152   return Parametric(P, 100.);
153 #endif
154 }
155
156
157 //=======================================================================
158 //function : PConfusion
159 //purpose  : 
160 //=======================================================================
161
162 inline Standard_Real  Precision::PConfusion()
163 {
164   return Parametric(Confusion());
165 }
166
167
168 //=======================================================================
169 //function : PIntersection
170 //purpose  : 
171 //=======================================================================
172
173 inline Standard_Real  Precision::PIntersection()
174 {
175   return Parametric(Intersection());
176 }
177
178
179 //=======================================================================
180 //function : PApproximation
181 //purpose  : 
182 //=======================================================================
183
184 inline Standard_Real  Precision::PApproximation()
185 {
186   return Parametric(Approximation());
187 }
188
189 //=======================================================================
190 //function : IsInfinite
191 //purpose  : 
192 //=======================================================================
193
194 inline Standard_Boolean  Precision::IsInfinite(const Standard_Real R)
195 {
196   return Abs(R) >= (0.5*Precision::Infinite());
197 }
198
199 //=======================================================================
200 //function : IsPositiveInfinite
201 //purpose  : 
202 //=======================================================================
203
204 inline Standard_Boolean  Precision::IsPositiveInfinite(const Standard_Real R)
205 {
206   return R >= (0.5*Precision::Infinite());
207 }
208
209 //=======================================================================
210 //function : IsNegativeInfinite
211 //purpose  : 
212 //=======================================================================
213
214 inline Standard_Boolean  Precision::IsNegativeInfinite(const Standard_Real R)
215 {
216   return R <= -(0.5*Precision::Infinite());
217 }
218
219
220 //=======================================================================
221 //function : Infinite
222 //purpose  : 
223 //=======================================================================
224
225 inline Standard_Real  Precision::Infinite()
226 {
227 #ifdef PRECISION_OBSOLETE
228   static const Standard_Real Precision_Infinite       = 1.e+100;
229   static const Standard_Real Precision_InfiniteValue  = 2 * Precision_Infinite;
230   return Precision_InfiniteValue;
231 #else
232   return 2.e+100;
233 #endif
234 }
235