LSST Applications  21.0.0+3c14b91618,21.0.0+9f51b1e3f7,21.0.0-1-ga51b5d4+6691386486,21.0.0-10-g2408eff+1a328412bf,21.0.0-10-g560fb7b+52fd22d7b4,21.0.0-10-g8d1d15d+2f9043cae0,21.0.0-10-gcf60f90+d15de71c48,21.0.0-11-g25eff31+d43066e4ef,21.0.0-15-g490e301a+a676f0d5cf,21.0.0-2-g103fe59+4758c8ef83,21.0.0-2-g1367e85+a9f57e981a,21.0.0-2-g45278ab+9f51b1e3f7,21.0.0-2-g5242d73+a9f57e981a,21.0.0-2-g7f82c8f+1bcc828e4f,21.0.0-2-g8f08a60+e6fd6d9ff9,21.0.0-2-ga326454+1bcc828e4f,21.0.0-2-gde069b7+66c51b65da,21.0.0-2-gecfae73+251b9830c3,21.0.0-2-gfc62afb+a9f57e981a,21.0.0-20-g09baf175d+e1e7d1c708,21.0.0-3-g357aad2+854c3902c3,21.0.0-3-g4be5c26+a9f57e981a,21.0.0-3-g65f322c+feaa1990e9,21.0.0-3-g7d9da8d+3c14b91618,21.0.0-3-ge02ed75+bda8df9b93,21.0.0-4-g591bb35+bda8df9b93,21.0.0-4-g65b4814+52fd22d7b4,21.0.0-4-g88306b8+656365ce3f,21.0.0-4-gccdca77+86bf7a300d,21.0.0-4-ge8a399c+b99e86088e,21.0.0-5-gd00fb1e+6a0dc09319,21.0.0-51-gd3b42663+bf9f0d1c8b,21.0.0-6-g2d4f3f3+9f51b1e3f7,21.0.0-7-g04766d7+ee2ae02087,21.0.0-7-g98eecf7+3609eddee2,21.0.0-7-gde99fe0+bda8df9b93,21.0.0-8-gd70ce6f+79e45e76e4,master-gac4afde19b+bda8df9b93,w.2021.10
LSST Data Management Base Package
Public Types | Public Member Functions | Static Public Member Functions | List of all members
lsst::geom::IntervalI Class Referencefinal

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
 
IntervalIoperator= (IntervalI const &) noexcept=default
 Standard copy assignment operator. More...
 
IntervalIoperator= (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

Return the size of the interval in pixels.

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...
 

Detailed Description

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.

Member Typedef Documentation

◆ Element

Definition at line 52 of file Interval.h.

Member Enumeration Documentation

◆ EdgeHandlingEnum

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.

64  {
68  EXPAND,
73  SHRINK
74  };

Constructor & Destructor Documentation

◆ IntervalI() [1/4]

lsst::geom::IntervalI::IntervalI ( )
inlinenoexcept

Construct an empty interval.

Definition at line 77 of file Interval.h.

77 : _min(0), _size(0) {}

◆ IntervalI() [2/4]

lsst::geom::IntervalI::IntervalI ( IntervalD const &  other,
EdgeHandlingEnum  edgeHandling = EdgeHandlingEnum::EXPAND 
)
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.

Parameters
[in]otherA floating-point interval to convert.
[in]edgeHandlingIf 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.
Exceptions
lsst::pex::exceptions::InvalidParameterErrorThrown if other is not finite.
lsst::pex::exceptions::LogicErrorThrown if an invalid enum value is passed.

Definition at line 87 of file Interval.cc.

87  : _min(), _size() {
88  if (other.isEmpty()) {
89  *this = IntervalI();
90  return;
91  }
92  if (!std::isfinite(other.getMin()) || !std::isfinite(other.getMax())) {
93  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError,
94  "Cannot convert non-finite IntervalD to IntervalI");
95  }
96  BigElement min, max;
97  switch (edgeHandling) {
99  min = static_cast<BigElement>(std::ceil(other.getMin() - 0.5));
100  max = static_cast<BigElement>(std::floor(other.getMax() + 0.5));
101  break;
103  min = static_cast<BigElement>(std::ceil(other.getMin() + 0.5));
104  max = static_cast<BigElement>(std::floor(other.getMax() - 0.5));
105  break;
106  default:
107  throw pex::exceptions::LogicError("Invalid enum value.");
108  }
109  *this = _fromMinMaxChecked(min, max);
110 }
int min
int max
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
ItemVariant const * other
Definition: Schema.cc:56
T ceil(T... args)
IntervalI() noexcept
Construct an empty interval.
Definition: Interval.h:77
@ SHRINK
Include only pixels that are wholly contained by the floating-point interval.
@ EXPAND
Include all pixels that overlap the floating-point interval at all.
T floor(T... args)
T isfinite(T... args)

◆ IntervalI() [3/4]

lsst::geom::IntervalI::IntervalI ( IntervalI const &  )
defaultnoexcept

Standard copy constructor.

◆ IntervalI() [4/4]

lsst::geom::IntervalI::IntervalI ( IntervalI &&  )
defaultnoexcept

Standard move constructor.

◆ ~IntervalI()

lsst::geom::IntervalI::~IntervalI ( )
defaultnoexcept

Member Function Documentation

◆ clippedTo()

IntervalI lsst::geom::IntervalI::clippedTo ( IntervalI const &  other) const
noexcept

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.

186  {
187  if (isEmpty() || other.isEmpty()) {
188  return IntervalI();
189  }
190  return fromMinMax(std::max(getMin(), other.getMin()), std::min(getMax(), other.getMax()));
191 }
bool isEmpty() const noexcept
Return true if the interval contains no points.
Definition: Interval.h:262
Element getMax() const noexcept
Definition: Interval.h:228
static IntervalI fromMinMax(Element min, Element max)
Construct an interval from its lower and upper bounds.
Definition: Interval.cc:53
Element getMin() const noexcept
Definition: Interval.h:227
T max(T... args)
T min(T... args)

◆ contains() [1/2]

bool lsst::geom::IntervalI::contains ( Element  point) const
noexcept

Return true if the interval contains the point.

Definition at line 116 of file Interval.cc.

116  {
117  // The case where this->isEmpty() is handled implicitly by the invariant
118  // that empty intervals have max < min.
119  return point >= this->getMin() && point <= this->getMax();
120 }

◆ contains() [2/2]

bool lsst::geom::IntervalI::contains ( IntervalI const &  other) const
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.

122  {
123  // The case where this->isEmpty() is handled implicitly by the invariant
124  // that empty intervals have max < min.
125  return other.isEmpty() || (other.getMin() >= this->getMin() && other.getMax() <= this->getMax());
126 }

◆ dilatedBy()

IntervalI lsst::geom::IntervalI::dilatedBy ( Element  buffer) const

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.

137  {
138  if (isEmpty()) {
139  return IntervalI();
140  }
141  BigElement min = static_cast<BigElement>(getMin()) - buffer;
142  BigElement max = static_cast<BigElement>(getMax()) + buffer;
143  return _fromMinMaxChecked(min, max);
144 }

◆ erodedBy()

IntervalI lsst::geom::IntervalI::erodedBy ( Element  buffer) const
inline

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.

315 { return dilatedBy(-buffer); }
IntervalI dilatedBy(Element buffer) const
Increase the size of the interval by the given amount in both directions (returning a new object).
Definition: Interval.cc:137

◆ expandedTo() [1/2]

IntervalI lsst::geom::IntervalI::expandedTo ( Element  other) const

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.

166  {
167  if (isEmpty()) {
168  return IntervalI(point, 1);
169  }
170  return _fromMinMaxChecked(std::min(static_cast<BigElement>(point), static_cast<BigElement>(getMin())),
171  std::max(static_cast<BigElement>(point), static_cast<BigElement>(getMax())));
172 }

◆ expandedTo() [2/2]

IntervalI lsst::geom::IntervalI::expandedTo ( IntervalI const &  other) 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 174 of file Interval.cc.

174  {
175  if (other.isEmpty()) {
176  return *this;
177  }
178  if (this->isEmpty()) {
179  return other;
180  }
181  return _fromMinMaxChecked(
182  std::min(static_cast<BigElement>(other.getMin()), static_cast<BigElement>(getMin())),
183  std::max(static_cast<BigElement>(other.getMax()), static_cast<BigElement>(getMax())));
184 }

◆ fromCenterSize()

IntervalI lsst::geom::IntervalI::fromCenterSize ( double  center,
Element  size 
)
static

Create an interval centered as closely as possible on a particular point.

Parameters
centerThe desired center of the interval.
sizeNumber of pixels in interval. Nonpositive values will produce an empty interval.
Returns
if 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.
Exceptions
lsst::pex::exceptions::OverflowErrorThrown if the resulting interval would overflow.
lsst::pex::exceptions::InvalidParameterErrorThrown if center is not finite and size is positive.

Definition at line 75 of file Interval.cc.

75  {
76  if (size <= 0) {
77  return IntervalI();
78  }
79  double min = center - 0.5 * size;
80  // compensate for IntervalI's coordinate conventions (where max = min + size - 1)
81  min += 0.5;
82  checkForOverflow(min, "minimum");
83  checkForOverflow(min + size - 1, "maximum");
84  return IntervalI(static_cast<BigElement>(min), size);
85 }

◆ fromMaxSize()

IntervalI lsst::geom::IntervalI::fromMaxSize ( Element  max,
Element  size 
)
static

Construct an interval from its upper bound and size.

Parameters
[in]maxMaximum coordinate (inclusive).
[in]sizeNumber of pixels in interval. Nonpositive values will produce an empty interval.
Exceptions
lsst::pex::exceptions::OverflowErrorThrown if the resulting interval would overflow.

Definition at line 66 of file Interval.cc.

66  {
67  if (size <= 0) {
68  return IntervalI();
69  }
70  BigElement min = static_cast<BigElement>(max) - static_cast<BigElement>(size) + 1;
71  checkForOverflow(min, "minimum");
72  return IntervalI(static_cast<Element>(min), size);
73 }

◆ fromMinMax()

IntervalI lsst::geom::IntervalI::fromMinMax ( Element  min,
Element  max 
)
static

Construct an interval from its lower and upper bounds.

If min > max, the resulting interval is empty.

Parameters
[in]minMinimum coordinate (inclusive).
[in]maxMaximum coordinate (inclusive).
Exceptions
lsst::pex::exceptions::OverflowErrorThrown if the resulting interval would overflow.

Definition at line 53 of file Interval.cc.

53  {
54  return _fromMinMaxChecked(static_cast<BigElement>(min), static_cast<BigElement>(max));
55 }

◆ fromMinSize()

IntervalI lsst::geom::IntervalI::fromMinSize ( Element  min,
Element  size 
)
static

Construct an interval from its lower bound and size.

Parameters
[in]minMinimum coordinate (inclusive).
[in]sizeNumber of pixels in interval. Nonpositive values will produce an empty interval.
Exceptions
lsst::pex::exceptions::OverflowErrorThrown if the resulting interval would overflow.

Definition at line 57 of file Interval.cc.

57  {
58  if (size <= 0) {
59  return IntervalI();
60  }
61  BigElement max = static_cast<BigElement>(min) + static_cast<BigElement>(size) - 1;
62  checkForOverflow(max, "maximum");
63  return IntervalI(min, size);
64 }

◆ fromSpannedPoints() [1/3]

template<typename Iter >
static IntervalI lsst::geom::IntervalI::fromSpannedPoints ( Iter  first,
Iter  last 
)
inlinestatic

Construct an interval that contains all of the given points.

Parameters
[in]firstIterator to the beginning of a sequence of integers.
[in]lastIterator to one-past-the-end of a sequence of integers.

An empty interval is returned if first == last.

Exceptions
lsst::pex::exceptions::OverflowErrorThrown if the resulting interval would overflow.

Definition at line 92 of file Interval.h.

92  {
94  for (auto i = first; i != last; ++i) {
95  result = result.expandedTo(*i);
96  }
97  return result;
98  }
py::object result
Definition: _schema.cc:430

◆ fromSpannedPoints() [2/3]

static IntervalI lsst::geom::IntervalI::fromSpannedPoints ( ndarray::Array< Element const, 1 > const &  elements)
inlinestatic

Definition at line 115 of file Interval.h.

115  {
116  return fromSpannedPoints(elements.begin(), elements.end());
117  }
static IntervalI fromSpannedPoints(Iter first, Iter last)
Construct an interval that contains all of the given points.
Definition: Interval.h:92

◆ fromSpannedPoints() [3/3]

static IntervalI lsst::geom::IntervalI::fromSpannedPoints ( std::vector< Element > const &  elements)
inlinestatic

Construct an interval that contains all of the given points.

Parameters
[in]elementsPoints (integer values) to include in the interval.

An empty interval is returned if the given container has no elements.

Exceptions
lsst::pex::exceptions::OverflowErrorThrown if the resulting interval would overflow.

Definition at line 112 of file Interval.h.

112  {
113  return fromSpannedPoints(elements.begin(), elements.end());
114  }
T begin(T... args)
T end(T... args)

◆ getBegin()

Element lsst::geom::IntervalI::getBegin ( ) const
inlinenoexcept

Definition at line 238 of file Interval.h.

238 { return _min; }

◆ getEnd()

Element lsst::geom::IntervalI::getEnd ( ) const
inlinenoexcept

Definition at line 239 of file Interval.h.

239 { return _min + _size; }

◆ getMax()

Element lsst::geom::IntervalI::getMax ( ) const
inlinenoexcept

Definition at line 228 of file Interval.h.

228 { return _min + _size - 1; }

◆ getMin()

Element lsst::geom::IntervalI::getMin ( ) const
inlinenoexcept

Definition at line 227 of file Interval.h.

227 { return _min; }

◆ getSize()

Element lsst::geom::IntervalI::getSize ( ) const
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.

247 { return _size; }

◆ getSlice()

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.

112  {
113  return ndarray::view(getBegin(), getEnd());
114 }
Element getEnd() const noexcept
Definition: Interval.h:239
Element getBegin() const noexcept
Definition: Interval.h:238

◆ hash_value()

std::size_t lsst::geom::IntervalI::hash_value ( ) const
noexcept

Return a hash of this object.

Definition at line 199 of file Interval.cc.

199  {
200  // Completely arbitrary seed
201  return utils::hashCombine(17, _min, _size);
202 }
std::size_t hashCombine(std::size_t seed) noexcept
Combine hashes.
Definition: hashCombine.h:35

◆ intersects()

bool lsst::geom::IntervalI::intersects ( IntervalI const &  other) const
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.

283 { return overlaps(other); }
bool overlaps(IntervalI const &other) const noexcept
Return true if there are any points in both this and other.
Definition: Interval.cc:128

◆ isDisjointFrom()

bool lsst::geom::IntervalI::isDisjointFrom ( IntervalI const &  other) const
noexcept

Return true if there are no points in both this and other.

Definition at line 130 of file Interval.cc.

130  {
131  if (isEmpty() || other.isEmpty()) {
132  return true;
133  }
134  return getMin() > other.getMax() || getMax() < other.getMin();
135 }

◆ isEmpty()

bool lsst::geom::IntervalI::isEmpty ( ) const
inlinenoexcept

Return true if the interval contains no points.

Definition at line 262 of file Interval.h.

262 { return _size == 0; }

◆ operator!=()

bool lsst::geom::IntervalI::operator!= ( IntervalI const &  other) const
noexcept

Compare two intervals for equality.

All empty intervals are equal.

Definition at line 197 of file Interval.cc.

197 { return !(other == *this); }

◆ operator=() [1/2]

IntervalI& lsst::geom::IntervalI::operator= ( IntervalI &&  )
defaultnoexcept

Standard move assignment operatior.

◆ operator=() [2/2]

IntervalI& lsst::geom::IntervalI::operator= ( IntervalI const &  )
defaultnoexcept

Standard copy assignment operator.

◆ operator==()

bool lsst::geom::IntervalI::operator== ( IntervalI const &  other) const
noexcept

Compare two intervals for equality.

All empty intervals are equal.

Definition at line 193 of file Interval.cc.

193  {
194  return other._min == this->_min && other._size == this->_size;
195 }

◆ overlaps()

bool lsst::geom::IntervalI::overlaps ( IntervalI const &  other) const
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.

128 { return !isDisjointFrom(other); }
bool isDisjointFrom(IntervalI const &other) const noexcept
Return true if there are no points in both this and other.
Definition: Interval.cc:130

◆ reflectedAbout()

IntervalI lsst::geom::IntervalI::reflectedAbout ( Element  point) const

Reflect an interval about a point (returning a new object).

Empty intervals remain empty when reflected.

Definition at line 157 of file Interval.cc.

157  {
158  if (isEmpty()) {
159  return IntervalI();
160  }
161  BigElement max = 2 * static_cast<BigElement>(point) - getMin();
162  BigElement min = 2 * static_cast<BigElement>(point) - getMax();
163  return _fromMinMaxChecked(min, max);
164 }

◆ shiftedBy()

IntervalI lsst::geom::IntervalI::shiftedBy ( Element  offset) const

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.

146  {
147  if (isEmpty()) {
148  return IntervalI();
149  }
150  BigElement min = static_cast<BigElement>(getMin()) + offset;
151  BigElement max = static_cast<BigElement>(getMax()) + offset;
152  checkForOverflow(min, "minimum");
153  checkForOverflow(max, "maximum");
154  return IntervalI(static_cast<Element>(min), getSize());
155 }
Element getSize() const noexcept
Return slice to extract the interval's region from an ndarray::Array.
Definition: Interval.h:247

◆ swap()

void lsst::geom::IntervalI::swap ( IntervalI other)
inlinenoexcept

Definition at line 209 of file Interval.h.

209  {
210  using std::swap;
211  swap(_size, other._size);
212  swap(_min, other._min);
213  }
void swap(IntervalI &other) noexcept
Definition: Interval.h:209
T swap(T... args)

◆ toString()

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.

204  {
205  return (boost::format("(min=%s, max=%s)") % getMin() % getMax()).str();
206 }
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
Definition: history.py:174

The documentation for this class was generated from the following files: