b311480e |
1 | // Created on: 1991-12-13 |
2 | // Created by: Christophe MARION |
3 | // Copyright (c) 1991-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
d5f74e42 |
8 | // This library is free software; you can redistribute it and/or modify it under |
9 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
10 | // by the Free Software Foundation, with special exception defined in the file |
11 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
12 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
7fd59977 |
16 | |
17 | // **-----------**** Other |
18 | // ***-----* IsBefore |
19 | // ***------------* IsJustBefore |
20 | // ***-----------------* IsOverlappingAtStart |
21 | // ***--------------------------* IsJustEnclosingAtEnd |
22 | // ***-------------------------------------* IsEnclosing |
23 | // ***----* IsJustOverlappingAtStart |
24 | // ***-------------* IsSimilar |
25 | // ***------------------------* IsJustEnclosingAtStart |
26 | // ***-* IsInside |
27 | // ***------* IsJustOverlappingAtEnd |
28 | // ***-----------------* IsOverlappingAtEnd |
29 | // ***--------* IsJustAfter |
30 | // ***---* IsAfter |
31 | |
32 | //======================================================================= |
33 | //function : Start |
34 | //purpose : |
35 | //======================================================================= |
36 | |
37 | inline Standard_Real Intrv_Interval::Start () const |
38 | { return myStart; } |
39 | |
40 | //======================================================================= |
41 | //function : End |
42 | //purpose : |
43 | //======================================================================= |
44 | |
45 | inline Standard_Real Intrv_Interval::End () const |
46 | { return myEnd; } |
47 | |
48 | //======================================================================= |
49 | //function : TolStart |
50 | //purpose : |
51 | //======================================================================= |
52 | |
53 | inline Standard_ShortReal Intrv_Interval::TolStart () const |
54 | { return myTolStart; } |
55 | |
56 | //======================================================================= |
57 | //function : TolEnd |
58 | //purpose : |
59 | //======================================================================= |
60 | |
61 | inline Standard_ShortReal Intrv_Interval::TolEnd () const |
62 | { return myTolEnd; } |
63 | |
64 | //======================================================================= |
65 | //function : Bounds |
66 | //purpose : |
67 | //======================================================================= |
68 | |
69 | inline void Intrv_Interval::Bounds |
70 | (Standard_Real& Start, Standard_ShortReal& TolStart, |
71 | Standard_Real& End , Standard_ShortReal& TolEnd) const |
72 | { |
73 | Start = myStart; |
74 | TolStart = myTolStart; |
75 | End = myEnd; |
76 | TolEnd = myTolEnd; |
77 | } |
78 | |
79 | //======================================================================= |
80 | //function : SetStart |
81 | //purpose : |
82 | //======================================================================= |
83 | |
84 | inline void Intrv_Interval::SetStart |
85 | (const Standard_Real Start, const Standard_ShortReal TolStart) |
86 | { |
87 | myStart = Start; |
88 | myTolStart = TolStart; |
89 | } |
90 | |
91 | //======================================================================= |
92 | //function : FuseAtStart |
93 | // |
94 | // ****+****--------------------> Old one |
95 | // ****+****------------------------> New one to fuse |
96 | // <<< <<< |
97 | // ****+****------------------------> result |
98 | // |
99 | //======================================================================= |
100 | |
101 | inline void Intrv_Interval::FuseAtStart |
102 | (const Standard_Real Start, const Standard_ShortReal TolStart) |
103 | { |
104 | if (myStart != RealFirst()) { |
105 | Standard_Real a = Min(myStart-myTolStart,Start-TolStart); |
106 | Standard_Real b = Min(myStart+myTolStart,Start+TolStart); |
107 | myStart = (a+b)/2; |
108 | myTolStart = (Standard_ShortReal)(b-a)/2; |
109 | } |
110 | } |
111 | |
112 | //======================================================================= |
113 | //function : CutAtStart |
114 | // |
115 | // ****+****-----------> Old one |
116 | // <----------**+** Tool for cutting |
117 | // >>> >>> |
118 | // ****+****-----------> result |
119 | // |
120 | //======================================================================= |
121 | |
122 | inline void Intrv_Interval::CutAtStart |
123 | (const Standard_Real Start, const Standard_ShortReal TolStart) |
124 | { |
125 | if (myStart != RealFirst()) { |
126 | Standard_Real a = Max(myStart-myTolStart,Start-TolStart); |
127 | Standard_Real b = Max(myStart+myTolStart,Start+TolStart); |
128 | myStart = (a+b)/2; |
129 | myTolStart = (Standard_ShortReal)(b-a)/2; |
130 | } |
131 | } |
132 | |
133 | //======================================================================= |
134 | //function : SetEnd |
135 | //purpose : |
136 | //======================================================================= |
137 | |
138 | inline void Intrv_Interval::SetEnd |
139 | (const Standard_Real End, const Standard_ShortReal TolEnd) |
140 | { |
141 | myEnd = End; |
142 | myTolEnd = TolEnd; |
143 | } |
144 | |
145 | //======================================================================= |
146 | //function : FuseAtEnd |
147 | // |
148 | // <---------------------****+**** Old one |
149 | // <-----------------**+** New one to fuse |
150 | // >>> >>> |
151 | // <---------------------****+**** result |
152 | // |
153 | //======================================================================= |
154 | |
155 | inline void Intrv_Interval::FuseAtEnd |
156 | (const Standard_Real End, const Standard_ShortReal TolEnd) |
157 | { |
158 | if (myEnd != RealLast()) { |
159 | Standard_Real a = Max(myEnd-myTolEnd,End-TolEnd); |
160 | Standard_Real b = Max(myEnd+myTolEnd,End+TolEnd); |
161 | myEnd = (a+b)/2; |
162 | myTolEnd = (Standard_ShortReal)(b-a)/2; |
163 | } |
164 | } |
165 | |
166 | //======================================================================= |
167 | //function : CutAtEnd |
168 | // |
169 | // <-----****+**** Old one |
170 | // **+**------> Tool for cutting |
171 | // <<< <<< |
172 | // <-----****+**** result |
173 | // |
174 | //======================================================================= |
175 | |
176 | inline void Intrv_Interval::CutAtEnd |
177 | (const Standard_Real End, const Standard_ShortReal TolEnd) |
178 | { |
179 | if (myEnd != RealLast()) { |
180 | Standard_Real a = Min(myEnd-myTolEnd,End-TolEnd); |
181 | Standard_Real b = Min(myEnd+myTolEnd,End+TolEnd); |
182 | myEnd = (a+b)/2; |
183 | myTolEnd = (Standard_ShortReal)(b-a)/2; |
184 | } |
185 | } |
186 | |
187 | //======================================================================= |
188 | //function : AreFused |
189 | //purpose : |
190 | //======================================================================= |
191 | |
192 | inline Standard_Boolean AreFused |
193 | (const Standard_Real c1,const Standard_ShortReal t1, |
194 | const Standard_Real c2,const Standard_ShortReal t2) |
195 | { return t1 + t2 >= Abs (c1 - c2); } |
196 | |
197 | //======================================================================= |
198 | //function : IsProbablyEmpty |
199 | //purpose : |
200 | //======================================================================= |
201 | |
202 | inline Standard_Boolean Intrv_Interval::IsProbablyEmpty () const |
203 | { return AreFused (myStart, myTolStart, myEnd, myTolEnd); } |
204 | |
205 | //======================================================================= |
206 | // **-----------**** Other |
207 | // ***-----* IsBefore |
208 | //======================================================================= |
209 | |
210 | inline Standard_Boolean Intrv_Interval::IsBefore |
211 | (const Intrv_Interval& Other) const |
212 | { return myTolEnd + Other.myTolStart < Other.myStart - myEnd; } |
213 | |
214 | //======================================================================= |
215 | // **-----------**** Other |
216 | // ***---* IsAfter |
217 | //======================================================================= |
218 | |
219 | inline Standard_Boolean Intrv_Interval::IsAfter |
220 | (const Intrv_Interval& Other) const |
221 | { return myTolStart + Other.myTolEnd < myStart - Other.myEnd; } |
222 | |
223 | //======================================================================= |
224 | // **-----------**** Other |
225 | // ***-* IsInside |
226 | //======================================================================= |
227 | |
228 | inline Standard_Boolean Intrv_Interval::IsInside |
229 | (const Intrv_Interval& Other) const |
230 | { return myTolStart + Other.myTolStart < myStart - Other.myStart && |
231 | myTolEnd + Other.myTolEnd < Other.myEnd - myEnd; } |
232 | |
233 | //======================================================================= |
234 | // **-----------**** Other |
235 | // ***-------------------------------------* IsEnclosing |
236 | //======================================================================= |
237 | |
238 | inline Standard_Boolean Intrv_Interval::IsEnclosing |
239 | (const Intrv_Interval& Other) const |
240 | { return myTolStart + Other.myTolStart < Other.myStart - myStart && |
241 | myTolEnd + Other.myTolEnd < myEnd - Other.myEnd; } |
242 | |
243 | //======================================================================= |
244 | // **-----------**** Other |
245 | // ***------------------------* IsJustEnclosingAtStart |
246 | //======================================================================= |
247 | |
248 | inline Standard_Boolean Intrv_Interval::IsJustEnclosingAtStart |
249 | (const Intrv_Interval& Other) const |
250 | { return AreFused (myStart, myTolStart, Other.myStart, Other.myTolStart) && |
251 | myTolEnd + Other.myTolEnd < myEnd - Other.myEnd; } |
252 | |
253 | //======================================================================= |
254 | // **-----------**** Other |
255 | // ***--------------------------* IsJustEnclosingAtEnd |
256 | //======================================================================= |
257 | |
258 | inline Standard_Boolean Intrv_Interval::IsJustEnclosingAtEnd |
259 | (const Intrv_Interval& Other) const |
260 | { return myTolStart + Other.myTolStart < Other.myStart - myStart && |
261 | AreFused (Other.myEnd, Other.myTolEnd, myEnd, myTolEnd); } |
262 | |
263 | //======================================================================= |
264 | // **-----------**** Other |
265 | // ***------------* IsJustBefore |
266 | //======================================================================= |
267 | |
268 | inline Standard_Boolean Intrv_Interval::IsJustBefore |
269 | (const Intrv_Interval& Other) const |
270 | { return AreFused (myEnd, myTolEnd, Other.myStart, Other.myTolStart); } |
271 | |
272 | //======================================================================= |
273 | // **-----------**** Other |
274 | // ***--------* IsJustAfter |
275 | //======================================================================= |
276 | |
277 | inline Standard_Boolean Intrv_Interval::IsJustAfter |
278 | (const Intrv_Interval& Other) const |
279 | { return AreFused (Other.myEnd, Other.myTolEnd, myStart, myTolStart); } |
280 | |
281 | //======================================================================= |
282 | // **-----------**** Other |
283 | // ***-----------------* IsOverlappingAtStart |
284 | //======================================================================= |
285 | |
286 | inline Standard_Boolean Intrv_Interval::IsOverlappingAtStart |
287 | (const Intrv_Interval& Other) const |
288 | { return myTolStart + Other.myTolStart < Other.myStart - myStart && |
289 | myTolEnd + Other.myTolStart < myEnd - Other.myStart && |
290 | myTolEnd + Other.myTolEnd < Other.myEnd - myEnd ; } |
291 | |
292 | //======================================================================= |
293 | // **-----------**** Other |
294 | // ***-----------------* IsOverlappingAtEnd |
295 | //======================================================================= |
296 | |
297 | inline Standard_Boolean Intrv_Interval::IsOverlappingAtEnd |
298 | (const Intrv_Interval& Other) const |
299 | { return myTolStart + Other.myTolStart < myStart - Other.myStart && |
300 | myTolStart + Other.myTolEnd < Other.myEnd - myStart && |
301 | myTolEnd + Other.myTolEnd < myEnd - Other.myEnd; } |
302 | |
303 | //======================================================================= |
304 | // **-----------**** Other |
305 | // ***----* IsJustOverlappingAtStart |
306 | //======================================================================= |
307 | |
308 | inline Standard_Boolean Intrv_Interval::IsJustOverlappingAtStart |
309 | (const Intrv_Interval& Other) const |
310 | { return AreFused (myStart, myTolStart, Other.myStart, Other.myTolStart) && |
311 | myTolEnd + Other.myTolEnd < Other.myEnd - myEnd; } |
312 | |
313 | //======================================================================= |
314 | // **-----------**** Other |
315 | // ***------* IsJustOverlappingAtEnd |
316 | //======================================================================= |
317 | |
318 | inline Standard_Boolean Intrv_Interval::IsJustOverlappingAtEnd |
319 | (const Intrv_Interval& Other) const |
320 | { return myTolStart + Other.myTolStart < myStart - Other.myStart && |
321 | AreFused (Other.myEnd, Other.myTolEnd, myEnd, myTolEnd); } |
322 | |
323 | //======================================================================= |
324 | // **-----------**** Other |
325 | // ***-------------* IsSimilar |
326 | //======================================================================= |
327 | |
328 | inline Standard_Boolean Intrv_Interval::IsSimilar |
329 | (const Intrv_Interval& Other) const |
330 | { |
331 | Standard_Boolean b1,b2; |
332 | b1 = AreFused (myStart,myTolStart,Other.myStart,Other.myTolStart); |
333 | b2 = AreFused (myEnd ,myTolEnd ,Other.myEnd ,Other.myTolEnd); |
334 | return b1 && b2; |
335 | } |
336 | |