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