mirror of https://github.com/CGAL/cgal
Use stack variable instead of pointer
This commit is contained in:
parent
95c1af0224
commit
49465bbcb6
|
|
@ -633,9 +633,9 @@ public:
|
|||
typename AABB_tree<Tr>::Self& AABB_tree<Tr>::operator=(Self&& tree) noexcept
|
||||
{
|
||||
m_traits = std::move(tree.traits);
|
||||
m_primitives = std::exchange(tree.m_primitives, {});
|
||||
m_p_nodes = std::exchange(tree.m_p_nodes, {});
|
||||
m_p_search_tree = std::exchange(tree.m_p_search_tree, nullptr);
|
||||
m_primitives = std::move(tree.m_primitives);
|
||||
m_p_nodes = std::move(tree.m_p_nodes);
|
||||
m_p_search_tree = std::move(tree.m_p_search_tree);
|
||||
m_search_tree_constructed = std::exchange(tree.m_search_tree_constructed, false);
|
||||
m_default_search_tree_constructed = std::exchange(tree.m_default_search_tree_constructed, true);
|
||||
m_need_build = std::exchange(tree.m_need_build, false);
|
||||
|
|
|
|||
|
|
@ -13,8 +13,6 @@
|
|||
#ifndef CGAL_AABB_SEARCH_TREE_H
|
||||
#define CGAL_AABB_SEARCH_TREE_H
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <CGAL/license/AABB_tree.h>
|
||||
|
||||
|
||||
|
|
@ -85,7 +83,7 @@ namespace CGAL
|
|||
typedef typename CGAL::Orthogonal_k_neighbor_search<TreeTraits> Neighbor_search;
|
||||
typedef typename Neighbor_search::Tree Tree;
|
||||
private:
|
||||
std::unique_ptr<Tree> m_p_tree;
|
||||
Tree m_tree;
|
||||
|
||||
|
||||
Point_and_primitive_id get_p_and_p(const Point_and_primitive_id& p)
|
||||
|
|
@ -100,22 +98,22 @@ namespace CGAL
|
|||
public:
|
||||
template <class ConstPointIterator>
|
||||
AABB_search_tree(ConstPointIterator begin, ConstPointIterator beyond)
|
||||
: m_p_tree(nullptr)
|
||||
: m_tree{}
|
||||
{
|
||||
typedef typename Add_decorated_point<Traits, typename Traits::Primitive::Id>::Point_3 Decorated_point;
|
||||
typedef typename Add_decorated_point<Traits,typename Traits::Primitive::Id>::Point_3 Decorated_point;
|
||||
std::vector<Decorated_point> points;
|
||||
while(begin != beyond) {
|
||||
Point_and_primitive_id pp = get_p_and_p(*begin);
|
||||
points.emplace_back(pp.first,pp.second);
|
||||
points.emplace_back(pp.first, pp.second);
|
||||
++begin;
|
||||
}
|
||||
m_p_tree = std::make_unique<Tree>(points.begin(), points.end());
|
||||
m_p_tree->build();
|
||||
m_tree.insert(points.begin(), points.end());
|
||||
m_tree.build();
|
||||
}
|
||||
|
||||
Point_and_primitive_id closest_point(const Point& query) const
|
||||
{
|
||||
Neighbor_search search(*m_p_tree, query, 1);
|
||||
Neighbor_search search(m_tree, query, 1);
|
||||
return Point_and_primitive_id(static_cast<Point>(search.begin()->first), search.begin()->first.id());
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue