OpenMS
DIntervalBase< D > Class Template Reference

A base class for D-dimensional interval. More...

#include <OpenMS/DATASTRUCTURES/DIntervalBase.h>

Inheritance diagram for DIntervalBase< D >:
[legend]
Collaboration diagram for DIntervalBase< D >:
[legend]

Public Types

Type definitions
enum  { DIMENSION = D }
 Dimensions. More...
 
typedef DPosition< D > PositionType
 Position type. More...
 
typedef PositionType::CoordinateType CoordinateType
 Coordinate type of the positions. More...
 

Public Member Functions

Constructors and Destructor
 DIntervalBase ()
 Default constructor. More...
 
 DIntervalBase (const DIntervalBase &rhs)
 Copy constructor. More...
 
 DIntervalBase (DIntervalBase &&) noexcept=default
 Move constructor. More...
 
DIntervalBaseoperator= (const DIntervalBase &rhs)
 Assignment operator. More...
 
 ~DIntervalBase ()
 Destructor. More...
 
 DIntervalBase (PositionType const &minimum, PositionType const &maximum)
 This constructor sets min_ and max_ directly. More...
 
Accessors
PositionType const & minPosition () const
 Accessor to minimum position. More...
 
PositionType const & maxPosition () const
 Accessor to maximum position. More...
 
void setMin (PositionType const &position)
 Mutator for minimum position. More...
 
void setMax (PositionType const &position)
 Mutator for maximum position. More...
 
void setMinMax (PositionType const &min, PositionType const &max)
 Mutator for minimum and maximum position. More...
 
template<UInt D2>
void assign (const DIntervalBase< D2 > rhs)
 Assignment from a DIntervalBase of different dimensions. More...
 

Predicates

template<UInt >
class DIntervalBase
 
bool operator== (const DIntervalBase &rhs) const
 Equality operator. More...
 
bool operator!= (const DIntervalBase &rhs) const
 Equality operator. More...
 
DIntervalBase operator+ (const PositionType &point) const
 
DIntervalBaseoperator+= (const PositionType &point)
 
DIntervalBase operator- (const PositionType &point) const
 
DIntervalBaseoperator-= (const PositionType &point)
 
void clear ()
 Make the interval empty. More...
 
bool isEmpty () const
 
bool isEmpty (UInt dim) const
 Is the dimension dim empty? If min==max, the interval is NOT empty! More...
 
void setDimMinMax (UInt dim, const DIntervalBase< 1 > &min_max)
 only set interval for a single dimension More...
 

Misc

static DIntervalBase const empty = DIntervalBase<D>(std::make_pair(DIntervalBase<D>::PositionType::maxPositive(), DIntervalBase<D>::PositionType::minNegative()))
 empty instance More...
 
static DIntervalBase const zero = DIntervalBase<D>(DIntervalBase<D>::PositionType::zero(), DIntervalBase<D>::PositionType::zero())
 instance with all positions zero More...
 
PositionType center () const
 Returns the center of the interval. More...
 
PositionType diagonal () const
 Returns the diagonal of the area, i.e. max_ - min_. More...
 

Accessors for 2D-intervals (for convenience)

PositionType min_
 lower left point More...
 
PositionType max_
 upper right point More...
 
CoordinateType minX () const
 Accessor for min_ coordinate minimum. More...
 
CoordinateType minY () const
 Accessor for max_ coordinate minimum. More...
 
CoordinateType maxX () const
 Accessor for min_ coordinate maximum. More...
 
CoordinateType maxY () const
 Accessor for max_ coordinate maximum. More...
 
void setMinX (CoordinateType const c)
 Mutator for min_ coordinate of the smaller point. More...
 
void setMinY (CoordinateType const c)
 Mutator for max_ coordinate of the smaller point. More...
 
void setMaxX (CoordinateType const c)
 Mutator for min_ coordinate of the larger point. More...
 
void setMaxY (CoordinateType const c)
 Mutator for max_ coordinate of the larger point. More...
 
CoordinateType width () const
 Returns the width of the area i.e. the difference of dimension zero (X). More...
 
CoordinateType height () const
 Returns the height of the area i.e. the difference of dimension one (Y). More...
 
void normalize_ ()
 normalization to keep all dimensions in the right geometrical order (min_[X] < max_[X]) More...
 
 DIntervalBase (const std::pair< PositionType, PositionType > &pair)
 Protected constructor for the construction of static instances. More...
 

Detailed Description

template<UInt D>
class OpenMS::Internal::DIntervalBase< D >

A base class for D-dimensional interval.

See DIntervalBase for a closed interval and DRange for a half-open interval class.

Invariant
All methods maintain the invariant that minPosition() is geometrically less or equal maxPosition() i.e. minPosition()[x] <= maxPosition()[x].

Member Typedef Documentation

◆ CoordinateType

typedef PositionType::CoordinateType CoordinateType

Coordinate type of the positions.

◆ PositionType

typedef DPosition<D> PositionType

Position type.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Dimensions.

Enumerator
DIMENSION 

Constructor & Destructor Documentation

◆ DIntervalBase() [1/5]

DIntervalBase ( )
inline

Default constructor.

Creates an empty interval with corners at infinity.

◆ DIntervalBase() [2/5]

DIntervalBase ( const DIntervalBase< D > &  rhs)
inline

Copy constructor.

◆ DIntervalBase() [3/5]

DIntervalBase ( DIntervalBase< D > &&  )
defaultnoexcept

Move constructor.

◆ ~DIntervalBase()

~DIntervalBase ( )
inline

Destructor.

◆ DIntervalBase() [4/5]

DIntervalBase ( PositionType const &  minimum,
PositionType const &  maximum 
)
inline

This constructor sets min_ and max_ directly.

References DIntervalBase< D >::normalize_().

◆ DIntervalBase() [5/5]

DIntervalBase ( const std::pair< PositionType, PositionType > &  pair)
inlineprotected

Protected constructor for the construction of static instances.

Member Function Documentation

◆ assign()

void assign ( const DIntervalBase< D2 >  rhs)
inline

Assignment from a DIntervalBase of different dimensions.

Only the dimensions 0 up to min(D,D2)-1 are copied.

References DIntervalBase< D >::max_, DIntervalBase< D >::maxPosition(), DIntervalBase< D >::min_, and DIntervalBase< D >::minPosition().

◆ center()

PositionType center ( ) const
inline

Returns the center of the interval.

References DIntervalBase< D >::max_, and DIntervalBase< D >::min_.

◆ clear()

void clear ( )
inline

Make the interval empty.

References DIntervalBase< D >::empty.

◆ diagonal()

PositionType diagonal ( ) const
inline

Returns the diagonal of the area, i.e. max_ - min_.

References DIntervalBase< D >::max_, and DIntervalBase< D >::min_.

◆ height()

CoordinateType height ( ) const
inline

Returns the height of the area i.e. the difference of dimension one (Y).

References DIntervalBase< D >::max_, and DIntervalBase< D >::min_.

◆ isEmpty() [1/2]

bool isEmpty ( ) const
inline

Is the interval completely empty? i.e. clear()'d or default constructed If min==max, the interval is NOT empty!

References DIntervalBase< D >::empty.

Referenced by DimMapper< N_DIM >::fromXY().

◆ isEmpty() [2/2]

bool isEmpty ( UInt  dim) const
inline

Is the dimension dim empty? If min==max, the interval is NOT empty!

References DIntervalBase< D >::max_, and DIntervalBase< D >::min_.

◆ maxPosition()

◆ maxX()

CoordinateType maxX ( ) const
inline

Accessor for min_ coordinate maximum.

References DIntervalBase< D >::max_.

Referenced by Gravitator::gravitateMax().

◆ maxY()

CoordinateType maxY ( ) const
inline

Accessor for max_ coordinate maximum.

References DIntervalBase< D >::max_.

Referenced by Gravitator::gravitateMax(), and GridBasedClustering< Metric >::removeSmallClustersY().

◆ minPosition()

◆ minX()

CoordinateType minX ( ) const
inline

Accessor for min_ coordinate minimum.

References DIntervalBase< D >::min_.

Referenced by Gravitator::gravitateMin().

◆ minY()

CoordinateType minY ( ) const
inline

Accessor for max_ coordinate minimum.

References DIntervalBase< D >::min_.

Referenced by Gravitator::gravitateMin(), and GridBasedClustering< Metric >::removeSmallClustersY().

◆ normalize_()

void normalize_ ( )
inlineprotected

normalization to keep all dimensions in the right geometrical order (min_[X] < max_[X])

References DIntervalBase< D >::DIMENSION, DIntervalBase< D >::max_, and DIntervalBase< D >::min_.

Referenced by DIntervalBase< D >::DIntervalBase(), DRange< D >::DRange(), and DIntervalBase< D >::setMinMax().

◆ operator!=()

bool operator!= ( const DIntervalBase< D > &  rhs) const
inline

Equality operator.

References DIntervalBase< D >::operator==().

◆ operator+()

DIntervalBase operator+ ( const PositionType point) const
inline

◆ operator+=()

DIntervalBase& operator+= ( const PositionType point)
inline

◆ operator-()

DIntervalBase operator- ( const PositionType point) const
inline

◆ operator-=()

DIntervalBase& operator-= ( const PositionType point)
inline

◆ operator=()

DIntervalBase& operator= ( const DIntervalBase< D > &  rhs)
inline

◆ operator==()

bool operator== ( const DIntervalBase< D > &  rhs) const
inline

◆ setDimMinMax()

void setDimMinMax ( UInt  dim,
const DIntervalBase< 1 > &  min_max 
)
inline

only set interval for a single dimension

References DIntervalBase< D >::max_, and DIntervalBase< D >::min_.

Referenced by DimMapper< N_DIM >::mapRange().

◆ setMax()

void setMax ( PositionType const &  position)
inline

Mutator for maximum position.

Note
The maximum position given here will be returned my maxPosition() after the method. If necessary the value returned by minPosition() will be adjusted.

References DIntervalBase< D >::DIMENSION, DIntervalBase< D >::max_, and DIntervalBase< D >::min_.

◆ setMaxX()

void setMaxX ( CoordinateType const  c)
inline

Mutator for min_ coordinate of the larger point.

References OpenMS::Constants::c, DIntervalBase< D >::max_, and DIntervalBase< D >::min_.

◆ setMaxY()

void setMaxY ( CoordinateType const  c)
inline

Mutator for max_ coordinate of the larger point.

References OpenMS::Constants::c, DIntervalBase< D >::max_, and DIntervalBase< D >::min_.

◆ setMin()

void setMin ( PositionType const &  position)
inline

Mutator for minimum position.

Note
The minimum position given here will be returned my minPosition() after the method. If necessary the value returned by maxPosition() will be adjusted.

References DIntervalBase< D >::DIMENSION, DIntervalBase< D >::max_, and DIntervalBase< D >::min_.

◆ setMinMax()

void setMinMax ( PositionType const &  min,
PositionType const &  max 
)
inline

Mutator for minimum and maximum position.

References DIntervalBase< D >::max_, DIntervalBase< D >::min_, and DIntervalBase< D >::normalize_().

Referenced by DRange< D >::united().

◆ setMinX()

void setMinX ( CoordinateType const  c)
inline

Mutator for min_ coordinate of the smaller point.

References OpenMS::Constants::c, DIntervalBase< D >::max_, and DIntervalBase< D >::min_.

◆ setMinY()

void setMinY ( CoordinateType const  c)
inline

Mutator for max_ coordinate of the smaller point.

References OpenMS::Constants::c, DIntervalBase< D >::max_, and DIntervalBase< D >::min_.

◆ width()

CoordinateType width ( ) const
inline

Returns the width of the area i.e. the difference of dimension zero (X).

References DIntervalBase< D >::max_, and DIntervalBase< D >::min_.

Friends And Related Function Documentation

◆ DIntervalBase

friend class DIntervalBase
friend

Member Data Documentation

◆ empty

DIntervalBase< D > const empty = DIntervalBase<D>(std::make_pair(DIntervalBase<D>::PositionType::maxPositive(), DIntervalBase<D>::PositionType::minNegative()))
static

empty instance

Referenced by DIntervalBase< D >::clear(), and DIntervalBase< D >::isEmpty().

◆ max_

◆ min_

◆ zero

DIntervalBase< D > const zero = DIntervalBase<D>(DIntervalBase<D>::PositionType::zero(), DIntervalBase<D>::PositionType::zero())
static

instance with all positions zero