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