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