00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkNonUniformBSpline.h,v $ 00005 Language: C++ 00006 Date: $Date: 2005/01/21 20:16:27 $ 00007 Version: $Revision: 1.4 $ 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 00019 #if defined(_MSC_VER) 00020 #pragma warning ( disable : 4786 ) 00021 #endif 00022 00023 #ifndef __itkNonUniformBSpline_h 00024 #define __itkNonUniformBSpline_h 00025 00026 #include <vector> 00027 00028 #include "itkPoint.h" 00029 #include "itkObject.h" 00030 #include "itkArray.h" 00031 00032 namespace itk { 00033 00047 template < unsigned int TDimension = 3 > 00048 class NonUniformBSpline 00049 : public Object 00050 { 00051 public: 00055 typedef NonUniformBSpline Self; 00056 typedef Object Superclass; 00057 typedef SmartPointer < Self > Pointer; 00058 typedef SmartPointer < const Self > ConstPointer; 00059 typedef double ScalarType; 00060 typedef itk::Point< ScalarType, TDimension > PointType; 00061 typedef std::vector < PointType > PointListType; 00062 typedef PointListType * PointListPointer; 00063 typedef std::vector < double > KnotListType; 00064 typedef std::vector<double> CoordinateListType; 00065 typedef itk::Point<double, TDimension > ControlPointType; 00066 typedef std::vector< ControlPointType > ControlPointListType; 00067 typedef ControlPointListType * ControlPointListPointer; 00068 typedef std::vector<double> ChordLengthListType; 00069 00071 itkNewMacro( Self ); 00072 00074 itkTypeMacro( NonUniformBSpline, Object ); 00075 00079 void SetPoints( PointListType & newPoints ); 00080 00084 PointListType& GetPoints() 00085 { 00086 return m_Points; 00087 } 00088 00093 void SetKnots( KnotListType & newKnots); 00094 00098 KnotListType& GetKnots(); 00099 00103 void ComputeChordLengths(); 00104 00109 PointType EvaluateSpline(const Array<double> & p) const; 00110 PointType EvaluateSpline( double t ) const; 00112 00116 void ComputeControlPoints(); 00117 00121 void SetControlPoints( ControlPointListType& ctrlpts ); 00122 00126 ControlPointListType& GetControlPoints() 00127 { 00128 return m_ControlPoints; 00129 } 00130 00137 double NonUniformBSplineFunctionRecursive(unsigned int order, unsigned int i, double t) const; 00138 00142 void SetSplineOrder(unsigned int order) 00143 { 00144 m_SplineOrder = order; 00145 this->Modified(); 00146 } 00148 00152 unsigned int GetSplineOrder() 00153 { 00154 return m_SplineOrder; 00155 } 00156 00157 protected: 00158 00162 NonUniformBSpline(); 00163 00167 virtual ~NonUniformBSpline(); 00168 00172 virtual void PrintSelf( std::ostream& os, Indent indent ) const; 00173 00177 PointListType m_Points; 00178 00182 KnotListType m_Knots; 00183 00187 ControlPointListType m_ControlPoints; 00188 00192 ChordLengthListType m_ChordLength; 00193 00197 ChordLengthListType m_CumulativeChordLength; 00198 00202 unsigned int m_SplineOrder; 00203 00207 unsigned int m_SpatialDimension; 00208 00209 }; 00210 00211 } // end namespace itk 00212 00213 #ifndef ITK_MANUAL_INSTANTIATION 00214 #include "itkNonUniformBSpline.txx" 00215 #endif 00216 00217 00218 #endif // __itkNonUniformBSpline_h 00219