18 #ifndef __itkPSMPointTree_h 19 #define __itkPSMPointTree_h 21 #include "itkPSMPointIndexPair.h" 22 #include "itkLightObject.h" 23 #include "itkDataObject.h" 24 #include "itkWeakPointer.h" 25 #include "itkTreeContainer.h" 33 template <
int a,
int b>
36 static const int c = a *
powstruct<a,b-1>::c;
41 static const int c = 1;
54 template <
unsigned int VDimension>
60 typedef SmartPointer<Self> Pointer;
61 typedef SmartPointer<const Self> ConstPointer;
62 typedef LightObject Superclass;
81 if ((m_LowerBound == o.m_LowerBound) && (m_UpperBound == o.m_UpperBound) )
return true;
91 if (m_Branches[0].GetPointer() != 0)
return false;
98 return m_List.insert(m_List.end(), elem);
105 for (
unsigned int i = 0; i < VDimension; i++)
107 if (p[i] < m_LowerBound[i] || p[i] >= m_UpperBound[i])
return false;
114 { m_LowerBound = p; }
115 const PointType &GetLowerBound()
const 116 {
return m_LowerBound; }
117 void SetUpperBound(
const PointType &p)
118 { m_UpperBound = p; }
119 const PointType &GetUpperBound()
const 120 {
return m_UpperBound; }
124 {
return m_Branches; }
125 const typename Self::Pointer *GetBranches()
const 126 {
return m_Branches; }
130 {
return m_Branches[i]; }
131 const typename Self::Pointer &GetBranch(
unsigned int i)
const 132 {
return m_Branches[i]; }
135 void SetBranch(
unsigned int b,
typename Self::Pointer n)
136 { this->GetBranch(b) = n; }
139 void PrintSelf(std::ostream& os, Indent indent)
const;
144 PointListType &GetList()
155 PointType m_LowerBound;
156 PointType m_UpperBound;
157 PointListType m_List;
173 template <
unsigned int VDimension>
179 typedef DataObject Superclass;
180 typedef SmartPointer<Self> Pointer;
181 typedef SmartPointer<const Self> ConstPointer;
182 typedef WeakPointer<const Self> ConstWeakPointer;
195 typedef std::vector<typename PointListType::const_iterator> PointIteratorListType;
204 itkStaticConstMacro(Dimension,
unsigned int, VDimension);
211 itkGetMacro(Depth,
unsigned int);
216 void ConstructTree(
const PointType &,
const PointType &,
unsigned int);
223 PointIteratorListType FindPointsInRegion(
const PointType &,
const PointType &)
const;
224 unsigned int FindPointsInRegion(
const PointType &,
const PointType &, PointIteratorListType &)
const;
228 NodePointerType GetNode(
const PointType &);
229 const NodePointerType GetNode(
const PointType &)
const;
232 itkGetObjectMacro(Root, NodeType);
233 itkSetObjectMacro(Root, NodeType);
245 typename PointListType::iterator AddPoint(
const PointType &,
246 unsigned int, NodePointerType &);
247 typename PointListType::iterator AddPoint(
const PointType &p,
250 NodePointerType node = NodeType::New();
251 return this->AddPoint(p, i, node);
256 bool Overlap(
const NodePointerType &,
const PointType &,
const PointType &)
const;
259 inline bool RegionContains(
const PointType &p,
const PointType &lowerbound,
260 const PointType &upperbound)
const 262 for (
unsigned int i = 0; i < VDimension; i++)
264 if (p[i] < lowerbound[i] || p[i] >= upperbound[i])
return false;
269 void PrintSelf(std::ostream& os, Indent indent)
const;
279 void BranchNode(NodePointerType &,
unsigned int);
284 void FindOneNodeInRegion(
const NodePointerType&,
const PointType &,
const PointType &,
285 PointIteratorListType &)
const;
289 void operator=(
const Self&);
291 NodePointerType m_Root;
293 unsigned int m_Depth;
298 #ifndef ITK_MANUAL_INSTANTIATION 299 #include "itkPSMPointTree.hxx" bool Contains(const PointType &p) const
PointListType::iterator InsertElement(const PSMPointIndexPair< VDimension > &elem)
bool operator==(const PSMPointTreeNode &o) const
PSMPointTreeNode< VDimension >::PointType PointType
Self::Pointer & GetBranch(unsigned int i)
PSMPointTreeNode< VDimension > NodeType
Struct containing a Point and an index value associated with a point. This object is used mainly by P...
Point< double, VDimension > PointType
Self::Pointer * GetBranches()
const PointListType & GetList() const
std::list< PSMPointIndexPair< VDimension > > PointListType
NodeType::Pointer NodePointerType
NodeType::PointListType PointListType
void SetLowerBound(const PointType &p)
void SetBranch(unsigned int b, typename Self::Pointer n)