8#ifndef BSPLINE_SUPPORT_SUPPORT_H
9#define BSPLINE_SUPPORT_SUPPORT_H
11#include <bspline/exceptions/BSplineException.h>
12#include <bspline/support/Grid.h>
70 void checkValidity()
const {
71 const bool isEmpty = _startIndex == 0 && _endIndex == 0;
121 : _grid{
s._grid}, _startIndex{
s._startIndex}, _endIndex{
s._endIndex} {
138 _startIndex =
s._startIndex;
139 _endIndex =
s._endIndex;
172 return _endIndex - _startIndex;
183 return (_startIndex == _endIndex);
211 if (index >= _startIndex && index < _endIndex) {
212 return index - _startIndex;
231 if (index >= _startIndex && index + 1 < _endIndex) {
232 return index - _startIndex;
250 if (index >=
size()) {
253 return index + _startIndex;
308 return _grid[_startIndex + index];
323 if (_startIndex + index >= _endIndex) {
326 return _grid.
at(_startIndex + index);
341 return _grid[_startIndex];
357 return _grid[_endIndex - 1];
366 return _grid.
begin() + _startIndex;
375 return _grid.
begin() + _endIndex;
389 return _grid ==
s._grid;
406 ((_startIndex ==
s._startIndex && _endIndex ==
s._endIndex) ||
423 return !(*
this ==
s);
457 const size_t newStartIndex = std::min(_startIndex,
s._startIndex);
458 const size_t newEndIndex = std::max(_endIndex,
s._endIndex);
478 const size_t newStartIndex = std::max(_startIndex,
s._startIndex);
479 const size_t newEndIndex = std::min(_endIndex,
s._endIndex);
The main exception class.
Definition BSplineException.h:84
Represents a global Grid.
Definition Grid.h:27
const T & at(size_t i) const
Gives access to the i-th element of the Grid.
Definition Grid.h:218
typename std::vector< T >::const_iterator const_iterator
Iterator type.
Definition Grid.h:66
size_t size() const
Returns the number of elements of the Grid.
Definition Grid.h:169
bool empty() const
Checks whether the spline is empty.
Definition Grid.h:192
const_iterator begin() const
Returns the begin iterator of the Grid.
Definition Grid.h:256
Represents the Spline's Support.
Definition Support.h:33
bool containsIntervals() const
Returns false if this Support is empty or point-like.
Definition Support.h:193
Support(const Support &s) noexcept=default
Default copy constructor.
const_iterator begin() const
Returns the begin iterator of the Support.
Definition Support.h:364
std::optional< RelativeIndex > relativeFromAbsolute(AbsoluteIndex index) const
Converts an AbsoluteIndex into a RelativeIndex.
Definition Support.h:209
std::optional< RelativeIndex > intervalIndexFromAbsolute(AbsoluteIndex index) const
Converts an AbsoluteIndex into a RelativeIndex.
Definition Support.h:228
typename Grid< T >::const_iterator const_iterator
The iterator type.
Definition Support.h:50
Support(const Grid< T > &grid, AbsoluteIndex startIndex, AbsoluteIndex endIndex)
Constructs a Support relative to the global Grid grid.
Definition Support.h:91
AbsoluteIndex getEndIndex() const
Returns the _endIndex.
Definition Support.h:292
~Support()=default
Default destructor.
size_t numberOfIntervals() const
Returns the number of intervals represented by this Support.
Definition Support.h:260
Support calcIntersection(const Support &s) const
Calculates the intersection of the two Supports.
Definition Support.h:471
static Support< T > createEmpty(const Grid< T > &grid)
Constructs an empty Support relative to the global Grid grid.
Definition Support.h:153
const_iterator end() const
Returns the end iterator of the Support.
Definition Support.h:373
const T & at(RelativeIndex index) const
Returns the indexed element.
Definition Support.h:321
const T & operator[](RelativeIndex index) const
Returns the indexed element.
Definition Support.h:306
bool operator!=(const Support &s) const
Logically compares to Supports.
Definition Support.h:420
const T & front() const
Returns the begin of this Support.
Definition Support.h:336
Support & operator=(Support &&s) noexcept
Move assignment operator.
Definition Support.h:136
size_t size() const
Returns the number of grid points contained in this Support.
Definition Support.h:170
AbsoluteIndex absoluteFromRelative(RelativeIndex index) const
Converts a RelativeIndex into an AbsoluteIndex.
Definition Support.h:248
Support calcUnion(const Support &s) const
Calculates the union of the two Supports.
Definition Support.h:438
bool operator==(const Support &s) const
Logically compares to Supports.
Definition Support.h:402
bool hasSameGrid(const Support &s) const
Checks whether two Supports are defined on the same Grids.
Definition Support.h:387
const Grid< T > & getGrid() const
Returns the global Grid.
Definition Support.h:274
const T & back() const
Returns the end of this Support.
Definition Support.h:352
Support & operator=(const Support &s) noexcept=default
Default copy assignment operator.
bool empty() const
Returns whether this Support is empty.
Definition Support.h:181
AbsoluteIndex getStartIndex() const
Returns the _startIndex.
Definition Support.h:283
static Support< T > createWholeGrid(const Grid< T > &grid)
Constructs a Support representing the complete global grid grid.
Definition Support.h:161
Support(Support &&s) noexcept
Move constructor.
Definition Support.h:120
Exceptions and error codes.
Definition BSplineException.h:19
Namespace for the Spline's Grid and Support.
Definition Grid.h:19