vspline 1.1.0
Generic C++11 Code for Uniform B-Splines
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
vspline::bspline_base< _dimension > Struct Template Reference

struct bspline is the object in vspline holding b-spline coefficients. In a way, the b-spline 'is' it's coefficients, since it is totally determined by them - while, of course, the 'actual' spline is an n-dimensional curve. So, even if this is a bit sloppy, I often refer to the coefficients as 'the spline', and have named struct bspline so even if it just holds the coefficients. More...

#include <bspline.h>

Inheritance diagram for vspline::bspline_base< _dimension >:
vspline::bspline< _value_type, _dimension >

Public Types

enum  { dimension = _dimension }
 'suck in' the template argument More...
 
typedef vigra::TinyVector< std::ptrdiff_t, dimensionshape_type
 type of a multidimensional index type More...
 
typedef vigra::TinyVector< bc_code, dimensionbcv_type
 nD type for one boundary condition per axis More...
 
typedef vigra::TinyVector< xlf_type, dimensionlimit_type
 nD type for one limit condition per axis More...
 

Public Member Functions

xlf_type lower_limit (const int &axis) const
 
limit_type lower_limit () const
 
xlf_type upper_limit (const int &axis) const
 
limit_type upper_limit () const
 
 bspline_base (shape_type _core_shape, int _spline_degree, bcv_type _bcv, xlf_type _tolerance, int headroom)
 The constructor sets up all metrics of the spline from the basic properties given for the spline. Here, no defaults are offered, because this class is meant as a base class for splines only, and the expectation is that no objects of this class will be created. More...
 

Static Public Member Functions

static xlf_type lower_limit (const bc_code &bc)
 lower_limit returns the lower bound of the spline's defined range. This is usually 0.0, but with REFLECT boundary condition it's -0.5, the lower point of reflection. The lowest coordinate at which the spline can be accessed may be lower: even splines have wider support, and splines with extra headroom add even more room to manoevre. More...
 
static xlf_type upper_limit (const std::size_t &extent, const bc_code &bc)
 upper_limit returns the upper bound of the spline's defined range. This is normally M - 1 if the shape for this axis is M. Splines with REFLECT boundary condition use M - 0.5, the upper point of reflection, and periodic splines use M. The highest coordinate at which the spline may be accessed safely may be higher. More...
 
static shape_type get_left_brace_size (int spline_degree, bcv_type bcv)
 get_left_brace_size and get_right_brace_size calculate the size of the brace vspline puts around the 'core' coefficients to allow evaluation inside the defined range (and even slightly beyond) without bounds checking. These routines are static to allow user code to establish vspline's bracing requirements without creating a bspline object. user code might use this information to generate coefficient arrays suitable for use with vspline evaluation code, sidestepping use of a bspline object. More...
 
static shape_type get_right_brace_size (int spline_degree, bcv_type bcv)
 
static shape_type get_container_shape (int spline_degree, bcv_type bcv, shape_type core_shape, int headroom)
 convenience method to caculate the shape of a container array needed to hold the coefficients of a spline with the given properties. The arguments are the same as those passed to the bspline object's constructor, but this method is static, so it can be called on the spline's type and does not need an object. I'm including this to make it easier for code which creates the container array externally before constructing the bspline object, rather than relying on class bspline to allocate it's own storage. More...
 
template<typename = std::enable_if < _dimension == 1 >>
static long get_container_shape (int spline_degree, vspline::bc_code bc, long core_shape, int headroom)
 variant for 1D splines. This variant accepts the shape as a plain long, rather than requiring a TinyVector of one long. More...
 

Public Attributes

const bcv_type bcv
 
const xlf_type tolerance
 
const shape_type left_frame
 
const shape_type core_shape
 
const shape_type right_frame
 
const shape_type container_shape
 

Detailed Description

template<unsigned int _dimension>
struct vspline::bspline_base< _dimension >

struct bspline is the object in vspline holding b-spline coefficients. In a way, the b-spline 'is' it's coefficients, since it is totally determined by them - while, of course, the 'actual' spline is an n-dimensional curve. So, even if this is a bit sloppy, I often refer to the coefficients as 'the spline', and have named struct bspline so even if it just holds the coefficients.

The coefficients held in a bspline object are 'braced', providing a few extra extrapolated coefficients around a 'core' area corresponding with the knot point, or original data. This way, they can be used by vspline's evaluation code which relies on such a brace being present.

struct bspline is a convenience class which bundles a coefficient array (and it's creation) with a set of metadata describing the parameters used to create the coefficients and the resulting data. I have chosen to implement class bspline so that there is only a minimal set of template arguments, namely the spline's data type (like pixels etc.) and it's dimension. All other parameters relevant to the spline's creation are passed in at construction time. This way, if explicit specialization becomes necessary (like, to interface to code which can't use templates) the number of specializations remains manageable. This design decision pertains specifically to the spline's degree, which could also be implemented as a template argument, allowing for some optimization by making some members static. Yet going down this path requires explicit specialization for every spline degree used and the performance gain I found doing so was hardly measurable, while automatic testing became difficult and compilation times grew.

class bspline may or may not 'own' the coefficient data it refers to - this depends on the specific initialization used, but is handled privately by class b-spline, using a shared_ptr to the data if they are owned, which makes bspline objects trivially copyable.

The 'metadata part' of the bspline object is coded as a base class, which is convenient to derive other 'spline-like' classes with the same metadata structure. class bspline itself adds the coeffcients of the spline and the storage holding the coefficients.

Definition at line 191 of file bspline.h.

Member Typedef Documentation

◆ bcv_type

template<unsigned int _dimension>
typedef vigra::TinyVector< bc_code , dimension > vspline::bspline_base< _dimension >::bcv_type

nD type for one boundary condition per axis

Definition at line 203 of file bspline.h.

◆ limit_type

template<unsigned int _dimension>
typedef vigra::TinyVector< xlf_type , dimension > vspline::bspline_base< _dimension >::limit_type

nD type for one limit condition per axis

Definition at line 207 of file bspline.h.

◆ shape_type

template<unsigned int _dimension>
typedef vigra::TinyVector< std::ptrdiff_t , dimension > vspline::bspline_base< _dimension >::shape_type

type of a multidimensional index type

Definition at line 199 of file bspline.h.

Member Enumeration Documentation

◆ anonymous enum

template<unsigned int _dimension>
anonymous enum

'suck in' the template argument

Enumerator
dimension 

Definition at line 195 of file bspline.h.

Constructor & Destructor Documentation

◆ bspline_base()

template<unsigned int _dimension>
vspline::bspline_base< _dimension >::bspline_base ( shape_type  _core_shape,
int  _spline_degree,
bcv_type  _bcv,
xlf_type  _tolerance,
int  headroom 
)
inline

The constructor sets up all metrics of the spline from the basic properties given for the spline. Here, no defaults are offered, because this class is meant as a base class for splines only, and the expectation is that no objects of this class will be created.

Definition at line 458 of file bspline.h.

Member Function Documentation

◆ get_container_shape() [1/2]

template<unsigned int _dimension>
static shape_type vspline::bspline_base< _dimension >::get_container_shape ( int  spline_degree,
bcv_type  bcv,
shape_type  core_shape,
int  headroom 
)
inlinestatic

convenience method to caculate the shape of a container array needed to hold the coefficients of a spline with the given properties. The arguments are the same as those passed to the bspline object's constructor, but this method is static, so it can be called on the spline's type and does not need an object. I'm including this to make it easier for code which creates the container array externally before constructing the bspline object, rather than relying on class bspline to allocate it's own storage.

Definition at line 420 of file bspline.h.

◆ get_container_shape() [2/2]

template<unsigned int _dimension>
template<typename = std::enable_if < _dimension == 1 >>
static long vspline::bspline_base< _dimension >::get_container_shape ( int  spline_degree,
vspline::bc_code  bc,
long  core_shape,
int  headroom 
)
inlinestatic

variant for 1D splines. This variant accepts the shape as a plain long, rather than requiring a TinyVector of one long.

Definition at line 441 of file bspline.h.

◆ get_left_brace_size()

template<unsigned int _dimension>
static shape_type vspline::bspline_base< _dimension >::get_left_brace_size ( int  spline_degree,
bcv_type  bcv 
)
inlinestatic

get_left_brace_size and get_right_brace_size calculate the size of the brace vspline puts around the 'core' coefficients to allow evaluation inside the defined range (and even slightly beyond) without bounds checking. These routines are static to allow user code to establish vspline's bracing requirements without creating a bspline object. user code might use this information to generate coefficient arrays suitable for use with vspline evaluation code, sidestepping use of a bspline object.

Definition at line 297 of file bspline.h.

◆ get_right_brace_size()

template<unsigned int _dimension>
static shape_type vspline::bspline_base< _dimension >::get_right_brace_size ( int  spline_degree,
bcv_type  bcv 
)
inlinestatic

Definition at line 347 of file bspline.h.

◆ lower_limit() [1/3]

template<unsigned int _dimension>
limit_type vspline::bspline_base< _dimension >::lower_limit ( ) const
inline

Definition at line 241 of file bspline.h.

◆ lower_limit() [2/3]

template<unsigned int _dimension>
static xlf_type vspline::bspline_base< _dimension >::lower_limit ( const bc_code bc)
inlinestatic

lower_limit returns the lower bound of the spline's defined range. This is usually 0.0, but with REFLECT boundary condition it's -0.5, the lower point of reflection. The lowest coordinate at which the spline can be accessed may be lower: even splines have wider support, and splines with extra headroom add even more room to manoevre.

Definition at line 226 of file bspline.h.

◆ lower_limit() [3/3]

template<unsigned int _dimension>
xlf_type vspline::bspline_base< _dimension >::lower_limit ( const int &  axis) const
inline

Definition at line 236 of file bspline.h.

◆ upper_limit() [1/3]

template<unsigned int _dimension>
limit_type vspline::bspline_base< _dimension >::upper_limit ( ) const
inline

Definition at line 280 of file bspline.h.

◆ upper_limit() [2/3]

template<unsigned int _dimension>
xlf_type vspline::bspline_base< _dimension >::upper_limit ( const int &  axis) const
inline

Definition at line 268 of file bspline.h.

◆ upper_limit() [3/3]

template<unsigned int _dimension>
static xlf_type vspline::bspline_base< _dimension >::upper_limit ( const std::size_t &  extent,
const bc_code bc 
)
inlinestatic

upper_limit returns the upper bound of the spline's defined range. This is normally M - 1 if the shape for this axis is M. Splines with REFLECT boundary condition use M - 0.5, the upper point of reflection, and periodic splines use M. The highest coordinate at which the spline may be accessed safely may be higher.

Definition at line 255 of file bspline.h.

Member Data Documentation

◆ bcv

template<unsigned int _dimension>
const bcv_type vspline::bspline_base< _dimension >::bcv

Definition at line 212 of file bspline.h.

◆ container_shape

template<unsigned int _dimension>
const shape_type vspline::bspline_base< _dimension >::container_shape

Definition at line 218 of file bspline.h.

◆ core_shape

template<unsigned int _dimension>
const shape_type vspline::bspline_base< _dimension >::core_shape

Definition at line 216 of file bspline.h.

◆ left_frame

template<unsigned int _dimension>
const shape_type vspline::bspline_base< _dimension >::left_frame

Definition at line 215 of file bspline.h.

◆ right_frame

template<unsigned int _dimension>
const shape_type vspline::bspline_base< _dimension >::right_frame

Definition at line 217 of file bspline.h.

◆ tolerance

template<unsigned int _dimension>
const xlf_type vspline::bspline_base< _dimension >::tolerance

Definition at line 213 of file bspline.h.


The documentation for this struct was generated from the following file: