Include parallel KD tree build in classification

This commit is contained in:
Simon Giraudot 2020-03-05 14:35:24 +01:00
parent e716d902cf
commit fe90d1ca1f
2 changed files with 49 additions and 5 deletions

View File

@ -161,9 +161,9 @@ private:
CGAL::Real_timer t;
t.start();
if (lower_grid == nullptr)
neighborhood = new Neighborhood (input, point_map);
neighborhood = new Neighborhood (input, point_map, ConcurrencyTag());
else
neighborhood = new Neighborhood (input, point_map, voxel_size);
neighborhood = new Neighborhood (input, point_map, voxel_size, ConcurrencyTag());
t.stop();
if (lower_grid == nullptr)

View File

@ -173,12 +173,32 @@ public:
/*!
\brief Constructs a neighborhood object based on the input range.
\tparam ConcurrencyTag enables sequential versus parallel
algorithm. Possible values are `Sequential_tag`, `Parallel_tag`,
and `Parallel_if_available_tag`. If no tag is provided,
`Parallel_if_available_tag` is used.
\param input point range.
\param point_map property map to access the input points.
*/
template <typename ConcurrencyTag>
Point_set_neighborhood (const PointRange& input,
PointMap point_map)
PointMap point_map,
const ConcurrencyTag&)
: m_tree (nullptr)
{
init<ConcurrencyTag> (input, point_map);
}
/// \cond SKIP_IN_MANUAL
Point_set_neighborhood (const PointRange& input, PointMap point_map)
: m_tree (nullptr)
{
init<Parallel_if_available_tag> (input, point_map);
}
template <typename ConcurrencyTag>
void init (const PointRange& input, PointMap point_map)
{
My_point_property_map pmap (&input, point_map);
m_tree = new Tree (boost::counting_iterator<boost::uint32_t> (0),
@ -186,8 +206,9 @@ public:
Splitter(),
Search_traits (pmap));
m_distance = Distance (pmap);
m_tree->build();
m_tree->template build<ConcurrencyTag>();
}
/// \endcond
/*!
\brief Constructs a simplified neighborhood object based on the input range.
@ -197,14 +218,36 @@ public:
present in one cell, only the point closest to the centroid of
this subset is used.
\tparam ConcurrencyTag enables sequential versus parallel
algorithm. Possible values are `Sequential_tag`, `Parallel_tag`,
and `Parallel_if_available_tag`. If no tag is provided,
`Parallel_if_available_tag` is used.
\param input input range.
\param point_map property map to access the input points.
\param voxel_size size of the cells of the 3D grid used for simplification.
*/
template <typename ConcurrencyTag>
Point_set_neighborhood (const PointRange& input,
PointMap point_map,
float voxel_size,
const ConcurrencyTag&)
: m_tree (nullptr)
{
init<ConcurrencyTag> (input, point_map, voxel_size);
}
/// \cond SKIP_IN_MANUAL
Point_set_neighborhood (const PointRange& input,
PointMap point_map,
float voxel_size)
: m_tree (nullptr)
{
init<Parallel_if_available_tag> (input, point_map, voxel_size);
}
template <typename ConcurrencyTag>
void init (const PointRange& input, PointMap point_map, float voxel_size)
{
// First, simplify
std::vector<boost::uint32_t> indices;
@ -215,8 +258,9 @@ public:
Splitter(),
Search_traits (pmap));
m_distance = Distance (pmap);
m_tree->build();
m_tree->template build<ConcurrencyTag>();
}
/// \endcond
/// @}