00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkStatNearestNeighborFinder.h,v $ 00005 Language: C++ 00006 Date: $Date: 2002/01/15 19:38:57 $ 00007 Version: $Revision: 1.4 $ 00008 00009 Copyright (c) 2002 Insight 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 #ifndef __itkStatNearestNeighborFinder_h 00018 #define __itkStatNearestNeighborFinder_h 00019 00020 #include "itkLightProcessObject.h" 00021 #include "itkStatDistanceFunctions.h" 00022 00023 namespace itk { 00043 template<class TDataSet, class TPoint> 00044 class NearestNeighborFinder: public LightProcessObject 00045 { 00046 public: 00050 typedef TDataSet DataSetType ; 00051 00055 typedef TPoint PointType ; 00056 00060 typedef std::vector<PointType> OutputType ; 00061 00065 typedef NearestNeighborFinder Self; 00066 00070 typedef LightProcessObject Superclass; 00071 00075 typedef SmartPointer<Self> Pointer; 00076 typedef SmartPointer<const Self> ConstPointer; 00077 00081 itkNewMacro(Self); 00082 00086 itkTypeMacro(NearestNeighborFinder, LightProcessObject); 00087 00091 struct InvalidInputError 00092 { 00093 InvalidInputError() {} 00094 } ; 00095 00108 void SetInputParams(int K, DataSetType* dataSet, PointType* queryPoint) 00109 throw (InvalidInputError) ; 00110 00121 OutputType GetOutput() throw (InvalidInputError) ; 00122 00123 00124 protected: 00128 NearestNeighborFinder() ; 00129 00137 typedef struct 00138 { 00139 PointType Point ; 00140 double Distance ; 00141 } NeighborType ; 00142 00149 typedef std::vector<NeighborType> NeighborsType ; 00150 00154 void GenerateData() ; 00155 00165 NeighborsType::iterator FindReplacement(double distance) ; 00166 00174 void CopyOutput() ; 00175 00179 double GetDistance(PointType* A, PointType* B) ; 00180 00181 private: 00185 int m_K ; 00186 00191 PointType* m_QueryPoint ; 00192 00196 DataSetType* m_DataSet ; 00197 00201 NeighborsType m_Neighbors ; 00202 00206 OutputType m_Output ; 00207 00211 bool m_ValidInputs ; 00212 00218 bool m_InputsModified ; 00219 } ; // end of class 00220 } // end of namespace itk 00221 00222 #ifndef ITK_MANUAL_INSTANTIATION 00223 #include "itkStatNearestNeighborFinder.txx" 00224 #endif 00225 00226 #endif