LSST Applications g0f08755f38+9c285cab97,g1635faa6d4+13f3999e92,g1653933729+a8ce1bb630,g1a0ca8cf93+bf6eb00ceb,g28da252d5a+0829b12dee,g29321ee8c0+5700dc9eac,g2bbee38e9b+9634bc57db,g2bc492864f+9634bc57db,g2cdde0e794+c2c89b37c4,g3156d2b45e+41e33cbcdc,g347aa1857d+9634bc57db,g35bb328faa+a8ce1bb630,g3a166c0a6a+9634bc57db,g3e281a1b8c+9f2c4e2fc3,g414038480c+077ccc18e7,g41af890bb2+fde0dd39b6,g5fbc88fb19+17cd334064,g781aacb6e4+a8ce1bb630,g80478fca09+55a9465950,g82479be7b0+d730eedb7d,g858d7b2824+9c285cab97,g9125e01d80+a8ce1bb630,g9726552aa6+10f999ec6a,ga5288a1d22+2a84bb7594,gacf8899fa4+c69c5206e8,gae0086650b+a8ce1bb630,gb58c049af0+d64f4d3760,gc28159a63d+9634bc57db,gcf0d15dbbd+4b7d09cae4,gda3e153d99+9c285cab97,gda6a2b7d83+4b7d09cae4,gdaeeff99f8+1711a396fd,ge2409df99d+5e831397f4,ge79ae78c31+9634bc57db,gf0baf85859+147a0692ba,gf3967379c6+41c94011de,gf3fb38a9a8+8f07a9901b,gfb92a5be7c+9c285cab97,w.2024.46
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. | |
IntervalI (IntervalD const &other, EdgeHandlingEnum edgeHandling=EdgeHandlingEnum::EXPAND) | |
Construct an integer interval from a floating-point interval. | |
IntervalI (IntervalI const &) noexcept=default | |
Standard copy constructor. | |
IntervalI (IntervalI &&) noexcept=default | |
Standard move constructor. | |
~IntervalI () noexcept=default | |
void | swap (IntervalI &other) noexcept |
IntervalI & | operator= (IntervalI const &) noexcept=default |
Standard copy assignment operator. | |
IntervalI & | operator= (IntervalI &&) noexcept=default |
Standard move assignment operatior. | |
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. | |
static IntervalI | fromSpannedPoints (std::vector< Element > const &elements) |
Construct an interval that contains all of the given points. | |
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. | |
static IntervalI | fromMinSize (Element min, Element size) |
Construct an interval from its lower bound and size. | |
static IntervalI | fromMaxSize (Element max, Element size) |
Construct an interval from its upper bound and size. | |
static IntervalI | fromCenterSize (double center, Element size) |
Create an interval centered as closely as possible on a particular point. | |
Size Accessors | |
Return the size of the interval in pixels. | |
Element | getSize () const noexcept |
Return slice to extract the interval's region from an ndarray::Array. | |
ndarray::View< boost::fusion::vector1< ndarray::index::Range > > | getSlice () const |
Return slice to extract the interval's region from an ndarray::Array. | |
bool | isEmpty () const noexcept |
Return true if the interval contains no points. | |
bool | contains (Element point) const noexcept |
Return true if the interval contains the point. | |
bool | contains (IntervalI const &other) const noexcept |
Return true if all points contained by other are also contained by this. | |
bool | overlaps (IntervalI const &other) const noexcept |
Return true if there are any points in both this and other. | |
bool | intersects (IntervalI const &other) const noexcept |
Return slice to extract the interval's region from an ndarray::Array. | |
bool | isDisjointFrom (IntervalI const &other) const noexcept |
Return true if there are no points in both this and other . | |
IntervalI | dilatedBy (Element buffer) const |
Increase the size of the interval by the given amount in both directions (returning a new object). | |
IntervalI | erodedBy (Element buffer) const |
Decrease the size of the interval by the given amount in both directions (returning a new object). | |
IntervalI | shiftedBy (Element offset) const |
Shift the position of the interval by the given offset (returning a new object).) | |
IntervalI | reflectedAbout (Element point) const |
Reflect an interval about a point (returning a new object). | |
IntervalI | expandedTo (Element other) const |
Expand an interval to ensure that contains(other) is true (returning a new object). | |
IntervalI | expandedTo (IntervalI const &other) const |
Return slice to extract the interval's region from an ndarray::Array. | |
IntervalI | clippedTo (IntervalI const &other) const noexcept |
Shrink an interval to ensure that it is contained by other (returning a new) | |
bool | operator== (IntervalI const &other) const noexcept |
Compare two intervals for equality. | |
bool | operator!= (IntervalI const &other) const noexcept |
Compare two intervals for equality. | |
std::size_t | hash_value () const noexcept |
Return a hash of this object. | |
std::string | toString () const |
Return slice to extract the interval's region from an ndarray::Array. | |
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.