00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkNonUniformBSpline.h,v $ 00005 Language: C++ 00006 Date: $Date: 2009-02-06 20:53:13 $ 00007 Version: $Revision: 1.5 $ 00008 00009 Copyright (c) Insight Software Consortium. All rights reserved. 00010 See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 00015 00016 =========================================================================*/ 00017 00018 #ifndef __itkNonUniformBSpline_h 00019 #define __itkNonUniformBSpline_h 00020 00021 #if defined(_MSC_VER) 00022 #pragma warning ( disable : 4786 ) 00023 #endif 00024 00025 #include <vector> 00026 00027 #include "itkPoint.h" 00028 #include "itkObject.h" 00029 #include "itkArray.h" 00030 00031 namespace itk { 00032 00046 template < unsigned int TDimension = 3 > 00047 class NonUniformBSpline 00048 : public Object 00049 { 00050 public: 00054 typedef NonUniformBSpline Self; 00055 typedef Object Superclass; 00056 typedef SmartPointer < Self > Pointer; 00057 typedef SmartPointer < const Self > ConstPointer; 00058 typedef double ScalarType; 00059 typedef itk::Point< ScalarType, TDimension > PointType; 00060 typedef std::vector < PointType > PointListType; 00061 typedef PointListType * PointListPointer; 00062 typedef std::vector < double > KnotListType; 00063 typedef std::vector<double> CoordinateListType; 00064 typedef itk::Point<double, TDimension > ControlPointType; 00065 typedef std::vector< ControlPointType > ControlPointListType; 00066 typedef ControlPointListType * ControlPointListPointer; 00067 typedef std::vector<double> ChordLengthListType; 00068 00070 itkNewMacro( Self ); 00071 00073 itkTypeMacro( NonUniformBSpline, Object ); 00074 00078 void SetPoints( PointListType & newPoints ); 00079 00083 PointListType& GetPoints() 00084 { 00085 return m_Points; 00086 } 00087 00092 void SetKnots( KnotListType & newKnots); 00093 00097 KnotListType& GetKnots(); 00098 00102 void ComputeChordLengths(); 00103 00108 PointType EvaluateSpline(const Array<double> & p) const; 00109 PointType EvaluateSpline( double t ) const; 00111 00115 void ComputeControlPoints(); 00116 00120 void SetControlPoints( ControlPointListType& ctrlpts ); 00121 00125 ControlPointListType& GetControlPoints() 00126 { 00127 return m_ControlPoints; 00128 } 00129 00136 double NonUniformBSplineFunctionRecursive(unsigned int order, unsigned int i, double t) const; 00137 00141 void SetSplineOrder(unsigned int order) 00142 { 00143 m_SplineOrder = order; 00144 this->Modified(); 00145 } 00147 00151 unsigned int GetSplineOrder() 00152 { 00153 return m_SplineOrder; 00154 } 00155 00156 protected: 00157 00161 NonUniformBSpline(); 00162 00166 virtual ~NonUniformBSpline(); 00167 00171 virtual void PrintSelf( std::ostream& os, Indent indent ) const; 00172 00176 PointListType m_Points; 00177 00181 KnotListType m_Knots; 00182 00186 ControlPointListType m_ControlPoints; 00187 00191 ChordLengthListType m_ChordLength; 00192 00196 ChordLengthListType m_CumulativeChordLength; 00197 00201 unsigned int m_SplineOrder; 00202 00206 unsigned int m_SpatialDimension; 00207 00208 }; 00209 00210 } // end namespace itk 00211 00212 #ifndef ITK_MANUAL_INSTANTIATION 00213 #include "itkNonUniformBSpline.txx" 00214 #endif 00215 00216 00217 #endif // __itkNonUniformBSpline_h 00218