Open CASCADE Technology Reference Manual 8.0.0
Loading...
Searching...
No Matches
Data Structures | Public Types | Public Member Functions
Bnd_Range Class Reference

This class describes a range in 1D space restricted by two real values. A range can be void indicating there is no point included in the range. More...

#include <Bnd_Range.hxx>

Data Structures

struct  Bounds
 Structure containing the range bounds (Min, Max). Can be used with C++17 structured bindings: More...
 

Public Types

enum  IntersectStatus { IntersectStatus_Out = 0 , IntersectStatus_In = 1 , IntersectStatus_Boundary = 2 }
 Status of intersection check with a periodic value. More...
 

Public Member Functions

 Bnd_Range ()
 Default constructor. Creates VOID range.
 
 Bnd_Range (const double theMin, const double theMax)
 Constructor. Never creates VOID range.
 
void Common (const Bnd_Range &theOther)
 Replaces <this> with common-part of <this> and theOther.
 
bool Union (const Bnd_Range &theOther)
 Joins *this and theOther to one interval. Replaces *this to the result. Returns false if the operation cannot be done (e.g. input arguments are empty or separated).
 
void Split (const double theVal, NCollection_List< Bnd_Range > &theList, const double thePeriod=0.0) const
 Splits <this> to several sub-ranges by theVal value (e.g. range [3, 15] will be split by theVal==5 to the two ranges: [3, 5] and [5, 15]). New ranges will be pushed to theList (theList must be initialized correctly before calling this method). If thePeriod != 0.0 then at least one boundary of new ranges (if <*this> intersects theVal+k*thePeriod) will be equal to theVal+thePeriod*k, where k is an integer number (k = 0, +/-1, +/-2, ...). (let thePeriod in above example be 4 ==> we will obtain four ranges: [3, 5], [5, 9], [9, 13] and [13, 15].
 
IntersectStatus IsIntersected (const double theVal, const double thePeriod=0.0) const
 Checks if <this> intersects values like theVal+k*thePeriod, where k is an integer number (k = 0, +/-1, +/-2, ...).
 
void Add (const double theParameter)
 Extends <this> to include theParameter.
 
void Add (const Bnd_Range &theRange)
 Extends this range to include both ranges.
 
bool GetMin (double &thePar) const
 Obtain MIN boundary of <this>. If <this> is VOID the method returns false.
 
bool GetMax (double &thePar) const
 Obtain MAX boundary of <this>. If <this> is VOID the method returns false.
 
bool GetBounds (double &theFirstPar, double &theLastPar) const
 Obtain first and last boundary of <this>. If <this> is VOID the method returns false.
 
std::optional< BoundsGet () const noexcept
 Returns the bounds of this range as a Bounds structure. Returns std::nullopt if IsVoid(). Can be used with C++17 structured bindings:
 
bool GetIntermediatePoint (const double theLambda, double &theParameter) const
 Obtain theParameter satisfied to the equation (theParameter-MIN)/(MAX-MIN) == theLambda.
 
std::optional< doubleCenter () const noexcept
 Returns the center of this range ((Min + Max) / 2). Returns std::nullopt if IsVoid().
 
double Delta () const noexcept
 Returns range value (MAX-MIN). Returns negative value for VOID range.
 
bool IsVoid () const noexcept
 Is <this> initialized.
 
void SetVoid () noexcept
 Initializes <this> by default parameters. Makes <this> VOID.
 
void Enlarge (const double theDelta) noexcept
 Extends this to the given value (in both side)
 
Bnd_Range Shifted (const double theVal) const
 Returns the copy of <*this> shifted by theVal.
 
void Shift (const double theVal) noexcept
 Shifts <*this> by theVal.
 
void TrimFrom (const double theValLower) noexcept
 Trims the First value in range by the given lower limit. Marks range as Void if the given Lower value is greater than range Max.
 
void TrimTo (const double theValUpper) noexcept
 Trim the Last value in range by the given Upper limit. Marks range as Void if the given Upper value is smaller than range Max.
 
bool IsOut (double theValue) const noexcept
 Returns True if the value is out of this range.
 
bool IsOut (const Bnd_Range &theRange) const noexcept
 Returns True if the given range is out of this range.
 
bool Contains (double theValue) const noexcept
 Returns True if the value is within this range.
 
bool Intersects (const Bnd_Range &theRange) const noexcept
 Returns True if the given range intersects (overlaps with) this range.
 
std::optional< doubleMin () const noexcept
 Returns the MIN boundary of <this>. Returns std::nullopt if IsVoid().
 
std::optional< doubleMax () const noexcept
 Returns the MAX boundary of <this>. Returns std::nullopt if IsVoid().
 
bool operator== (const Bnd_Range &theOther) const noexcept
 Returns TRUE if theOther is equal to <*this>
 
void DumpJson (Standard_OStream &theOStream, int theDepth=-1) const
 Dumps the content of me into the stream.
 

Detailed Description

This class describes a range in 1D space restricted by two real values. A range can be void indicating there is no point included in the range.

Member Enumeration Documentation

◆ IntersectStatus

Status of intersection check with a periodic value.

See also
IsIntersected()
Enumerator
IntersectStatus_Out 

No intersection with theVal+k*thePeriod.

IntersectStatus_In 

Range strictly contains theVal+k*thePeriod.

IntersectStatus_Boundary 

Range boundary coincides with theVal+k*thePeriod.

Constructor & Destructor Documentation

◆ Bnd_Range() [1/2]

Bnd_Range::Bnd_Range ( )
inline

Default constructor. Creates VOID range.

◆ Bnd_Range() [2/2]

Bnd_Range::Bnd_Range ( const double theMin,
const double theMax )
inline

Constructor. Never creates VOID range.

Member Function Documentation

◆ Add() [1/2]

void Bnd_Range::Add ( const Bnd_Range & theRange)
inline

Extends this range to include both ranges.

See also
use method Union() to check if two ranges overlap method merging

◆ Add() [2/2]

void Bnd_Range::Add ( const double theParameter)
inline

Extends <this> to include theParameter.

◆ Center()

std::optional< double > Bnd_Range::Center ( ) const
inlinenoexcept

Returns the center of this range ((Min + Max) / 2). Returns std::nullopt if IsVoid().

◆ Common()

void Bnd_Range::Common ( const Bnd_Range & theOther)

Replaces <this> with common-part of <this> and theOther.

◆ Contains()

bool Bnd_Range::Contains ( double theValue) const
inlinenoexcept

Returns True if the value is within this range.

◆ Delta()

double Bnd_Range::Delta ( ) const
inlinenoexcept

Returns range value (MAX-MIN). Returns negative value for VOID range.

◆ DumpJson()

void Bnd_Range::DumpJson ( Standard_OStream & theOStream,
int theDepth = -1 ) const

Dumps the content of me into the stream.

◆ Enlarge()

void Bnd_Range::Enlarge ( const double theDelta)
inlinenoexcept

Extends this to the given value (in both side)

◆ Get()

std::optional< Bounds > Bnd_Range::Get ( ) const
inlinenoexcept

Returns the bounds of this range as a Bounds structure. Returns std::nullopt if IsVoid(). Can be used with C++17 structured bindings:

if (auto aBounds = aRange.Get())
{
auto [aMin, aMax] = *aBounds;
}
STL input iterator that wraps an OCCT More()/Next() iterator.
Definition NCollection_ForwardRange.hxx:142

◆ GetBounds()

bool Bnd_Range::GetBounds ( double & theFirstPar,
double & theLastPar ) const
inline

Obtain first and last boundary of <this>. If <this> is VOID the method returns false.

◆ GetIntermediatePoint()

bool Bnd_Range::GetIntermediatePoint ( const double theLambda,
double & theParameter ) const
inline

Obtain theParameter satisfied to the equation (theParameter-MIN)/(MAX-MIN) == theLambda.

  • theLambda == 0 --> MIN boundary will be returned;
  • theLambda == 0.5 --> Middle point will be returned;
  • theLambda == 1 --> MAX boundary will be returned;
  • theLambda < 0 --> the value less than MIN will be returned;
  • theLambda > 1 --> the value greater than MAX will be returned. If <this> is VOID the method returns false.

◆ GetMax()

bool Bnd_Range::GetMax ( double & thePar) const
inline

Obtain MAX boundary of <this>. If <this> is VOID the method returns false.

◆ GetMin()

bool Bnd_Range::GetMin ( double & thePar) const
inline

Obtain MIN boundary of <this>. If <this> is VOID the method returns false.

◆ Intersects()

bool Bnd_Range::Intersects ( const Bnd_Range & theRange) const
inlinenoexcept

Returns True if the given range intersects (overlaps with) this range.

◆ IsIntersected()

IntersectStatus Bnd_Range::IsIntersected ( const double theVal,
const double thePeriod = 0.0 ) const

Checks if <this> intersects values like theVal+k*thePeriod, where k is an integer number (k = 0, +/-1, +/-2, ...).

ATTENTION!!! If (myFirst == myLast) then this function will return only either Out or Boundary.

◆ IsOut() [1/2]

bool Bnd_Range::IsOut ( const Bnd_Range & theRange) const
inlinenoexcept

Returns True if the given range is out of this range.

◆ IsOut() [2/2]

bool Bnd_Range::IsOut ( double theValue) const
inlinenoexcept

Returns True if the value is out of this range.

◆ IsVoid()

bool Bnd_Range::IsVoid ( ) const
inlinenoexcept

Is <this> initialized.

◆ Max()

std::optional< double > Bnd_Range::Max ( ) const
inlinenoexcept

Returns the MAX boundary of <this>. Returns std::nullopt if IsVoid().

◆ Min()

std::optional< double > Bnd_Range::Min ( ) const
inlinenoexcept

Returns the MIN boundary of <this>. Returns std::nullopt if IsVoid().

◆ operator==()

bool Bnd_Range::operator== ( const Bnd_Range & theOther) const
inlinenoexcept

Returns TRUE if theOther is equal to <*this>

◆ SetVoid()

void Bnd_Range::SetVoid ( )
inlinenoexcept

Initializes <this> by default parameters. Makes <this> VOID.

◆ Shift()

void Bnd_Range::Shift ( const double theVal)
inlinenoexcept

Shifts <*this> by theVal.

◆ Shifted()

Bnd_Range Bnd_Range::Shifted ( const double theVal) const
inline

Returns the copy of <*this> shifted by theVal.

◆ Split()

void Bnd_Range::Split ( const double theVal,
NCollection_List< Bnd_Range > & theList,
const double thePeriod = 0.0 ) const

Splits <this> to several sub-ranges by theVal value (e.g. range [3, 15] will be split by theVal==5 to the two ranges: [3, 5] and [5, 15]). New ranges will be pushed to theList (theList must be initialized correctly before calling this method). If thePeriod != 0.0 then at least one boundary of new ranges (if <*this> intersects theVal+k*thePeriod) will be equal to theVal+thePeriod*k, where k is an integer number (k = 0, +/-1, +/-2, ...). (let thePeriod in above example be 4 ==> we will obtain four ranges: [3, 5], [5, 9], [9, 13] and [13, 15].

◆ TrimFrom()

void Bnd_Range::TrimFrom ( const double theValLower)
inlinenoexcept

Trims the First value in range by the given lower limit. Marks range as Void if the given Lower value is greater than range Max.

◆ TrimTo()

void Bnd_Range::TrimTo ( const double theValUpper)
inlinenoexcept

Trim the Last value in range by the given Upper limit. Marks range as Void if the given Upper value is smaller than range Max.

◆ Union()

bool Bnd_Range::Union ( const Bnd_Range & theOther)

Joins *this and theOther to one interval. Replaces *this to the result. Returns false if the operation cannot be done (e.g. input arguments are empty or separated).

See also
use method Add() to merge two ranges unconditionally

The documentation for this class was generated from the following file: