Inkscape
Vector Graphics Editor
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages Concepts
Geom::GenericInterval< C > Class Template Reference

A range of numbers which is never empty. More...

#include <generic-interval.h>

Inheritance diagram for Geom::GenericInterval< C >:

Public Member Functions

Inspect contained values.
constexpr C min () const
 
constexpr C max () const
 
constexpr C extent () const
 
constexpr C middle () const
 
constexpr bool isSingular () const
 
operator[] (unsigned i) const
 
constexpr C operator[] (Dim2 d) const
 
constexpr C clamp (C val) const
 
nearestEnd (C val) const
 Return the closer end of the interval.
 
template<size_t I>
constexpr C get () const
 
Test coordinates and other intervals for inclusion.
constexpr bool contains (C val) const
 Check whether the interval includes this number.
 
constexpr bool contains (CInterval const &val) const
 Check whether the interval includes the given interval.
 
constexpr bool intersects (CInterval const &val) const
 Check whether the intervals have any common elements.
 
Modify the interval.
constexpr void setMin (C val)
 Set the lower boundary of the interval.
 
constexpr void setMax (C val)
 Set the upper boundary of the interval.
 
constexpr void setEnds (C a, C b)
 Set both ends of the interval simultaneously.
 
constexpr void expandTo (C val)
 Extend the interval to include the given number.
 
constexpr void expandBy (C amount)
 Expand or shrink the interval in both directions by the given amount.
 
constexpr void unionWith (CInterval const &a)
 Union the interval with another one.
 

Protected Attributes

_b [2] = { 0, 0 }
 

Private Types

using CInterval = typename CoordTraits< C >::IntervalType
 
using Self = GenericInterval< C >
 

Related Symbols

(Note that these are not member symbols.)

template<typename C >
GenericInterval< C > unify (GenericInterval< C > const &a, GenericInterval< C > const &b)
 Union two intervals.
 

Operators

using output_type = C
 
constexpr Selfoperator+= (C amnt)
 Offset the interval by a specified amount.
 
constexpr Selfoperator-= (C amnt)
 Offset the interval by the negation of the specified amount.
 
constexpr Self operator- () const
 Return an interval mirrored about 0.
 
constexpr Selfoperator+= (CInterval const &o)
 Add two intervals.
 
constexpr Selfoperator-= (CInterval const &o)
 Subtract two intervals.
 
constexpr Selfoperator|= (CInterval const &o)
 Union two intervals.
 
constexpr bool operator== (CInterval const &other) const
 Test for interval equality.
 

Create intervals.

constexpr GenericInterval ()=default
 Create an interval that contains only zero.
 
constexpr GenericInterval (C u)
 Create an interval that contains a single point.
 
constexpr GenericInterval (C u, C v)
 Create an interval that contains all points between u and v.
 
template<typename InputIterator >
static CInterval from_range (InputIterator start, InputIterator end)
 Create an interval containing a range of values.
 
static CInterval from_array (C const *c, unsigned n)
 Create an interval from a C-style array of values it should contain.
 

Detailed Description

template<typename C>
class Geom::GenericInterval< C >

A range of numbers which is never empty.

Definition at line 52 of file generic-interval.h.

Member Typedef Documentation

◆ CInterval

template<typename C >
using Geom::GenericInterval< C >::CInterval = typename CoordTraits<C>::IntervalType
private

Definition at line 55 of file generic-interval.h.

◆ output_type

template<typename C >
using Geom::GenericInterval< C >::output_type = C

Definition at line 197 of file generic-interval.h.

◆ Self

template<typename C >
using Geom::GenericInterval< C >::Self = GenericInterval<C>
private

Definition at line 56 of file generic-interval.h.

Constructor & Destructor Documentation

◆ GenericInterval() [1/3]

template<typename C >
constexpr Geom::GenericInterval< C >::GenericInterval ( )
constexprdefault

Create an interval that contains only zero.

◆ GenericInterval() [2/3]

template<typename C >
constexpr Geom::GenericInterval< C >::GenericInterval ( u)
inlineexplicitconstexpr

Create an interval that contains a single point.

Definition at line 65 of file generic-interval.h.

References Geom::GenericInterval< C >::_b.

◆ GenericInterval() [3/3]

template<typename C >
constexpr Geom::GenericInterval< C >::GenericInterval ( u,
v 
)
inlineconstexpr

Create an interval that contains all points between u and v.

Definition at line 67 of file generic-interval.h.

References Geom::GenericInterval< C >::_b.

Member Function Documentation

◆ clamp()

template<typename C >
constexpr C Geom::GenericInterval< C >::clamp ( val) const
inlineconstexpr

◆ contains() [1/2]

◆ contains() [2/2]

template<typename C >
constexpr bool Geom::GenericInterval< C >::contains ( CInterval const &  val) const
inlineconstexpr

Check whether the interval includes the given interval.

Definition at line 123 of file generic-interval.h.

References Geom::GenericInterval< C >::max(), and Geom::GenericInterval< C >::min().

◆ expandBy()

template<typename C >
constexpr void Geom::GenericInterval< C >::expandBy ( amount)
inlineconstexpr

Expand or shrink the interval in both directions by the given amount.

After this method, the interval's length (extent) will be increased by amount * 2. Negative values can be given; they will shrink the interval. Shrinking by a value larger than half the interval's length will create a degenerate interval containing only the midpoint of the original.

Definition at line 175 of file generic-interval.h.

References Geom::GenericInterval< C >::_b.

◆ expandTo()

template<typename C >
constexpr void Geom::GenericInterval< C >::expandTo ( val)
inlineconstexpr

◆ extent()

◆ from_array()

template<typename C >
static CInterval Geom::GenericInterval< C >::from_array ( C const *  c,
unsigned  n 
)
inlinestatic

Create an interval from a C-style array of values it should contain.

Definition at line 90 of file generic-interval.h.

References c, and Geom::GenericInterval< C >::from_range().

◆ from_range()

template<typename C >
template<typename InputIterator >
static CInterval Geom::GenericInterval< C >::from_range ( InputIterator  start,
InputIterator  end 
)
inlinestatic

Create an interval containing a range of values.

The resulting interval will contain all values from the given range. The return type of iterators must be convertible to C. The given range must not be empty. For potentially empty ranges, see GenericOptInterval.

Parameters
startBeginning of the range
endEnd of the range
Returns
Interval that contains all values from [start, end).

Definition at line 83 of file generic-interval.h.

References end, result, and start.

Referenced by Geom::GenericInterval< C >::from_array().

◆ get()

template<typename C >
template<size_t I>
constexpr C Geom::GenericInterval< C >::get ( ) const
inlineconstexpr

Definition at line 113 of file generic-interval.h.

References Geom::GenericInterval< C >::_b.

◆ intersects()

template<typename C >
constexpr bool Geom::GenericInterval< C >::intersects ( CInterval const &  val) const
inlineconstexpr

Check whether the intervals have any common elements.

Definition at line 127 of file generic-interval.h.

References Geom::GenericInterval< C >::contains().

◆ isSingular()

template<typename C >
constexpr bool Geom::GenericInterval< C >::isSingular ( ) const
inlineconstexpr

◆ max()

template<typename C >
constexpr C Geom::GenericInterval< C >::max ( ) const
inlineconstexpr

Definition at line 98 of file generic-interval.h.

References Geom::GenericInterval< C >::_b.

Referenced by SPHatch::_calculateRenderInfo(), SPHatch::_calculateStripExtents(), Geom::Curve::allNearestTimes(), Geom::Piecewise< T >::bounds_local(), Geom::GenericInterval< C >::clamp(), Geom::detail::bezier_clipping::clip(), Geom::detail::bezier_clipping::clip_interval(), Geom::computeLinfinityNeighborhood(), computeLinfinityNeighborhood(), Geom::GenericInterval< C >::contains(), Geom::GenericInterval< C >::contains(), convole(), convole(), Inkscape::LivePathEffect::LPEVonKoch::doBeforeEffect(), Inkscape::LivePathEffect::LPETiling::doBeforeEffect(), Inkscape::LivePathEffect::LPEBendPath::doBeforeEffect(), Inkscape::LivePathEffect::LPEMirrorSymmetry::doBeforeEffect(), Inkscape::LivePathEffect::LPEPerspectiveEnvelope::doBeforeEffect(), Inkscape::LivePathEffect::LPESlice::doBeforeEffect(), Inkscape::LivePathEffect::LPETransform2Pts::doBeforeEffect(), Inkscape::LivePathEffect::LPEPerspectiveEnvelope::doEffect(), Inkscape::LivePathEffect::LPEKnot::doEffect_path(), Inkscape::LivePathEffect::LPECopyRotate::doEffect_path(), Inkscape::LivePathEffect::LPECurveStitch::doEffect_path(), Inkscape::LivePathEffect::LPEEmbroderyStitch::doEffect_path(), Inkscape::LivePathEffect::LPEMirrorSymmetry::doEffect_path(), Inkscape::LivePathEffect::LPEPowerStroke::doEffect_path(), Inkscape::LivePathEffect::LPEMirrorSymmetry::doOnApply(), Inkscape::LivePathEffect::LPESlice::doOnApply(), Inkscape::LivePathEffect::LPETransform2Pts::doOnApply(), Geom::GenericInterval< C >::extent(), Inkscape::LivePathEffect::LPERoughHatches::generateLevels(), generateLevels(), Geom::RedBlack::high(), Geom::Interval::interiorContains(), Geom::Interval::interiorIntersects(), Geom::detail::bezier_clipping::intersection(), interval_repr(), interval_to_tuple(), Geom::GenericInterval< C >::isSingular(), log(), Geom::Interval::lowerContains(), Geom::GenericInterval< C >::middle(), Geom::mono_intersect(), Geom::monotonic_smash_intersect(), Geom::nearest_time(), Geom::GenericInterval< C >::nearestEnd(), Geom::Curve::nearestTime(), Geom::Interval::operator*=(), Geom::GenericInterval< C >::operator==(), Geom::Interval::operator==(), Geom::pair_intersect(), Geom::parting_point(), plot(), Geom::portion(), Geom::portion(), Geom::Curve::portion(), Geom::Path::portion(), Geom::Sweeper< SweepSet >::process(), Inkscape::LivePathEffect::LPEPerspectiveEnvelope::projectPoint(), Geom::xAx::quad_ex(), Geom::reciprocalOnDomain(), Inkscape::LivePathEffect::LPETransform2Pts::reset(), Inkscape::LivePathEffect::LPEBendPath::resetDefaults(), Inkscape::LivePathEffect::LPEEnvelope::resetDefaults(), Inkscape::LivePathEffect::LPELattice::resetDefaults(), Inkscape::LivePathEffect::LPEVonKoch::resetDefaults(), Geom::Bezier::roots(), Geom::RedBlackTree::search(), Inkscape::LivePathEffect::LPELattice2::setDefaults(), Inkscape::LivePathEffect::LPEPerspectiveEnvelope::setDefaults(), Geom::Piecewise< T >::setDomain(), smash_intersect(), sore_tooth(), Inkscape::LivePathEffect::LPESlice::splititem(), Geom::Interval::upperContains(), and zaggy().

◆ middle()

◆ min()

template<typename C >
constexpr C Geom::GenericInterval< C >::min ( ) const
inlineconstexpr

Definition at line 97 of file generic-interval.h.

References Geom::GenericInterval< C >::_b.

Referenced by SPHatch::_calculateRenderInfo(), SPHatch::_calculateStripExtents(), Geom::Curve::allNearestTimes(), Geom::Piecewise< T >::bounds_local(), Geom::GenericInterval< C >::clamp(), Geom::detail::bezier_clipping::clip(), Geom::detail::bezier_clipping::clip_interval(), Geom::computeLinfinityNeighborhood(), computeLinfinityNeighborhood(), Geom::GenericInterval< C >::contains(), Geom::GenericInterval< C >::contains(), convole(), convole(), Inkscape::LivePathEffect::LPEVonKoch::doBeforeEffect(), Inkscape::LivePathEffect::LPETiling::doBeforeEffect(), Inkscape::LivePathEffect::LPEBendPath::doBeforeEffect(), Inkscape::LivePathEffect::LPECopyRotate::doBeforeEffect(), Inkscape::LivePathEffect::LPEMirrorSymmetry::doBeforeEffect(), Inkscape::LivePathEffect::LPEPerspectiveEnvelope::doBeforeEffect(), Inkscape::LivePathEffect::LPESlice::doBeforeEffect(), Inkscape::LivePathEffect::LPETransform2Pts::doBeforeEffect(), Inkscape::LivePathEffect::LPEPerspectiveEnvelope::doEffect(), Inkscape::LivePathEffect::LPEKnot::doEffect_path(), Inkscape::LivePathEffect::LPECopyRotate::doEffect_path(), Inkscape::LivePathEffect::LPECurveStitch::doEffect_path(), Inkscape::LivePathEffect::LPEEmbroderyStitch::doEffect_path(), Inkscape::LivePathEffect::LPEInterpolate::doEffect_path(), Inkscape::LivePathEffect::LPEMirrorSymmetry::doEffect_path(), Inkscape::LivePathEffect::LPEPowerStroke::doEffect_path(), Inkscape::LivePathEffect::LPEBendPath::doEffect_pwd2(), Inkscape::LivePathEffect::LPEEnvelope::doEffect_pwd2(), Inkscape::LivePathEffect::LPELattice::doEffect_pwd2(), Inkscape::LivePathEffect::LPELattice2::doEffect_pwd2(), doEffect_pwd2(), Inkscape::LivePathEffect::LPECopyRotate::doOnApply(), Inkscape::LivePathEffect::LPEMirrorSymmetry::doOnApply(), Inkscape::LivePathEffect::LPESlice::doOnApply(), Inkscape::LivePathEffect::LPETransform2Pts::doOnApply(), Geom::GenericInterval< C >::extent(), Inkscape::LivePathEffect::LPERoughHatches::generateLevels(), generateLevels(), Geom::Interval::interiorContains(), Geom::Interval::interiorIntersects(), Geom::detail::bezier_clipping::intersection(), interval_repr(), interval_to_tuple(), Geom::GenericInterval< C >::isSingular(), Geom::RedBlack::key(), log(), Geom::Interval::lowerContains(), Geom::GenericInterval< C >::middle(), Geom::mono_intersect(), monotonic_smash_intersect(), Geom::monotonic_smash_intersect(), Geom::nearest_time(), Geom::GenericInterval< C >::nearestEnd(), Geom::Curve::nearestTime(), Geom::Interval::operator*=(), Geom::GenericInterval< C >::operator==(), Geom::Interval::operator==(), Geom::pair_intersect(), plot(), Geom::portion(), Geom::portion(), Geom::Curve::portion(), Geom::Path::portion(), Geom::Sweeper< SweepSet >::process(), Inkscape::LivePathEffect::LPEPerspectiveEnvelope::projectPoint(), Geom::xAx::quad_ex(), Geom::reciprocalOnDomain(), Inkscape::LivePathEffect::LPETransform2Pts::reset(), Inkscape::LivePathEffect::LPEBendPath::resetDefaults(), Inkscape::LivePathEffect::LPEEnvelope::resetDefaults(), Inkscape::LivePathEffect::LPELattice::resetDefaults(), Inkscape::LivePathEffect::LPEVonKoch::resetDefaults(), Geom::Bezier::roots(), Geom::RedBlackTree::search(), Inkscape::LivePathEffect::LPELattice2::setDefaults(), Inkscape::LivePathEffect::LPEPerspectiveEnvelope::setDefaults(), Geom::Piecewise< T >::setDomain(), smash_intersect(), sore_tooth(), Inkscape::LivePathEffect::LPESlice::splititem(), Geom::Interval::upperContains(), xlogx(), and zaggy().

◆ nearestEnd()

template<typename C >
C Geom::GenericInterval< C >::nearestEnd ( val) const
inline

Return the closer end of the interval.

Definition at line 108 of file generic-interval.h.

References Geom::GenericInterval< C >::max(), and Geom::GenericInterval< C >::min().

◆ operator+=() [1/2]

template<typename C >
constexpr Self & Geom::GenericInterval< C >::operator+= ( amnt)
inlineconstexpr

Offset the interval by a specified amount.

Definition at line 199 of file generic-interval.h.

References Geom::GenericInterval< C >::_b.

◆ operator+=() [2/2]

template<typename C >
constexpr Self & Geom::GenericInterval< C >::operator+= ( CInterval const &  o)
inlineconstexpr

Add two intervals.

Sum is defined as the set of points that can be obtained by adding any two values from both operands: \(S = \{x \in A, y \in B: x + y\}\)

Definition at line 215 of file generic-interval.h.

References Geom::GenericInterval< C >::_b.

◆ operator-()

template<typename C >
constexpr Self Geom::GenericInterval< C >::operator- ( ) const
inlineconstexpr

Return an interval mirrored about 0.

Definition at line 210 of file generic-interval.h.

References Geom::GenericInterval< C >::_b.

◆ operator-=() [1/2]

template<typename C >
constexpr Self & Geom::GenericInterval< C >::operator-= ( amnt)
inlineconstexpr

Offset the interval by the negation of the specified amount.

Definition at line 204 of file generic-interval.h.

References Geom::GenericInterval< C >::_b.

◆ operator-=() [2/2]

template<typename C >
constexpr Self & Geom::GenericInterval< C >::operator-= ( CInterval const &  o)
inlineconstexpr

Subtract two intervals.

Difference is defined as the set of points that can be obtained by subtracting any value from the second operand from any value from the first operand: \(S = \{x \in A, y \in B: x - y\}\)

Definition at line 224 of file generic-interval.h.

References Geom::GenericInterval< C >::_b.

◆ operator==()

template<typename C >
constexpr bool Geom::GenericInterval< C >::operator== ( CInterval const &  other) const
inlineconstexpr

Test for interval equality.

Definition at line 238 of file generic-interval.h.

References Geom::GenericInterval< C >::max(), and Geom::GenericInterval< C >::min().

◆ operator[]() [1/2]

template<typename C >
constexpr C Geom::GenericInterval< C >::operator[] ( Dim2  d) const
inlineconstexpr

Definition at line 103 of file generic-interval.h.

References Geom::GenericInterval< C >::_b.

◆ operator[]() [2/2]

template<typename C >
C Geom::GenericInterval< C >::operator[] ( unsigned  i) const
inline

Definition at line 102 of file generic-interval.h.

References Geom::GenericInterval< C >::_b.

◆ operator|=()

template<typename C >
constexpr Self & Geom::GenericInterval< C >::operator|= ( CInterval const &  o)
inlineconstexpr

Union two intervals.

Note that the intersection-and-assignment operator is not defined, because the result of an intersection can be empty, while Interval cannot.

Definition at line 233 of file generic-interval.h.

References Geom::GenericInterval< C >::unionWith().

◆ setEnds()

template<typename C >
constexpr void Geom::GenericInterval< C >::setEnds ( a,
b 
)
inlineconstexpr

Set both ends of the interval simultaneously.

Definition at line 156 of file generic-interval.h.

References Geom::GenericInterval< C >::_b.

Referenced by Geom::detail::bezier_clipping::map_to(), and read_interval().

◆ setMax()

template<typename C >
constexpr void Geom::GenericInterval< C >::setMax ( val)
inlineconstexpr

Set the upper boundary of the interval.

When the given number is smaller than the interval's smallest element, it will be reduced to the single number val.

Definition at line 148 of file generic-interval.h.

References Geom::GenericInterval< C >::_b.

Referenced by SPHatch::_calculateStripExtents().

◆ setMin()

template<typename C >
constexpr void Geom::GenericInterval< C >::setMin ( val)
inlineconstexpr

Set the lower boundary of the interval.

When the given number is larger than the interval's largest element, it will be reduced to the single number val.

Definition at line 138 of file generic-interval.h.

References Geom::GenericInterval< C >::_b.

Referenced by SPHatch::_calculateStripExtents().

◆ unionWith()

template<typename C >
constexpr void Geom::GenericInterval< C >::unionWith ( CInterval const &  a)
inlineconstexpr

Union the interval with another one.

The resulting interval will contain all points of both intervals. It might also contain some points which didn't belong to either - this happens when the intervals did not have any common elements.

Definition at line 187 of file generic-interval.h.

References Geom::GenericInterval< C >::_b.

Referenced by Geom::GenericInterval< C >::operator|=().

Friends And Related Symbol Documentation

◆ unify()

template<typename C >
GenericInterval< C > unify ( GenericInterval< C > const &  a,
GenericInterval< C > const &  b 
)
related

Union two intervals.

Definition at line 247 of file generic-interval.h.

Member Data Documentation

◆ _b


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