| 1 |
|
/*========================================================================= |
| 2 |
|
|
| 3 |
|
Program: Insight Segmentation & Registration Toolkit |
| 4 |
|
Module: $RCSfile: itkNonUniformBSpline.h.html,v $ |
| 5 |
|
Language: C++ |
| 6 |
|
Date: $Date: 2006/01/17 19:15:42 $ |
| 7 |
|
Version: $Revision: 1.4 $ |
| 8 |
|
|
| 9 |
|
Copyright (c) Insight Software Consortium. All rights reserved. |
| 10 |
|
See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. |
| 11 |
|
|
| 12 |
|
This software is distributed WITHOUT ANY WARRANTY; without even |
| 13 |
|
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 14 |
|
PURPOSE. See the above copyright notices for more information. |
| 15 |
|
|
| 16 |
DEF |
=========================================================================*/ |
| 17 |
|
|
| 18 |
|
|
| 19 |
|
#if defined(_MSC_VER) |
| 20 |
|
#pragma warning ( disable : 4786 ) |
| 21 |
|
#endif |
| 22 |
|
|
| 23 |
|
#ifndef __itkNonUniformBSpline_h |
| 24 |
|
#define __itkNonUniformBSpline_h |
| 25 |
|
|
| 26 |
|
#include <vector> |
| 27 |
|
|
| 28 |
|
#include "itkPoint.h" |
| 29 |
|
#include "itkObject.h" |
| 30 |
|
#include "itkArray.h" |
| 31 |
|
|
| 32 |
|
namespace itk { |
| 33 |
|
|
| 34 |
|
/** |
| 35 |
IND |
* \class NonUniformBSpline |
| 36 |
IND |
* \brief BSpline with nonuniform knot spacing. |
| 37 |
IND |
* |
| 38 |
IND |
* This class is a bspline with nonuniform knot spacing. The |
| 39 |
IND |
* use can specify a set of points and a set of knots and the |
| 40 |
IND |
* spline will attempt to find the control points which will |
| 41 |
IND |
* cause the spline to interpolate the points. |
| 42 |
IND |
* |
| 43 |
IND |
* CAUTION: THIS CLASS IS STILL UNDER DEVELOPMENT. |
| 44 |
IND |
* |
| 45 |
IND |
*/ |
| 46 |
|
|
| 47 |
|
template < unsigned int TDimension = 3 > |
| 48 |
|
class NonUniformBSpline |
| 49 |
IND |
**: public Object |
| 50 |
|
{ |
| 51 |
IND |
*public: |
| 52 |
|
/** |
| 53 |
|
Typedefs |
| 54 |
IND |
***/ |
| 55 |
|
typedef NonUniformBSpline Self; |
| 56 |
|
typedef Object Superclass; |
| 57 |
|
typedef SmartPointer < Self > Pointer; |
| 58 |
|
typedef SmartPointer < const Self > ConstPointer; |
| 59 |
|
typedef double ScalarType; |
| 60 |
|
typedef itk::Point< ScalarType, TDimension > PointType; |
| 61 |
|
typedef std::vector < PointType > PointListType; |
| 62 |
|
typedef PointListType * PointListPointer; |
| 63 |
|
typedef std::vector < double > KnotListType; |
| 64 |
|
typedef std::vector<double> CoordinateListType; |
| 65 |
|
typedef itk::Point<double, TDimension > ControlPointType; |
| 66 |
|
typedef std::vector< ControlPointType > ControlPointListType; |
| 67 |
|
typedef ControlPointListType * ControlPointListPointer; |
| 68 |
|
typedef std::vector<double> ChordLengthListType; |
| 69 |
|
|
| 70 |
|
/** Method for creation through the object factory. */ |
| 71 |
|
itkNewMacro( Self ); |
| 72 |
|
|
| 73 |
|
/** Method for creation through the object factory. */ |
| 74 |
|
itkTypeMacro( NonUniformBSpline, Object ); |
| 75 |
|
|
| 76 |
|
/** |
| 77 |
|
Set points which the spline will attempt to interpolate. |
| 78 |
IND |
***/ |
| 79 |
|
void SetPoints( PointListType & newPoints ); |
| 80 |
|
|
| 81 |
|
/** |
| 82 |
|
Get the points the spline is trying to interpolate. |
| 83 |
IND |
***/ |
| 84 |
|
PointListType& GetPoints() |
| 85 |
|
{ |
| 86 |
|
return m_Points; |
| 87 |
|
} |
| 88 |
|
|
| 89 |
|
/** |
| 90 |
|
Set the knot vector. Knots may be nonuniformly spaced. |
| 91 |
|
Knots will be rescaled to be between 0 and 1. |
| 92 |
IND |
***/ |
| 93 |
|
void SetKnots( KnotListType & newKnots); |
| 94 |
|
|
| 95 |
|
/** |
| 96 |
|
Get the knot vector. |
| 97 |
IND |
***/ |
| 98 |
|
KnotListType& GetKnots(); |
| 99 |
|
|
| 100 |
|
/** |
| 101 |
|
Computes the chord lengths based on the points. |
| 102 |
IND |
***/ |
| 103 |
|
void ComputeChordLengths(); |
| 104 |
|
|
| 105 |
|
/** |
| 106 |
|
Methods for evaluating the spline. |
| 107 |
|
The parameterization is always between 0 and 1. |
| 108 |
IND |
***/ |
| 109 |
|
PointType EvaluateSpline(const Array<double> & p) const; |
| 110 |
|
PointType EvaluateSpline( double t ) const; |
| 111 |
|
|
| 112 |
|
/** |
| 113 |
|
Compute the control points. |
| 114 |
IND |
***/ |
| 115 |
|
void ComputeControlPoints(); |
| 116 |
|
|
| 117 |
|
/** |
| 118 |
|
Set the control points for the spline. |
| 119 |
IND |
***/ |
| 120 |
|
void SetControlPoints( ControlPointListType& ctrlpts ); |
| 121 |
|
|
| 122 |
|
/** |
| 123 |
|
Get the control points for the spline |
| 124 |
IND |
***/ |
| 125 |
|
ControlPointListType& GetControlPoints() |
| 126 |
|
{ |
| 127 |
|
return m_ControlPoints; |
| 128 |
|
} |
| 129 |
|
|
| 130 |
|
/** |
| 131 |
|
Evaluate the basis functions directly. |
| 132 |
|
order - order of the basis function, i.e. 3 = cubic. |
| 133 |
|
i - basis function number, zero based. |
| 134 |
|
t - parameter of the spline. |
| 135 |
IND |
***/ |
| 136 |
LEN |
double NonUniformBSplineFunctionRecursive(unsigned int order, unsigned int i, double t) const; |
| 137 |
|
|
| 138 |
|
/** |
| 139 |
|
Set the order of the spline. |
| 140 |
IND |
***/ |
| 141 |
|
void SetSplineOrder(unsigned int order) |
| 142 |
|
{ |
| 143 |
|
m_SplineOrder = order; |
| 144 |
|
this->Modified(); |
| 145 |
|
} |
| 146 |
|
|
| 147 |
|
/** |
| 148 |
|
Get the order of the spline. |
| 149 |
IND |
***/ |
| 150 |
|
unsigned int GetSplineOrder() |
| 151 |
|
{ |
| 152 |
|
return m_SplineOrder; |
| 153 |
|
} |
| 154 |
|
|
| 155 |
IND |
*protected: |
| 156 |
|
|
| 157 |
|
/** |
| 158 |
|
Constructor |
| 159 |
IND |
***/ |
| 160 |
|
NonUniformBSpline(); |
| 161 |
|
|
| 162 |
|
/** |
| 163 |
|
Virtual destructor |
| 164 |
IND |
***/ |
| 165 |
|
virtual ~NonUniformBSpline(); |
| 166 |
|
|
| 167 |
|
/** |
| 168 |
IND |
****Method to print the object. |
| 169 |
IND |
***/ |
| 170 |
|
virtual void PrintSelf( std::ostream& os, Indent indent ) const; |
| 171 |
|
|
| 172 |
|
/** |
| 173 |
|
Points that the spline attempts to intepolate. |
| 174 |
IND |
***/ |
| 175 |
|
PointListType m_Points; |
| 176 |
|
|
| 177 |
|
/** |
| 178 |
|
The knots of spline. |
| 179 |
IND |
***/ |
| 180 |
|
KnotListType m_Knots; |
| 181 |
|
|
| 182 |
|
/** |
| 183 |
|
The control points of the spline. |
| 184 |
IND |
***/ |
| 185 |
|
ControlPointListType m_ControlPoints; |
| 186 |
|
|
| 187 |
|
/** |
| 188 |
|
The chord length computed from m_Points. |
| 189 |
IND |
***/ |
| 190 |
|
ChordLengthListType m_ChordLength; |
| 191 |
|
|
| 192 |
|
/** |
| 193 |
|
The cumulative chord length computed from m_Points |
| 194 |
IND |
***/ |
| 195 |
|
ChordLengthListType m_CumulativeChordLength; |
| 196 |
|
|
| 197 |
|
/** |
| 198 |
|
The order of the spline. |
| 199 |
IND |
***/ |
| 200 |
|
unsigned int m_SplineOrder; |
| 201 |
|
|
| 202 |
|
/** |
| 203 |
|
The spatial dimension. Saved from the template parameter. |
| 204 |
IND |
***/ |
| 205 |
|
unsigned int m_SpatialDimension; |
| 206 |
|
|
| 207 |
|
}; |
| 208 |
|
|
| 209 |
|
} // end namespace itk |
| 210 |
|
|
| 211 |
|
#ifndef ITK_MANUAL_INSTANTIATION |
| 212 |
|
#include "itkNonUniformBSpline.txx" |
| 213 |
|
#endif |
| 214 |
|
|
| 215 |
|
|
| 216 |
|
#endif // __itkNonUniformBSpline_h |
| 217 |
|
|