LSST Applications
21.0.0-172-gfb10e10a+18fedfabac,22.0.0+297cba6710,22.0.0+80564b0ff1,22.0.0+8d77f4f51a,22.0.0+a28f4c53b1,22.0.0+dcf3732eb2,22.0.1-1-g7d6de66+2a20fdde0d,22.0.1-1-g8e32f31+297cba6710,22.0.1-1-geca5380+7fa3b7d9b6,22.0.1-12-g44dc1dc+2a20fdde0d,22.0.1-15-g6a90155+515f58c32b,22.0.1-16-g9282f48+790f5f2caa,22.0.1-2-g92698f7+dcf3732eb2,22.0.1-2-ga9b0f51+7fa3b7d9b6,22.0.1-2-gd1925c9+bf4f0e694f,22.0.1-24-g1ad7a390+a9625a72a8,22.0.1-25-g5bf6245+3ad8ecd50b,22.0.1-25-gb120d7b+8b5510f75f,22.0.1-27-g97737f7+2a20fdde0d,22.0.1-32-gf62ce7b1+aa4237961e,22.0.1-4-g0b3f228+2a20fdde0d,22.0.1-4-g243d05b+871c1b8305,22.0.1-4-g3a563be+32dcf1063f,22.0.1-4-g44f2e3d+9e4ab0f4fa,22.0.1-42-gca6935d93+ba5e5ca3eb,22.0.1-5-g15c806e+85460ae5f3,22.0.1-5-g58711c4+611d128589,22.0.1-5-g75bb458+99c117b92f,22.0.1-6-g1c63a23+7fa3b7d9b6,22.0.1-6-g50866e6+84ff5a128b,22.0.1-6-g8d3140d+720564cf76,22.0.1-6-gd805d02+cc5644f571,22.0.1-8-ge5750ce+85460ae5f3,master-g6e05de7fdc+babf819c66,master-g99da0e417a+8d77f4f51a,w.2021.48
LSST Data Management Base Package
|
A 1-d integer coordinate range. More...
#include <Interval.h>
Public Types | |
enum class | EdgeHandlingEnum { EXPAND , SHRINK } |
Enum used to indicate how to handle conversions from floating-point to integer intervals. More... | |
using | Element = int |
Public Member Functions | |
IntervalI () noexcept | |
Construct an empty interval. More... | |
IntervalI (IntervalD const &other, EdgeHandlingEnum edgeHandling=EdgeHandlingEnum::EXPAND) | |
Construct an integer interval from a floating-point interval. More... | |
IntervalI (IntervalI const &) noexcept=default | |
Standard copy constructor. More... | |
IntervalI (IntervalI &&) noexcept=default | |
Standard move constructor. More... | |
~IntervalI () noexcept=default | |
void | swap (IntervalI &other) noexcept |
IntervalI & | operator= (IntervalI const &) noexcept=default |
Standard copy assignment operator. More... | |
IntervalI & | operator= (IntervalI &&) noexcept=default |
Standard move assignment operatior. More... | |
Min/Max Accessors | |
Return the minimum and maximum coordinates of the interval (inclusive). | |
Element | getMin () const noexcept |
Element | getMax () const noexcept |
Begin/End Accessors | |
Return begin (inclusive) and end (exclusive) coordinates for the interval. | |
Element | getBegin () const noexcept |
Element | getEnd () const noexcept |
Static Public Member Functions | |
template<typename Iter > | |
static IntervalI | fromSpannedPoints (Iter first, Iter last) |
Construct an interval that contains all of the given points. More... | |
static IntervalI | fromSpannedPoints (std::vector< Element > const &elements) |
Construct an interval that contains all of the given points. More... | |
static IntervalI | fromSpannedPoints (ndarray::Array< Element const, 1 > const &elements) |
static IntervalI | fromMinMax (Element min, Element max) |
Construct an interval from its lower and upper bounds. More... | |
static IntervalI | fromMinSize (Element min, Element size) |
Construct an interval from its lower bound and size. More... | |
static IntervalI | fromMaxSize (Element max, Element size) |
Construct an interval from its upper bound and size. More... | |
static IntervalI | fromCenterSize (double center, Element size) |
Create an interval centered as closely as possible on a particular point. More... | |
Size Accessors | |
Element | getSize () const noexcept |
Return slice to extract the interval's region from an ndarray::Array. More... | |
ndarray::View< boost::fusion::vector1< ndarray::index::Range > > | getSlice () const |
Return slice to extract the interval's region from an ndarray::Array. More... | |
bool | isEmpty () const noexcept |
Return true if the interval contains no points. More... | |
bool | contains (Element point) const noexcept |
Return true if the interval contains the point. More... | |
bool | contains (IntervalI const &other) const noexcept |
Return true if all points contained by other are also contained by this. More... | |
bool | overlaps (IntervalI const &other) const noexcept |
Return true if there are any points in both this and other. More... | |
bool | intersects (IntervalI const &other) const noexcept |
Return slice to extract the interval's region from an ndarray::Array. More... | |
bool | isDisjointFrom (IntervalI const &other) const noexcept |
Return true if there are no points in both this and other . More... | |
IntervalI | dilatedBy (Element buffer) const |
Increase the size of the interval by the given amount in both directions (returning a new object). More... | |
IntervalI | erodedBy (Element buffer) const |
Decrease the size of the interval by the given amount in both directions (returning a new object). More... | |
IntervalI | shiftedBy (Element offset) const |
Shift the position of the interval by the given offset (returning a new object).) More... | |
IntervalI | reflectedAbout (Element point) const |
Reflect an interval about a point (returning a new object). More... | |
IntervalI | expandedTo (Element other) const |
Expand an interval to ensure that contains(other) is true (returning a new object). More... | |
IntervalI | expandedTo (IntervalI const &other) const |
Return slice to extract the interval's region from an ndarray::Array. More... | |
IntervalI | clippedTo (IntervalI const &other) const noexcept |
Shrink an interval to ensure that it is contained by other (returning a new) More... | |
bool | operator== (IntervalI const &other) const noexcept |
Compare two intervals for equality. More... | |
bool | operator!= (IntervalI const &other) const noexcept |
Compare two intervals for equality. More... | |
std::size_t | hash_value () const noexcept |
Return a hash of this object. More... | |
std::string | toString () const |
Return slice to extract the interval's region from an ndarray::Array. More... | |
A 1-d integer coordinate range.
IntervalI is an inclusive range that represents region of pixels. An IntervalI never has negative size; the empty interval is defined to have zero size, and is treated as though it does not have a well-defined position (regardless of the return value of getMin() or getMax() for an empty interval).
All IntervalI methods that return a new instance (and are not marked noexcept
) throw OverflowError
if the lower bound, upper bound, or the size would be too large to fit in int
.
Definition at line 50 of file Interval.h.
using lsst::geom::IntervalI::Element = int |
Definition at line 52 of file Interval.h.
|
strong |
Enum used to indicate how to handle conversions from floating-point to integer intervals.
Note that the floating point bounds for some pixel x
in an integer interval are [x - 0.5, x + 0.5]
(because the pixel has unit size, and integer coordinates correspond to the centers of pixels). This means interval conversions involve more than just rounding the bounds inward or outward.
Enumerator | |
---|---|
EXPAND | Include all pixels that overlap the floating-point interval at all. |
SHRINK | Include only pixels that are wholly contained by the floating-point interval. |
Definition at line 64 of file Interval.h.
|
inlinenoexcept |
|
explicit |
Construct an integer interval from a floating-point interval.
Floating-point to integer interval conversion is based on the concept that a pixel is not an infinitesimal point but rather a square of unit size centered on integer-valued coordinates. Converting a floating-point interval to an integer interval thus requires a choice on how to handle pixels which are only partially contained by the input floating-point interval.
[in] | other | A floating-point interval to convert. |
[in] | edgeHandling | If EXPAND, the integer interval will contain any pixels that overlap the floating-point interval. If SHRINK, the integer interval will contain only pixels completely contained by the floating-point interval. |
lsst::pex::exceptions::InvalidParameterError | Thrown if other is not finite. |
lsst::pex::exceptions::LogicError | Thrown if an invalid enum value is passed. |
Definition at line 87 of file Interval.cc.
|
defaultnoexcept |
Standard copy constructor.
|
defaultnoexcept |
Standard move constructor.
|
defaultnoexcept |
Shrink an interval to ensure that it is contained by other (returning a new)
In particular, if other
and this interval do not overlap, the returned interval will be empty.
Definition at line 186 of file Interval.cc.
|
noexcept |
Return true if the interval contains the point.
Definition at line 116 of file Interval.cc.
|
noexcept |
Return true if all points contained by other are also contained by this.
An empty interval is contained by every other interval, including other empty intervals.
Definition at line 122 of file Interval.cc.
Increase the size of the interval by the given amount in both directions (returning a new object).
If buffer
is negative, this is equivalent to eroding by -buffer
.
If the final size of the interval is less than or equal to zero the new interval will be empty.
Empty intervals remain empty after dilation.
Definition at line 137 of file Interval.cc.
Decrease the size of the interval by the given amount in both directions (returning a new object).
If buffer
is negative, this is equivalent to dilating by -buffer
.
If the final size of the interval is less than or equal to zero the new interval will be empty.
Empty intervals remain empty after erosion.
Definition at line 315 of file Interval.h.
Expand an interval to ensure that contains(other)
is true (returning a new object).
Expanding an empty interval with a single point yields an interval with size=1 at that point; expanding an empty interval with a second interval is equivalent to assignment.
Definition at line 166 of file Interval.cc.
Return slice to extract the interval's region from an ndarray::Array.
For example:
auto array = ndarray::copy(ndarray::arange(5); auto interval = IntervalI::fromMinMax(2, 4); auto subarray = array[interval.getSlice()];
Definition at line 174 of file Interval.cc.
Create an interval centered as closely as possible on a particular point.
center | The desired center of the interval. |
size | Number of pixels in interval. Nonpositive values will produce an empty interval. |
size
is positive, an interval with size size
; if size
is zero or negative, an empty interval. If the returned interval is not empty, its center shall be within half a pixel of center
.lsst::pex::exceptions::OverflowError | Thrown if the resulting interval would overflow. |
lsst::pex::exceptions::InvalidParameterError | Thrown if center is not finite and size is positive. |
Definition at line 75 of file Interval.cc.
Construct an interval from its upper bound and size.
[in] | max | Maximum coordinate (inclusive). |
[in] | size | Number of pixels in interval. Nonpositive values will produce an empty interval. |
lsst::pex::exceptions::OverflowError | Thrown if the resulting interval would overflow. |
Definition at line 66 of file Interval.cc.
Construct an interval from its lower and upper bounds.
If min > max, the resulting interval is empty.
[in] | min | Minimum coordinate (inclusive). |
[in] | max | Maximum coordinate (inclusive). |
lsst::pex::exceptions::OverflowError | Thrown if the resulting interval would overflow. |
Definition at line 53 of file Interval.cc.
Construct an interval from its lower bound and size.
[in] | min | Minimum coordinate (inclusive). |
[in] | size | Number of pixels in interval. Nonpositive values will produce an empty interval. |
lsst::pex::exceptions::OverflowError | Thrown if the resulting interval would overflow. |
Definition at line 57 of file Interval.cc.
|
inlinestatic |
Construct an interval that contains all of the given points.
[in] | first | Iterator to the beginning of a sequence of integers. |
[in] | last | Iterator to one-past-the-end of a sequence of integers. |
An empty interval is returned if first == last
.
lsst::pex::exceptions::OverflowError | Thrown if the resulting interval would overflow. |
Definition at line 92 of file Interval.h.
|
inlinestatic |
Definition at line 115 of file Interval.h.
|
inlinestatic |
Construct an interval that contains all of the given points.
[in] | elements | Points (integer values) to include in the interval. |
An empty interval is returned if the given container has no elements.
lsst::pex::exceptions::OverflowError | Thrown if the resulting interval would overflow. |
Definition at line 112 of file Interval.h.
|
inlinenoexcept |
Definition at line 238 of file Interval.h.
|
inlinenoexcept |
Definition at line 239 of file Interval.h.
|
inlinenoexcept |
Definition at line 228 of file Interval.h.
|
inlinenoexcept |
Definition at line 227 of file Interval.h.
|
inlinenoexcept |
Return slice to extract the interval's region from an ndarray::Array.
For example:
auto array = ndarray::copy(ndarray::arange(5); auto interval = IntervalI::fromMinMax(2, 4); auto subarray = array[interval.getSlice()];
Definition at line 247 of file Interval.h.
ndarray::View< boost::fusion::vector1< ndarray::index::Range > > lsst::geom::IntervalI::getSlice | ( | ) | const |
Return slice to extract the interval's region from an ndarray::Array.
For example:
auto array = ndarray::copy(ndarray::arange(5); auto interval = IntervalI::fromMinMax(2, 4); auto subarray = array[interval.getSlice()];
Definition at line 112 of file Interval.cc.
|
noexcept |
Return a hash of this object.
Definition at line 199 of file Interval.cc.
|
inlinenoexcept |
Return slice to extract the interval's region from an ndarray::Array.
For example:
auto array = ndarray::copy(ndarray::arange(5); auto interval = IntervalI::fromMinMax(2, 4); auto subarray = array[interval.getSlice()];
Definition at line 283 of file Interval.h.
|
noexcept |
Return true if there are no points in both this
and other
.
Definition at line 130 of file Interval.cc.
|
inlinenoexcept |
Return true if the interval contains no points.
Definition at line 262 of file Interval.h.
|
noexcept |
Compare two intervals for equality.
All empty intervals are equal.
Definition at line 197 of file Interval.cc.
Standard move assignment operatior.
Standard copy assignment operator.
|
noexcept |
Compare two intervals for equality.
All empty intervals are equal.
Definition at line 193 of file Interval.cc.
|
noexcept |
Return true if there are any points in both this and other.
Any overlap operation involving an empty interval returns false.
Definition at line 128 of file Interval.cc.
Reflect an interval about a point (returning a new object).
Empty intervals remain empty when reflected.
Definition at line 157 of file Interval.cc.
Shift the position of the interval by the given offset (returning a new object).)
Empty intervals remain empty when shifted.
Definition at line 146 of file Interval.cc.
|
inlinenoexcept |
Definition at line 209 of file Interval.h.
std::string lsst::geom::IntervalI::toString | ( | ) | const |
Return slice to extract the interval's region from an ndarray::Array.
For example:
auto array = ndarray::copy(ndarray::arange(5); auto interval = IntervalI::fromMinMax(2, 4); auto subarray = array[interval.getSlice()];
Definition at line 204 of file Interval.cc.