0023024: Update headers of OCCT files
[occt.git] / src / Intrv / Intrv_Interval.cxx
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#include <Intrv_Interval.ixx>
23
24// **-----------**** Other
25// ***-----* Before
26// ***------------* JustBefore
27// ***-----------------* OverlappingAtStart
28// ***--------------------------* JustEnclosingAtEnd
29// ***-------------------------------------* Enclosing
30// ***----* JustOverlappingAtStart
31// ***-------------* Similar
32// ***------------------------* JustEnclosingAtStart
33// ***-* Inside
34// ***------* JustOverlappingAtEnd
35// ***-----------------* OverlappingAtEnd
36// ***--------* JustAfter
37// ***---* After
38
39//=======================================================================
40//function : Intrv_Interval
41//purpose :
42//=======================================================================
43
44Intrv_Interval::Intrv_Interval
45 () : myStart(RealFirst()), myEnd (RealLast ())
46{
47 myTolStart = (Standard_ShortReal)Epsilon(RealFirst());
48 myTolEnd = (Standard_ShortReal)Epsilon(RealLast ());
49}
50
51//=======================================================================
52//function : Intrv_Interval
53//purpose :
54//=======================================================================
55
56Intrv_Interval::Intrv_Interval
57 (const Standard_Real Start, const Standard_Real End) :
58 myStart(Start), myEnd (End)
59{
60 myTolStart = (Standard_ShortReal)Epsilon(myStart);
61 myTolEnd = (Standard_ShortReal)Epsilon(myEnd);
62}
63
64//=======================================================================
65//function : Intrv_Interval
66//purpose :
67//=======================================================================
68
69Intrv_Interval::Intrv_Interval
70(const Standard_Real Start, const Standard_ShortReal TolStart,
71 const Standard_Real End , const Standard_ShortReal TolEnd) :
72myStart(Start), myEnd (End),
73myTolStart(TolStart),myTolEnd (TolEnd)
74{
75 Standard_ShortReal epsStart = (Standard_ShortReal)Epsilon(myStart);
76 Standard_ShortReal epsEnd = (Standard_ShortReal)Epsilon(myEnd);
77 if (myTolStart < epsStart) myTolStart = epsStart;
78 if (myTolEnd < epsEnd ) myTolEnd = epsEnd;
79}
80
81//=======================================================================
82//function : Position
83//purpose :
84//=======================================================================
85
86Intrv_Position Intrv_Interval::Position (const Intrv_Interval& Other) const
87{
88 Standard_Real mySMin = myStart - myTolStart;
89 Standard_Real mySMax = myStart + myTolStart;
90 Standard_Real myEMin = myEnd - myTolEnd ;
91 Standard_Real myEMax = myEnd + myTolEnd ;
92 Standard_Real otSMin = Other.myStart - Other.myTolStart;
93 Standard_Real otSMax = Other.myStart + Other.myTolStart;
94 Standard_Real otEMin = Other.myEnd - Other.myTolEnd ;
95 Standard_Real otEMax = Other.myEnd + Other.myTolEnd ;
96 Intrv_Position P;
97 if ( mySMax < otSMin ) {
98 if ( myEMax < otSMin ) P = Intrv_Before;
99 else if ( otSMax >= myEMin ) P = Intrv_JustBefore;
100 else if ( myEMax < otEMin ) P = Intrv_OverlappingAtStart;
101 else if ( otEMax >= myEMin ) P = Intrv_JustEnclosingAtEnd;
102 else P = Intrv_Enclosing;
103 }
104 else if ( otSMax >= mySMin ) {
105 if ( myEMax < otEMin ) P = Intrv_JustOverlappingAtStart;
106 else if ( otEMax >= myEMin ) P = Intrv_Similar;
107 else P = Intrv_JustEnclosingAtStart;
108 }
109 else if ( mySMax < otEMin ) {
110 if ( myEMax < otEMin ) P = Intrv_Inside;
111 else if ( otEMax >= myEMin ) P = Intrv_JustOverlappingAtEnd;
112 else P = Intrv_OverlappingAtEnd;
113 }
114 else if ( otEMax >= mySMin ) P = Intrv_JustAfter;
115 else P = Intrv_After;
116 return P;
117}
118