#ifndef __CPM__ALGORITHMS__BASE__FINDCLOSESTPOINTINMESH__H__ #define __CPM__ALGORITHMS__BASE__FINDCLOSESTPOINTINMESH__H__ #include #include #include #include namespace cpm { namespace Algorithms { namespace Base { /** */ template< class M, class S = float > class FindClosestPointInMesh : public itk::Object { public: typedef FindClosestPointInMesh Self; typedef itk::Object Superclass; typedef itk::SmartPointer< Self > Pointer; typedef itk::SmartPointer< const Self > ConstPointer; itkStaticConstMacro( Dimension, unsigned int, M::PointDimension ); typedef S TKDScalar; typedef cpm::DataStructures::KDVector< S, Dimension > TKDVector; typedef itk::Statistics::ListSample< TKDVector > TKDSample; typedef itk::Statistics::WeightedCentroidKdTreeGenerator< TKDSample > TKDGenerator; typedef typename TKDGenerator::KdTreeType TKDTree; typedef typename TKDTree::KdTreeNodeType TKDNode; public: itkNewMacro( Self ); itkTypeMacro( FindClosestPointInMesh, itkObject ); itkGetConstMacro( BucketSize, unsigned int ); itkSetMacro( BucketSize, unsigned int ); itkGetConstObjectMacro( Mesh, M ); public: void SetMesh( const M* m ); void Build( ); template< class P > typename M::PointIdentifier FindClosestPoint( const P& p ) const; template< class P, class C > typename M::PointIdentifier FindClosestPoint( const P& p, const C& c ) const; template< class V, class N > void _Dummy( TKDNode* root, const V& d, const V& n, const N& nd ) const; protected: FindClosestPointInMesh( ); virtual ~FindClosestPointInMesh( ); template< class V, class N, class P > static S _LinePointDistance( const P& p0, const V& d, const V& n, const N& nd ); private: // Purposely not implemented FindClosestPointInMesh( Self& ); Self& operator=( Self& ); protected: unsigned int m_BucketSize; typename M::ConstPointer m_Mesh; typename TKDSample::Pointer m_KDSample; typename TKDGenerator::Pointer m_KDGenerator; typename TKDTree::Pointer m_KDTree; }; } // ecapseman } // ecapseman } // ecapseman #include #endif // __CPM__ALGORITHMS__BASE__FINDCLOSESTPOINTINMESH__H__ // eof - $RCSfile$