1 // Created on: 1991-12-13
2 // Created by: Christophe MARION
3 // Copyright (c) 1991-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 // **-----------**** Other
19 // ***------------* IsJustBefore
20 // ***-----------------* IsOverlappingAtStart
21 // ***--------------------------* IsJustEnclosingAtEnd
22 // ***-------------------------------------* IsEnclosing
23 // ***----* IsJustOverlappingAtStart
24 // ***-------------* IsSimilar
25 // ***------------------------* IsJustEnclosingAtStart
27 // ***------* IsJustOverlappingAtEnd
28 // ***-----------------* IsOverlappingAtEnd
29 // ***--------* IsJustAfter
32 //=======================================================================
35 //=======================================================================
37 inline Standard_Real Intrv_Interval::Start () const
40 //=======================================================================
43 //=======================================================================
45 inline Standard_Real Intrv_Interval::End () const
48 //=======================================================================
51 //=======================================================================
53 inline Standard_ShortReal Intrv_Interval::TolStart () const
54 { return myTolStart; }
56 //=======================================================================
59 //=======================================================================
61 inline Standard_ShortReal Intrv_Interval::TolEnd () const
64 //=======================================================================
67 //=======================================================================
69 inline void Intrv_Interval::Bounds
70 (Standard_Real& Start, Standard_ShortReal& TolStart,
71 Standard_Real& End , Standard_ShortReal& TolEnd) const
74 TolStart = myTolStart;
79 //=======================================================================
82 //=======================================================================
84 inline void Intrv_Interval::SetStart
85 (const Standard_Real Start, const Standard_ShortReal TolStart)
88 myTolStart = TolStart;
91 //=======================================================================
92 //function : FuseAtStart
94 // ****+****--------------------> Old one
95 // ****+****------------------------> New one to fuse
97 // ****+****------------------------> result
99 //=======================================================================
101 inline void Intrv_Interval::FuseAtStart
102 (const Standard_Real Start, const Standard_ShortReal TolStart)
104 if (myStart != RealFirst()) {
105 Standard_Real a = Min(myStart-myTolStart,Start-TolStart);
106 Standard_Real b = Min(myStart+myTolStart,Start+TolStart);
108 myTolStart = (Standard_ShortReal)(b-a)/2;
112 //=======================================================================
113 //function : CutAtStart
115 // ****+****-----------> Old one
116 // <----------**+** Tool for cutting
118 // ****+****-----------> result
120 //=======================================================================
122 inline void Intrv_Interval::CutAtStart
123 (const Standard_Real Start, const Standard_ShortReal TolStart)
125 if (myStart != RealFirst()) {
126 Standard_Real a = Max(myStart-myTolStart,Start-TolStart);
127 Standard_Real b = Max(myStart+myTolStart,Start+TolStart);
129 myTolStart = (Standard_ShortReal)(b-a)/2;
133 //=======================================================================
136 //=======================================================================
138 inline void Intrv_Interval::SetEnd
139 (const Standard_Real End, const Standard_ShortReal TolEnd)
145 //=======================================================================
146 //function : FuseAtEnd
148 // <---------------------****+**** Old one
149 // <-----------------**+** New one to fuse
151 // <---------------------****+**** result
153 //=======================================================================
155 inline void Intrv_Interval::FuseAtEnd
156 (const Standard_Real End, const Standard_ShortReal TolEnd)
158 if (myEnd != RealLast()) {
159 Standard_Real a = Max(myEnd-myTolEnd,End-TolEnd);
160 Standard_Real b = Max(myEnd+myTolEnd,End+TolEnd);
162 myTolEnd = (Standard_ShortReal)(b-a)/2;
166 //=======================================================================
167 //function : CutAtEnd
169 // <-----****+**** Old one
170 // **+**------> Tool for cutting
172 // <-----****+**** result
174 //=======================================================================
176 inline void Intrv_Interval::CutAtEnd
177 (const Standard_Real End, const Standard_ShortReal TolEnd)
179 if (myEnd != RealLast()) {
180 Standard_Real a = Min(myEnd-myTolEnd,End-TolEnd);
181 Standard_Real b = Min(myEnd+myTolEnd,End+TolEnd);
183 myTolEnd = (Standard_ShortReal)(b-a)/2;
187 //=======================================================================
188 //function : AreFused
190 //=======================================================================
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); }
197 //=======================================================================
198 //function : IsProbablyEmpty
200 //=======================================================================
202 inline Standard_Boolean Intrv_Interval::IsProbablyEmpty () const
203 { return AreFused (myStart, myTolStart, myEnd, myTolEnd); }
205 //=======================================================================
206 // **-----------**** Other
207 // ***-----* IsBefore
208 //=======================================================================
210 inline Standard_Boolean Intrv_Interval::IsBefore
211 (const Intrv_Interval& Other) const
212 { return myTolEnd + Other.myTolStart < Other.myStart - myEnd; }
214 //=======================================================================
215 // **-----------**** Other
217 //=======================================================================
219 inline Standard_Boolean Intrv_Interval::IsAfter
220 (const Intrv_Interval& Other) const
221 { return myTolStart + Other.myTolEnd < myStart - Other.myEnd; }
223 //=======================================================================
224 // **-----------**** Other
226 //=======================================================================
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; }
233 //=======================================================================
234 // **-----------**** Other
235 // ***-------------------------------------* IsEnclosing
236 //=======================================================================
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; }
243 //=======================================================================
244 // **-----------**** Other
245 // ***------------------------* IsJustEnclosingAtStart
246 //=======================================================================
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; }
253 //=======================================================================
254 // **-----------**** Other
255 // ***--------------------------* IsJustEnclosingAtEnd
256 //=======================================================================
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); }
263 //=======================================================================
264 // **-----------**** Other
265 // ***------------* IsJustBefore
266 //=======================================================================
268 inline Standard_Boolean Intrv_Interval::IsJustBefore
269 (const Intrv_Interval& Other) const
270 { return AreFused (myEnd, myTolEnd, Other.myStart, Other.myTolStart); }
272 //=======================================================================
273 // **-----------**** Other
274 // ***--------* IsJustAfter
275 //=======================================================================
277 inline Standard_Boolean Intrv_Interval::IsJustAfter
278 (const Intrv_Interval& Other) const
279 { return AreFused (Other.myEnd, Other.myTolEnd, myStart, myTolStart); }
281 //=======================================================================
282 // **-----------**** Other
283 // ***-----------------* IsOverlappingAtStart
284 //=======================================================================
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 ; }
292 //=======================================================================
293 // **-----------**** Other
294 // ***-----------------* IsOverlappingAtEnd
295 //=======================================================================
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; }
303 //=======================================================================
304 // **-----------**** Other
305 // ***----* IsJustOverlappingAtStart
306 //=======================================================================
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; }
313 //=======================================================================
314 // **-----------**** Other
315 // ***------* IsJustOverlappingAtEnd
316 //=======================================================================
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); }
323 //=======================================================================
324 // **-----------**** Other
325 // ***-------------* IsSimilar
326 //=======================================================================
328 inline Standard_Boolean Intrv_Interval::IsSimilar
329 (const Intrv_Interval& Other) const
331 Standard_Boolean b1,b2;
332 b1 = AreFused (myStart,myTolStart,Other.myStart,Other.myTolStart);
333 b2 = AreFused (myEnd ,myTolEnd ,Other.myEnd ,Other.myTolEnd);