Parasol Planning Library (PPL)
KdTreeNF.h
Go to the documentation of this file.
1 #ifndef PMPL_KDTREE_NF_H_
2 #define PMPL_KDTREE_NF_H_
3 
5 
6 #include <CGAL/Cartesian_d.h>
7 #include <CGAL/Search_traits.h>
8 #include <CGAL/Orthogonal_k_neighbor_search.h>
9 
10 #include <map>
11 
12 
37 class KdTreeNF : virtual public NeighborhoodFinderMethod {
38 
39  public:
40 
44  typedef typename RoadmapType::VI VI;
45  typedef typename RoadmapType::VID VID;
50 
54 
55  using typename NeighborhoodFinderMethod::Type;
57 
59 
60  private:
61 
64 
66  typedef CGAL::Cartesian_d<double> Kernel;
67 
70  struct PointD : public Kernel::Point_d {
71 
72  PointD() : Kernel::Point_d() {}
73 
74  PointD(const Cfg& _cfg) : PointD(INVALID_VID, _cfg)
75  {}
76 
77  PointD(const VID _vid, const Cfg& _cfg) :
78  Kernel::Point_d(_cfg.DOF(), _cfg.GetData().begin(),
79  _cfg.GetData().end()), vid(_vid)
80  {}
81 
82  VID vid{INVALID_VID};
83 
84  };
85 
87  typedef CGAL::Search_traits<Kernel::FT, // Field type.
88  PointD, // Point type.
89  Kernel::Cartesian_const_iterator_d, // Coordinate iterator.
90  Kernel::Construct_cartesian_const_iterator_d // Constructs iterator.
91  > TreeTraits;
92 
94  typedef CGAL::Orthogonal_k_neighbor_search<TreeTraits> NeighborSearch;
95 
97  typedef typename NeighborSearch::Tree KdTree;
98 
101  typedef std::pair<RoadmapType*, const VertexSet*> ModelKey;
102 
104 
105  public:
106 
109 
110  KdTreeNF();
111 
112  KdTreeNF(XMLNode& _node);
113 
114  virtual ~KdTreeNF() = default;
115 
119 
120  virtual void Initialize() override;
121 
122  virtual void Print(std::ostream& _os) const override;
123 
127 
128  virtual void FindNeighbors(RoadmapType* const _r, const Cfg& _cfg,
129  const VertexSet& _candidates, OutputIterator _out) override;
130 
131  virtual void FindNeighbors(GroupRoadmapType* const _r,
132  const GroupCfgType& _cfg, const VertexSet& _candidates,
133  OutputIterator _out) override;
134 
136 
137  private:
138 
141 
143  void SetupModels(RoadmapType* const _r);
144 
150  KdTree* GetModel(RoadmapType* const _r, const VertexSet& _candidates);
151 
155 
156  double m_epsilon{0.};
157 
158  std::map<ModelKey, KdTree> m_trees;
159 
160  std::unique_ptr<KdTree> m_tmpTree;
161 
163 
164 };
165 
166 #endif
#define INVALID_VID
Definition: GenericStateGraph.h:23
Definition: CCTracker.h:36
Definition: Cfg.h:38
const std::vector< double > & GetData() const noexcept
Definition: Cfg.cpp:489
size_t DOF() const noexcept
Definition: Cfg.cpp:438
Definition: GenericStateGraph.h:67
STAPLGraph::vertex_descriptor VID
Definition: GenericStateGraph.h:83
STAPLGraph::vertex_iterator VI
Definition: GenericStateGraph.h:89
std::unordered_set< VID > VertexSet
Definition: GenericStateGraph.h:86
Definition: GroupCfg.h:39
Definition: GroupRoadmap.h:25
Definition: KdTreeNF.h:37
RoadmapType::VertexSet VertexSet
Definition: KdTreeNF.h:46
MPBaseObject::GroupCfgType GroupCfgType
Definition: KdTreeNF.h:49
RoadmapType::VI VI
Definition: KdTreeNF.h:44
RoadmapType::CCTrackerType CCTrackerType
Definition: KdTreeNF.h:47
virtual void FindNeighbors(RoadmapType *const _r, const Cfg &_cfg, const VertexSet &_candidates, OutputIterator _out) override
Definition: KdTreeNF.cpp:50
virtual void Initialize() override
Definition: KdTreeNF.cpp:25
RoadmapType::VID VID
Definition: KdTreeNF.h:45
virtual ~KdTreeNF()=default
virtual void Print(std::ostream &_os) const override
Definition: KdTreeNF.cpp:40
MPBaseObject::RoadmapType RoadmapType
Definition: KdTreeNF.h:43
MPBaseObject::GroupRoadmapType GroupRoadmapType
Definition: KdTreeNF.h:48
KdTreeNF()
Definition: KdTreeNF.cpp:8
Definition: NeighborhoodFinderMethod.h:32
Type
The type of neighbors found.
Definition: NeighborhoodFinderMethod.h:50
std::back_insert_iterator< std::vector< Neighbor > > OutputIterator
Output iterator for writing discovered neighbors to a container.
Definition: NeighborhoodFinderMethod.h:59
Definition: XMLNode.h:27