11 #if defined(__clang__) 12 # pragma clang diagnostic push 13 # pragma clang diagnostic ignored "-Wshadow" 15 #include <boost/geometry.hpp> 16 #include <boost/geometry/geometries/point.hpp> 17 #include <boost/geometry/index/rtree.hpp> 18 #if defined(__clang__) 19 # pragma clang diagnostic pop 29 template <
typename T,
size_t Dimension = 3>
33 typedef boost::geometry::model::point<float, Dimension, boost::geometry::cs::cartesian>
BPoint;
37 _rtree.insert(std::make_pair(point, element));
45 _rtree.insert(elements.begin(), elements.end());
53 template <
typename Filter>
55 size_t number_neighbours = 1)
const {
56 std::vector<TreeElement> query_result;
57 auto nearest = boost::geometry::index::nearest(point, static_cast<unsigned int>(number_neighbours));
58 auto satisfies = boost::geometry::index::satisfies(filter);
61 _rtree.query(
operator&&(nearest, satisfies), std::back_inserter(query_result));
66 std::vector<TreeElement> query_result;
67 _rtree.query(boost::geometry::index::nearest(point, static_cast<unsigned int>(number_neighbours)),
68 std::back_inserter(query_result));
78 boost::geometry::index::rtree<TreeElement, boost::geometry::index::linear<16>>
_rtree;
85 template <
typename T,
size_t Dimension = 3>
89 typedef boost::geometry::model::point<float, Dimension, boost::geometry::cs::cartesian>
BPoint;
90 typedef boost::geometry::model::segment<BPoint>
BSegment;
93 void InsertElement(
const BSegment &segment,
const T &element_start,
const T &element_end) {
94 _rtree.insert(std::make_pair(segment, std::make_pair(element_start, element_end)));
102 _rtree.insert(elements.begin(), elements.end());
110 template <
typename Geometry,
typename Filter>
112 const Geometry &geometry,
114 size_t number_neighbours = 1)
const {
115 std::vector<TreeElement> query_result;
117 boost::geometry::index::nearest(geometry, static_cast<unsigned int>(number_neighbours)) &&
118 boost::geometry::index::satisfies(filter),
119 std::back_inserter(query_result));
123 template<
typename Geometry>
125 std::vector<TreeElement> query_result;
127 boost::geometry::index::nearest(geometry, static_cast<unsigned int>(number_neighbours)),
128 std::back_inserter(query_result));
134 template<
typename Geometry>
136 std::vector<TreeElement> query_result;
138 boost::geometry::index::intersects(geometry),
139 std::back_inserter(query_result));
149 boost::geometry::index::rtree<TreeElement, boost::geometry::index::linear<16>>
_rtree;
std::vector< TreeElement > GetNearestNeighbours(const BPoint &point, size_t number_neighbours=1) const
boost::geometry::index::rtree< TreeElement, boost::geometry::index::linear< 16 > > _rtree
std::vector< TreeElement > GetNearestNeighbours(const Geometry &geometry, size_t number_neighbours=1) const
std::pair< BPoint, T > TreeElement
size_t GetTreeSize() const
void InsertElements(const std::vector< TreeElement > &elements)
std::vector< TreeElement > GetIntersections(const Geometry &geometry) const
Returns segments that intersec the specified geometry Warning: intersection between 3D segments is no...
boost::geometry::model::point< float, Dimension, boost::geometry::cs::cartesian > BPoint
This file contains definitions of common data structures used in traffic manager. ...
void InsertElement(const BPoint &point, const T &element)
void InsertElement(const TreeElement &element)
std::vector< TreeElement > GetNearestNeighboursWithFilter(const BPoint &point, Filter filter, size_t number_neighbours=1) const
Return nearest neighbors with a user defined filter.
Rtree class working with 3D segment clouds.
boost::geometry::model::point< float, Dimension, boost::geometry::cs::cartesian > BPoint
void InsertElements(const std::vector< TreeElement > &elements)
boost::geometry::index::rtree< TreeElement, boost::geometry::index::linear< 16 > > _rtree
void InsertElement(const TreeElement &element)
void InsertElement(const BSegment &segment, const T &element_start, const T &element_end)
boost::geometry::model::segment< BPoint > BSegment
Rtree class working with 3D point clouds.
size_t GetTreeSize() const
std::vector< TreeElement > GetNearestNeighboursWithFilter(const Geometry &geometry, Filter filter, size_t number_neighbours=1) const
Return nearest neighbors with a user defined filter.
std::pair< BSegment, std::pair< T, T > > TreeElement