LSST Applications g063fba187b+cac8b7c890,g0f08755f38+6aee506743,g1653933729+a8ce1bb630,g168dd56ebc+a8ce1bb630,g1a2382251a+b4475c5878,g1dcb35cd9c+8f9bc1652e,g20f6ffc8e0+6aee506743,g217e2c1bcf+73dee94bd0,g28da252d5a+1f19c529b9,g2bbee38e9b+3f2625acfc,g2bc492864f+3f2625acfc,g3156d2b45e+6e55a43351,g32e5bea42b+1bb94961c2,g347aa1857d+3f2625acfc,g35bb328faa+a8ce1bb630,g3a166c0a6a+3f2625acfc,g3e281a1b8c+c5dd892a6c,g3e8969e208+a8ce1bb630,g414038480c+5927e1bc1e,g41af890bb2+8a9e676b2a,g7af13505b9+809c143d88,g80478fca09+6ef8b1810f,g82479be7b0+f568feb641,g858d7b2824+6aee506743,g89c8672015+f4add4ffd5,g9125e01d80+a8ce1bb630,ga5288a1d22+2903d499ea,gb58c049af0+d64f4d3760,gc28159a63d+3f2625acfc,gcab2d0539d+b12535109e,gcf0d15dbbd+46a3f46ba9,gda6a2b7d83+46a3f46ba9,gdaeeff99f8+1711a396fd,ge79ae78c31+3f2625acfc,gef2f8181fd+0a71e47438,gf0baf85859+c1f95f4921,gfa517265be+6aee506743,gfa999e8aa5+17cd334064,w.2024.51
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.