Home | History | Annotate | Download | only in Splines
      1 // This file is part of Eigen, a lightweight C++ template library
      2 // for linear algebra.
      3 //
      4 // Copyright (C) 20010-2011 Hauke Heibel <hauke.heibel (at) gmail.com>
      5 //
      6 // This Source Code Form is subject to the terms of the Mozilla
      7 // Public License v. 2.0. If a copy of the MPL was not distributed
      8 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
      9 
     10 #ifndef EIGEN_SPLINES_FWD_H
     11 #define EIGEN_SPLINES_FWD_H
     12 
     13 #include <Eigen/Core>
     14 
     15 namespace Eigen
     16 {
     17     template <typename Scalar, int Dim, int Degree = Dynamic> class Spline;
     18 
     19     template < typename SplineType, int DerivativeOrder = Dynamic > struct SplineTraits {};
     20 
     21     /**
     22      * \ingroup Splines_Module
     23      * \brief Compile-time attributes of the Spline class for Dynamic degree.
     24      **/
     25     template <typename _Scalar, int _Dim, int _Degree>
     26     struct SplineTraits< Spline<_Scalar, _Dim, _Degree>, Dynamic >
     27     {
     28       typedef _Scalar Scalar; /*!< The spline curve's scalar type. */
     29       enum { Dimension = _Dim /*!< The spline curve's dimension. */ };
     30       enum { Degree = _Degree /*!< The spline curve's degree. */ };
     31 
     32       enum { OrderAtCompileTime = _Degree==Dynamic ? Dynamic : _Degree+1 /*!< The spline curve's order at compile-time. */ };
     33       enum { NumOfDerivativesAtCompileTime = OrderAtCompileTime /*!< The number of derivatives defined for the current spline. */ };
     34 
     35       enum { DerivativeMemoryLayout = Dimension==1 ? RowMajor : ColMajor /*!< The derivative type's memory layout. */ };
     36 
     37       /** \brief The data type used to store non-zero basis functions. */
     38       typedef Array<Scalar,1,OrderAtCompileTime> BasisVectorType;
     39 
     40       /** \brief The data type used to store the values of the basis function derivatives. */
     41       typedef Array<Scalar,Dynamic,Dynamic,RowMajor,NumOfDerivativesAtCompileTime,OrderAtCompileTime> BasisDerivativeType;
     42 
     43       /** \brief The data type used to store the spline's derivative values. */
     44       typedef Array<Scalar,Dimension,Dynamic,DerivativeMemoryLayout,Dimension,NumOfDerivativesAtCompileTime> DerivativeType;
     45 
     46       /** \brief The point type the spline is representing. */
     47       typedef Array<Scalar,Dimension,1> PointType;
     48 
     49       /** \brief The data type used to store knot vectors. */
     50       typedef Array<Scalar,1,Dynamic> KnotVectorType;
     51 
     52       /** \brief The data type used to store parameter vectors. */
     53       typedef Array<Scalar,1,Dynamic> ParameterVectorType;
     54 
     55       /** \brief The data type representing the spline's control points. */
     56       typedef Array<Scalar,Dimension,Dynamic> ControlPointVectorType;
     57     };
     58 
     59     /**
     60      * \ingroup Splines_Module
     61      * \brief Compile-time attributes of the Spline class for fixed degree.
     62      *
     63      * The traits class inherits all attributes from the SplineTraits of Dynamic degree.
     64      **/
     65     template < typename _Scalar, int _Dim, int _Degree, int _DerivativeOrder >
     66     struct SplineTraits< Spline<_Scalar, _Dim, _Degree>, _DerivativeOrder > : public SplineTraits< Spline<_Scalar, _Dim, _Degree> >
     67     {
     68       enum { OrderAtCompileTime = _Degree==Dynamic ? Dynamic : _Degree+1 /*!< The spline curve's order at compile-time. */ };
     69       enum { NumOfDerivativesAtCompileTime = _DerivativeOrder==Dynamic ? Dynamic : _DerivativeOrder+1 /*!< The number of derivatives defined for the current spline. */ };
     70 
     71       enum { DerivativeMemoryLayout = _Dim==1 ? RowMajor : ColMajor /*!< The derivative type's memory layout. */ };
     72 
     73       /** \brief The data type used to store the values of the basis function derivatives. */
     74       typedef Array<_Scalar,Dynamic,Dynamic,RowMajor,NumOfDerivativesAtCompileTime,OrderAtCompileTime> BasisDerivativeType;
     75 
     76       /** \brief The data type used to store the spline's derivative values. */
     77       typedef Array<_Scalar,_Dim,Dynamic,DerivativeMemoryLayout,_Dim,NumOfDerivativesAtCompileTime> DerivativeType;
     78     };
     79 
     80     /** \brief 2D float B-spline with dynamic degree. */
     81     typedef Spline<float,2> Spline2f;
     82 
     83     /** \brief 3D float B-spline with dynamic degree. */
     84     typedef Spline<float,3> Spline3f;
     85 
     86     /** \brief 2D double B-spline with dynamic degree. */
     87     typedef Spline<double,2> Spline2d;
     88 
     89     /** \brief 3D double B-spline with dynamic degree. */
     90     typedef Spline<double,3> Spline3d;
     91 }
     92 
     93 #endif // EIGEN_SPLINES_FWD_H
     94