ITK  4.4.0
Insight Segmentation and Registration Toolkit
itkKdTreeGenerator.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef __itkKdTreeGenerator_h
19 #define __itkKdTreeGenerator_h
20 
21 #include <vector>
22 
23 #include "itkKdTree.h"
24 #include "itkStatisticsAlgorithm.h"
25 
26 namespace itk
27 {
28 namespace Statistics
29 {
69 template< class TSample >
70 class ITK_EXPORT KdTreeGenerator:public Object
71 {
72 public:
75  typedef Object Superclass;
78 
80  itkTypeMacro(KdTreeGenerator, Object);
81 
83  itkNewMacro(Self);
84 
86  typedef typename TSample::MeasurementVectorType MeasurementVectorType;
87  typedef typename TSample::MeasurementType MeasurementType;
88 
90  typedef unsigned int MeasurementVectorSizeType;
91 
94 
97 
100 
103 
106 
109 
111  void SetSample(TSample *sample);
112 
115  void SetBucketSize(unsigned int size);
116 
118  OutputPointer GetOutput()
119  {
120  return m_Tree;
121  }
122 
124  void Update()
125  {
126  this->GenerateData();
127  }
128 
130  void GenerateData();
131 
134  itkGetConstMacro(MeasurementVectorSize, unsigned int);
135 
136 protected:
138  KdTreeGenerator();
139 
141  virtual ~KdTreeGenerator() {}
142 
143  void PrintSelf(std::ostream & os, Indent indent) const;
144 
146  SubsamplePointer GetSubsample()
147  {
148  return m_Subsample;
149  }
150 
152  virtual KdTreeNodeType * GenerateNonterminalNode(unsigned int beginIndex,
153  unsigned int endIndex,
154  MeasurementVectorType
155  & lowerBound,
156  MeasurementVectorType
157  & upperBound,
158  unsigned int level);
159 
161  KdTreeNodeType * GenerateTreeLoop(unsigned int beginIndex, unsigned int endIndex,
162  MeasurementVectorType & lowerBound,
163  MeasurementVectorType & upperBound,
164  unsigned int level);
165 
166 private:
167  KdTreeGenerator(const Self &); //purposely not implemented
168  void operator=(const Self &); //purposely not implemented
169 
171  TSample *m_SourceSample;
172 
177 
180  unsigned int m_BucketSize;
181 
184 
187 
190 
193 
196 }; // end of class
197 } // end of namespace Statistics
198 } // end of namespace itk
199 
200 #ifndef ITK_MANUAL_INSTANTIATION
201 #include "itkKdTreeGenerator.hxx"
202 #endif
203 
204 #endif
205