35 #ifndef OPENMS_DATASTRUCTURES_DRANGE_H 36 #define OPENMS_DATASTRUCTURES_DRANGE_H 104 DRange(
const PositionType& lower,
const PositionType& upper) :
122 DRange(CoordinateType minx, CoordinateType miny, CoordinateType maxx, CoordinateType maxy)
174 for (
UInt i = 0; i != D; i++)
176 if (position[i] <
min_[i])
return false;
178 if (position[i] >=
max_[i])
return false;
184 bool encloses(CoordinateType x, CoordinateType y)
const 186 if (x <
min_[0])
return false;
188 if (x >=
max_[0])
return false;
190 if (y <
min_[1])
return false;
192 if (y >=
max_[1])
return false;
200 PositionType united_min;
201 PositionType united_max;
204 PositionType other_min = other_range.
minPosition();
205 PositionType other_max = other_range.
maxPosition();
207 for (
Size i = 0; i != D; ++i)
209 united_min[i] =
min_[i] < other_min[i] ?
min_[i] : other_min[i];
210 united_max[i] =
max_[i] > other_max[i] ?
max_[i] : other_max[i];
212 united_range.
setMinMax(united_min, united_max);
228 for (
Size i = 0; i != D; i++)
239 for (
Size i = 0; i != D; i++)
248 for (
Size i = 0; i != D; i++)
274 for (
Size i = 0; i != D; i++)
283 for (
Size i = 0; i != D; i++)
296 for (
UInt i = 0; i != D; i++)
324 for (
UInt i = 0; i != D; ++i)
338 std::ostream& operator<<(std::ostream& os, const DRange<D>& area)
340 os <<
"--DRANGE BEGIN--" << std::endl;
341 os <<
"MIN --> " << area.min_ << std::endl;
342 os <<
"MAX --> " << area.max_ << std::endl;
343 os <<
"--DRANGE END--" << std::endl;
349 #endif // OPENMS_DATASTRUCTURES_DRANGE_H DRange united(const DRange< D > &other_range) const
Returns the smallest range containing this range and other_range.
Definition: DRange.h:198
Base::PositionType PositionType
Position type.
Definition: DRange.h:75
No intersection.
Definition: DRange.h:81
DRange(CoordinateType minx, CoordinateType miny, CoordinateType maxx, CoordinateType maxy)
Convenient constructor for DRange<2>
Definition: DRange.h:122
PositionType min_
lower left point
Definition: DIntervalBase.h:309
bool encloses(const PositionType &position) const
Checks whether this range contains a certain point.
Definition: DRange.h:172
Internal::DIntervalBase< D > Base
Base class type.
Definition: DRange.h:73
bool operator==(const DRange &rhs) const
Equality operator.
Definition: DRange.h:155
#define OPENMS_PRECONDITION(condition, message)
Precondition macro.
Definition: openms/include/OpenMS/CONCEPT/Macros.h:107
DIntervalBase & operator=(const DIntervalBase &rhs)
Assignment operator.
Definition: DIntervalBase.h:94
unsigned int UInt
Unsigned integer type.
Definition: Types.h:95
void extend(double factor)
Extends the range in all dimensions by a certain multiplier.
Definition: DRange.h:317
DRangeIntersection intersects(const DRange &range) const
Checks how this range intersects with another range.
Definition: DRange.h:222
bool operator==(const Base &rhs) const
Equality operator.
Definition: DRange.h:161
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
PositionType const & maxPosition() const
Accessor to maximum position.
Definition: DIntervalBase.h:128
DRange()
Default constructor.
Definition: DRange.h:98
DRange & operator=(const DRange &rhs)
Assignment operator.
Definition: DRange.h:132
bool encloses(CoordinateType x, CoordinateType y) const
2D-version of encloses for convenience only
Definition: DRange.h:184
DRange(const DRange &range)
Copy constructor.
Definition: DRange.h:110
Base::CoordinateType CoordinateType
Coordinate type of the positions.
Definition: DRange.h:77
bool isIntersected(const DRange &range) const
Checks whether this range intersects with another range.
Definition: DRange.h:264
DRange(const Base &range)
Copy constructor for the base class.
Definition: DRange.h:116
Exception indicating that an invalid parameter was handed over to an algorithm.
Definition: Exception.h:348
DRange & operator=(const Base &rhs)
Assignment operator for the base class.
Definition: DRange.h:139
A D-dimensional half-open interval.
Definition: DRange.h:61
PositionType max_
upper right point
Definition: DIntervalBase.h:312
~DRange()
Destructor.
Definition: DRange.h:146
bool isEmpty() const
Checks if the range is empty.
Definition: DRange.h:294
A base class for D-dimensional interval.
Definition: DIntervalBase.h:56
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:128
DRangeIntersection
Types that describe the kind of intersection between two ranges.
Definition: DRange.h:79
void setMinMax(PositionType const &min, PositionType const &max)
Mutator for minimum and maximum position.
Definition: DIntervalBase.h:166
bool operator==(const DIntervalBase &rhs) const
Equality operator.
Definition: DIntervalBase.h:193
Intersection.
Definition: DRange.h:82
DRange(const PositionType &lower, const PositionType &upper)
Constructor that takes two Points and constructs a range.
Definition: DRange.h:104
One contains the other.
Definition: DRange.h:83
PositionType const & minPosition() const
Accessor to minimum position.
Definition: DIntervalBase.h:122