1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-07 18:30:55 +03:00
occt/src/Intrv/Intrv_Interval.lxx
abv d5f74e42d6 0024624: Lost word in license statement in source files
License statement text corrected; compiler warnings caused by Bison 2.41 disabled for MSVC; a few other compiler warnings on 54-bit Windows eliminated by appropriate type cast
Wrong license statements corrected in several files.
Copyright and license statements added in XSD and GLSL files.
Copyright year updated in some files.
Obsolete documentation files removed from DrawResources.
2014-02-20 16:15:17 +04:00

337 lines
14 KiB
Plaintext

// Created on: 1991-12-13
// Created by: Christophe MARION
// Copyright (c) 1991-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
// **-----------**** Other
// ***-----* IsBefore
// ***------------* IsJustBefore
// ***-----------------* IsOverlappingAtStart
// ***--------------------------* IsJustEnclosingAtEnd
// ***-------------------------------------* IsEnclosing
// ***----* IsJustOverlappingAtStart
// ***-------------* IsSimilar
// ***------------------------* IsJustEnclosingAtStart
// ***-* IsInside
// ***------* IsJustOverlappingAtEnd
// ***-----------------* IsOverlappingAtEnd
// ***--------* IsJustAfter
// ***---* IsAfter
//=======================================================================
//function : Start
//purpose :
//=======================================================================
inline Standard_Real Intrv_Interval::Start () const
{ return myStart; }
//=======================================================================
//function : End
//purpose :
//=======================================================================
inline Standard_Real Intrv_Interval::End () const
{ return myEnd; }
//=======================================================================
//function : TolStart
//purpose :
//=======================================================================
inline Standard_ShortReal Intrv_Interval::TolStart () const
{ return myTolStart; }
//=======================================================================
//function : TolEnd
//purpose :
//=======================================================================
inline Standard_ShortReal Intrv_Interval::TolEnd () const
{ return myTolEnd; }
//=======================================================================
//function : Bounds
//purpose :
//=======================================================================
inline void Intrv_Interval::Bounds
(Standard_Real& Start, Standard_ShortReal& TolStart,
Standard_Real& End , Standard_ShortReal& TolEnd) const
{
Start = myStart;
TolStart = myTolStart;
End = myEnd;
TolEnd = myTolEnd;
}
//=======================================================================
//function : SetStart
//purpose :
//=======================================================================
inline void Intrv_Interval::SetStart
(const Standard_Real Start, const Standard_ShortReal TolStart)
{
myStart = Start;
myTolStart = TolStart;
}
//=======================================================================
//function : FuseAtStart
//
// ****+****--------------------> Old one
// ****+****------------------------> New one to fuse
// <<< <<<
// ****+****------------------------> result
//
//=======================================================================
inline void Intrv_Interval::FuseAtStart
(const Standard_Real Start, const Standard_ShortReal TolStart)
{
if (myStart != RealFirst()) {
Standard_Real a = Min(myStart-myTolStart,Start-TolStart);
Standard_Real b = Min(myStart+myTolStart,Start+TolStart);
myStart = (a+b)/2;
myTolStart = (Standard_ShortReal)(b-a)/2;
}
}
//=======================================================================
//function : CutAtStart
//
// ****+****-----------> Old one
// <----------**+** Tool for cutting
// >>> >>>
// ****+****-----------> result
//
//=======================================================================
inline void Intrv_Interval::CutAtStart
(const Standard_Real Start, const Standard_ShortReal TolStart)
{
if (myStart != RealFirst()) {
Standard_Real a = Max(myStart-myTolStart,Start-TolStart);
Standard_Real b = Max(myStart+myTolStart,Start+TolStart);
myStart = (a+b)/2;
myTolStart = (Standard_ShortReal)(b-a)/2;
}
}
//=======================================================================
//function : SetEnd
//purpose :
//=======================================================================
inline void Intrv_Interval::SetEnd
(const Standard_Real End, const Standard_ShortReal TolEnd)
{
myEnd = End;
myTolEnd = TolEnd;
}
//=======================================================================
//function : FuseAtEnd
//
// <---------------------****+**** Old one
// <-----------------**+** New one to fuse
// >>> >>>
// <---------------------****+**** result
//
//=======================================================================
inline void Intrv_Interval::FuseAtEnd
(const Standard_Real End, const Standard_ShortReal TolEnd)
{
if (myEnd != RealLast()) {
Standard_Real a = Max(myEnd-myTolEnd,End-TolEnd);
Standard_Real b = Max(myEnd+myTolEnd,End+TolEnd);
myEnd = (a+b)/2;
myTolEnd = (Standard_ShortReal)(b-a)/2;
}
}
//=======================================================================
//function : CutAtEnd
//
// <-----****+**** Old one
// **+**------> Tool for cutting
// <<< <<<
// <-----****+**** result
//
//=======================================================================
inline void Intrv_Interval::CutAtEnd
(const Standard_Real End, const Standard_ShortReal TolEnd)
{
if (myEnd != RealLast()) {
Standard_Real a = Min(myEnd-myTolEnd,End-TolEnd);
Standard_Real b = Min(myEnd+myTolEnd,End+TolEnd);
myEnd = (a+b)/2;
myTolEnd = (Standard_ShortReal)(b-a)/2;
}
}
//=======================================================================
//function : AreFused
//purpose :
//=======================================================================
inline Standard_Boolean AreFused
(const Standard_Real c1,const Standard_ShortReal t1,
const Standard_Real c2,const Standard_ShortReal t2)
{ return t1 + t2 >= Abs (c1 - c2); }
//=======================================================================
//function : IsProbablyEmpty
//purpose :
//=======================================================================
inline Standard_Boolean Intrv_Interval::IsProbablyEmpty () const
{ return AreFused (myStart, myTolStart, myEnd, myTolEnd); }
//=======================================================================
// **-----------**** Other
// ***-----* IsBefore
//=======================================================================
inline Standard_Boolean Intrv_Interval::IsBefore
(const Intrv_Interval& Other) const
{ return myTolEnd + Other.myTolStart < Other.myStart - myEnd; }
//=======================================================================
// **-----------**** Other
// ***---* IsAfter
//=======================================================================
inline Standard_Boolean Intrv_Interval::IsAfter
(const Intrv_Interval& Other) const
{ return myTolStart + Other.myTolEnd < myStart - Other.myEnd; }
//=======================================================================
// **-----------**** Other
// ***-* IsInside
//=======================================================================
inline Standard_Boolean Intrv_Interval::IsInside
(const Intrv_Interval& Other) const
{ return myTolStart + Other.myTolStart < myStart - Other.myStart &&
myTolEnd + Other.myTolEnd < Other.myEnd - myEnd; }
//=======================================================================
// **-----------**** Other
// ***-------------------------------------* IsEnclosing
//=======================================================================
inline Standard_Boolean Intrv_Interval::IsEnclosing
(const Intrv_Interval& Other) const
{ return myTolStart + Other.myTolStart < Other.myStart - myStart &&
myTolEnd + Other.myTolEnd < myEnd - Other.myEnd; }
//=======================================================================
// **-----------**** Other
// ***------------------------* IsJustEnclosingAtStart
//=======================================================================
inline Standard_Boolean Intrv_Interval::IsJustEnclosingAtStart
(const Intrv_Interval& Other) const
{ return AreFused (myStart, myTolStart, Other.myStart, Other.myTolStart) &&
myTolEnd + Other.myTolEnd < myEnd - Other.myEnd; }
//=======================================================================
// **-----------**** Other
// ***--------------------------* IsJustEnclosingAtEnd
//=======================================================================
inline Standard_Boolean Intrv_Interval::IsJustEnclosingAtEnd
(const Intrv_Interval& Other) const
{ return myTolStart + Other.myTolStart < Other.myStart - myStart &&
AreFused (Other.myEnd, Other.myTolEnd, myEnd, myTolEnd); }
//=======================================================================
// **-----------**** Other
// ***------------* IsJustBefore
//=======================================================================
inline Standard_Boolean Intrv_Interval::IsJustBefore
(const Intrv_Interval& Other) const
{ return AreFused (myEnd, myTolEnd, Other.myStart, Other.myTolStart); }
//=======================================================================
// **-----------**** Other
// ***--------* IsJustAfter
//=======================================================================
inline Standard_Boolean Intrv_Interval::IsJustAfter
(const Intrv_Interval& Other) const
{ return AreFused (Other.myEnd, Other.myTolEnd, myStart, myTolStart); }
//=======================================================================
// **-----------**** Other
// ***-----------------* IsOverlappingAtStart
//=======================================================================
inline Standard_Boolean Intrv_Interval::IsOverlappingAtStart
(const Intrv_Interval& Other) const
{ return myTolStart + Other.myTolStart < Other.myStart - myStart &&
myTolEnd + Other.myTolStart < myEnd - Other.myStart &&
myTolEnd + Other.myTolEnd < Other.myEnd - myEnd ; }
//=======================================================================
// **-----------**** Other
// ***-----------------* IsOverlappingAtEnd
//=======================================================================
inline Standard_Boolean Intrv_Interval::IsOverlappingAtEnd
(const Intrv_Interval& Other) const
{ return myTolStart + Other.myTolStart < myStart - Other.myStart &&
myTolStart + Other.myTolEnd < Other.myEnd - myStart &&
myTolEnd + Other.myTolEnd < myEnd - Other.myEnd; }
//=======================================================================
// **-----------**** Other
// ***----* IsJustOverlappingAtStart
//=======================================================================
inline Standard_Boolean Intrv_Interval::IsJustOverlappingAtStart
(const Intrv_Interval& Other) const
{ return AreFused (myStart, myTolStart, Other.myStart, Other.myTolStart) &&
myTolEnd + Other.myTolEnd < Other.myEnd - myEnd; }
//=======================================================================
// **-----------**** Other
// ***------* IsJustOverlappingAtEnd
//=======================================================================
inline Standard_Boolean Intrv_Interval::IsJustOverlappingAtEnd
(const Intrv_Interval& Other) const
{ return myTolStart + Other.myTolStart < myStart - Other.myStart &&
AreFused (Other.myEnd, Other.myTolEnd, myEnd, myTolEnd); }
//=======================================================================
// **-----------**** Other
// ***-------------* IsSimilar
//=======================================================================
inline Standard_Boolean Intrv_Interval::IsSimilar
(const Intrv_Interval& Other) const
{
Standard_Boolean b1,b2;
b1 = AreFused (myStart,myTolStart,Other.myStart,Other.myTolStart);
b2 = AreFused (myEnd ,myTolEnd ,Other.myEnd ,Other.myTolEnd);
return b1 && b2;
}