\1\cite \1" \
"cgalPackageSection{2}=\htmlonly[block] \endhtmlonly \section \1 \2 ^^ \htmlonly[block]
\endhtmlonly"
-# This tag can be used to specify a number of word-keyword mappings (TCL only).
-# A mapping has the form "name=value". For example adding "class=itcl::class"
-# will allow you to use the command class in the itcl::class meaning.
-
-TCL_SUBST =
-
# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources
# only. Doxygen will then generate output that is more tailored for C. For
# instance, some of the names that are used will be different. The list of all
@@ -2188,12 +2182,6 @@ EXTERNAL_GROUPS = NO
EXTERNAL_PAGES = NO
-# The PERL_PATH should be the absolute path and name of the perl script
-# interpreter (i.e. the result of 'which perl').
-# The default file (with absolute path) is: /usr/bin/perl.
-
-PERL_PATH = /usr/bin/perl
-
#---------------------------------------------------------------------------
# Configuration options related to the dot tool
#---------------------------------------------------------------------------
@@ -2207,15 +2195,6 @@ PERL_PATH = /usr/bin/perl
CLASS_DIAGRAMS = NO
-# You can define message sequence charts within doxygen comments using the \msc
-# command. Doxygen will then run the mscgen tool (see:
-# http://www.mcternan.me.uk/mscgen/)) to produce the chart and insert it in the
-# documentation. The MSCGEN_PATH tag allows you to specify the directory where
-# the mscgen tool resides. If left empty the tool is assumed to be found in the
-# default search path.
-
-MSCGEN_PATH =
-
# You can include diagrams made with dia in doxygen documentation. Doxygen will
# then run dia to produce the diagram and insert it in the documentation. The
# DIA_PATH tag allows you to specify the directory where the dia binary resides.
diff --git a/Filtered_kernel/include/CGAL/Lazy.h b/Filtered_kernel/include/CGAL/Lazy.h
index 1dc7f2f12a2..067fbe57463 100644
--- a/Filtered_kernel/include/CGAL/Lazy.h
+++ b/Filtered_kernel/include/CGAL/Lazy.h
@@ -116,9 +116,9 @@ templateinline std::enable_if_t::value, unsigned> dept
// For an iterator, exact/approx applies to the objects it points to
template ::value>>
-auto exact(T const& t) {return make_transforming_iterator(t,[](auto const&u){return CGAL::exact(u);});}
+auto exact(T const& t) {return make_transforming_iterator(t,[](auto const&u)->decltype(auto){return CGAL::exact(u);});}
template ::value>>
-auto approx(T const& t) {return make_transforming_iterator(t,[](auto const&u){return CGAL::approx(u);});}
+auto approx(T const& t) {return make_transforming_iterator(t,[](auto const&u)->decltype(auto){return CGAL::approx(u);});}
template ::value>>
unsigned depth(T const&) {return 1;} // FIXME: depth(*t) would be better when t is valid, but not for end iterators, and the true answer would iterate on the range, but we can't do that with only one iterator... We need to replace iterators with ranges to solve that.
diff --git a/Generator/include/CGAL/point_generators_3.h b/Generator/include/CGAL/point_generators_3.h
index dd1e624b65c..1dcbf4ce935 100644
--- a/Generator/include/CGAL/point_generators_3.h
+++ b/Generator/include/CGAL/point_generators_3.h
@@ -539,6 +539,26 @@ public:
const Tr& tr;
};
+
+template
+class Triangle_3_from_soup
+{
+ typedef typename boost::range_value::type Point_3;
+ typedef typename Kernel_traits::Kernel Kernel;
+public:
+ typedef typename Kernel::Triangle_3 result_type;
+
+ Triangle_3_from_soup(const PointRange& pts) : points(pts) { }
+
+ result_type operator()(const Triangle& t) const
+ {
+ return result_type(points[t[0]], points[t[1]], points[t[2]]);
+ }
+
+private:
+ const PointRange& points;
+};
+
}//end namespace internal
template ,
+ class Creator = Creator_uniform_3<
+ typename Kernel_traits< typename PointRange::value_type >::Kernel::RT,
+ typename PointRange::value_type> >
+struct Random_points_in_triangle_soup
+ : public Generic_random_point_generator,
+ Random_points_in_triangle_3,
+ typename PointRange::value_type>
+{
+ typedef Generic_random_point_generator,
+ Random_points_in_triangle_3,
+ typename PointRange::value_type> Base;
+ typedef typename PointRange::value_type Point_3;
+ typedef typename Kernel_traits::Kernel Kernel;
+ typedef Triangle Id;
+ typedef Point_3 result_type;
+ typedef Random_points_in_triangle_soup This;
+
+ template
+ Random_points_in_triangle_soup(const TriangleRange& triangles,
+ const PointRange& points,
+ Random& rnd = get_default_random())
+ : Base(triangles,
+ internal::Triangle_3_from_soup(points),
+ internal::Apply_approx_sqrt::Kernel::Compute_squared_area_3>(),
+ rnd)
+ { }
+
+ This& operator++()
+ {
+ Base::generate_point();
+ return *this;
+ }
+
+ This operator++(int)
+ {
+ This tmp = *this;
+ ++(*this);
+ return tmp;
+ }
+};
+
} //namespace CGAL
#include
diff --git a/Homogeneous_kernel/include/CGAL/Homogeneous/function_objects.h b/Homogeneous_kernel/include/CGAL/Homogeneous/function_objects.h
index 649d18c1751..97e7a68d225 100644
--- a/Homogeneous_kernel/include/CGAL/Homogeneous/function_objects.h
+++ b/Homogeneous_kernel/include/CGAL/Homogeneous/function_objects.h
@@ -761,6 +761,52 @@ namespace HomogeneousKernelFunctors {
}
};
+ template
+ class Compare_signed_distance_to_line_2
+ {
+ typedef typename K::Point_2 Point_2;
+ typedef typename K::Line_2 Line_2;
+ typedef typename K::Less_signed_distance_to_line_2 Less_signed_distance_to_line_2;
+
+ public:
+ typedef Comparison_result result_type;
+
+ result_type
+ operator()(const Point_2& p, const Point_2& q,
+ const Point_2& r, const Point_2& s) const
+ {
+ typedef typename K::RT RT;
+
+ const RT & phx = p.hx();
+ const RT & phy = p.hy();
+ const RT & phw = p.hw();
+ const RT & qhx = q.hx();
+ const RT & qhy = q.hy();
+ const RT & qhw = q.hw();
+ const RT & rhx = r.hx();
+ const RT & rhy = r.hy();
+ const RT & rhw = r.hw();
+ const RT & shx = s.hx();
+ const RT & shy = s.hy();
+ const RT & shw = s.hw();
+
+ RT scaled_dist_r_minus_scaled_dist_s =
+ ( rhx*shw - shx*rhw ) * (phy*qhw - qhy*phw)
+ - ( rhy*shw - shy*rhw ) * (phx*qhw - qhx*phw);
+
+ return compare(scaled_dist_r_minus_scaled_dist_s, 0);
+ }
+
+ result_type
+ operator()(const Line_2& l, const Point_2& p, const Point_2& q) const
+ {
+ Less_signed_distance_to_line_2 less = K().less_signed_distance_to_line_2_object();
+ if (less(l, p, q)) return SMALLER;
+ if (less(l, q, p)) return LARGER;
+ return EQUAL;
+ }
+ };
+
template
class Compare_slope_2
{
@@ -4109,26 +4155,7 @@ namespace HomogeneousKernelFunctors {
operator()(const Point_2& p, const Point_2& q,
const Point_2& r, const Point_2& s) const
{
- typedef typename K::RT RT;
-
- const RT & phx= p.hx();
- const RT & phy= p.hy();
- const RT & phw= p.hw();
- const RT & qhx= q.hx();
- const RT & qhy= q.hy();
- const RT & qhw= q.hw();
- const RT & rhx= r.hx();
- const RT & rhy= r.hy();
- const RT & rhw= r.hw();
- const RT & shx= s.hx();
- const RT & shy= s.hy();
- const RT & shw= s.hw();
-
- RT scaled_dist_r_minus_scaled_dist_s =
- ( rhx*shw - shx*rhw ) * (phy*qhw - qhy*phw)
- - ( rhy*shw - shy*rhw ) * (phx*qhw - qhx*phw);
-
- return scaled_dist_r_minus_scaled_dist_s < 0;
+ return Compare_signed_distance_to_line_2().operator()(p, q, r, s) == SMALLER;
}
result_type
diff --git a/Installation/CHANGES.md b/Installation/CHANGES.md
index fcd93c9ac8d..8b4d67730cf 100644
--- a/Installation/CHANGES.md
+++ b/Installation/CHANGES.md
@@ -2,6 +2,20 @@ Release History
===============
[Release 5.1] (https://github.com/CGAL/cgal/releases/tag/releases%2FCGAL-5.1)
+
+### 2D and 3D Linear Geometry Kernel
+ - Add `CompareSignedDistanceToLine_2` in the 2D/3D Kernel concept to compare
+ the signed distance of two points to a line, or the line passing through two given points.
+ Corresponding functors in the model (`Compare_signed_distance_to_line_2`) are also added.
+
+### 2D Triangulations
+ - Add function `split_subconstraint_graph_into_constraints()` to
+ `Constrained_triangulation_plus_2` to initialize the constraints
+ from a soup of disconnected segments that should first be split
+ into polylines.
+
+
+Release 5.0
-----------
Release date: June 2020
@@ -24,6 +38,8 @@ Release date: June 2020
### CGAL and the Boost Graph Library (BGL)
- Introduced the function `set_triangulation_ids(Triangulation& tr)` which must be used to initialize vertex,
edge, and face indices of a triangulation meant to be used with BGL algorithms.
+ - Added function `alpha_expansion_graphcut()` which regularizes a
+ multi-label partition over a user-defined graph.
### Polygon Mesh Processing
@@ -38,6 +54,10 @@ Release date: June 2020
components that would be removed with the specified threshold, but without actually removing them.
- The function `CGAL::Polygon_mesh_processing::stitch_borders()` now returns the number
of halfedge pairs that were stitched.
+- Introduced the new functions `CGAL::Polygon_mesh_processing::merge_reversible_connected_components()`,
+ `CGAL::Polygon_mesh_processing::duplicate_incompatible_edges_in_polygon_soup()`,
+ and `CGAL::Polygon_mesh_processing::orient_triangle_soup_with_reference_triangle_mesh()` that can be helpful
+ when repairing a polygon soup.
- New function to split meshes along a mesh or a plane:
`CGAL::Polygon_mesh_processing::split()`
- New function to split a single mesh containing several connected components into several meshes containing one connected component:
@@ -47,6 +67,7 @@ Release date: June 2020
- The function `CGAL::Polygon_mesh_processing::polygon_soup_to_polygon_mesh` now allows passing a point map (for the point range)
and a vertex point map (for the polygon mesh) via named parameters.
- Added the function `CGAL::Polygon_mesh_processing::polygon_mesh_to_polygon_soup()`.
+ - Added a new function `CGAL::Polygon_mesh_processing::sample_triangle_soup()` that generates points on a triangle soup surface.
### Point Set Processing
- Added wrapper functions for registration:
@@ -62,6 +83,7 @@ Release date: June 2020
sets using ICP algorithm implemented in the third party library libpointmatcher, and registers
the points sets by transforming the data point set using the computed transformation.
+
### 2D Triangulations
- To fix an inconsistency between code and documentation and to clarify which types of intersections
are truly allowed in constrained Delaunay triangulations, the tag `CGAL::No_intersection_tag`
@@ -74,6 +96,16 @@ Release date: June 2020
does not allow any intersection, except for the configuration of two constraints having a single
common endpoints, for convience.
+### 3D Triangulations
+- The free function `CGAL::file_input()` and the member function `CGAL::Triangulation_3::file_input()`
+ have been added. The first allows to load a `Triangulation_3` from an input stream, using functors to create vertices and cells.
+ The second is simply the member function version of the first one.
+
+### 3D Triangulation Data Structure
+- The free function `CGAL::file_input()` and the member function `CGAL::TDS_3::file_input()`
+ have been added. The first allows to load a `TDS_3` from an input stream, using functors to create vertices and cells.
+ The second is simply the member function version of the first one.
+
### dD Spatial Searching
- Improved the performance of the kd-tree in some cases:
@@ -115,8 +147,7 @@ Release date: June 2020
### STL Extensions for CGAL
- Added a new concurrency tag: `CGAL::Parallel_if_available_tag`. This tag is a convenience typedef to `CGAL::Parallel_tag`
if the third party library TBB has been found and linked with, and to `CGAL::Sequential_tag` otherwise.
-
-
+
### Convex_hull_3
- A new overload for `convex_hull_3()` that takes a model of `VertexListGraph` has been added.
diff --git a/Kernel_23/doc/Kernel_23/CGAL/Vector_3.h b/Kernel_23/doc/Kernel_23/CGAL/Vector_3.h
index cfb6e25544b..036dafdc8f2 100644
--- a/Kernel_23/doc/Kernel_23/CGAL/Vector_3.h
+++ b/Kernel_23/doc/Kernel_23/CGAL/Vector_3.h
@@ -68,12 +68,12 @@ introduces a vector `v` initialized to `(x, y, z)`.
Vector_3(int x, int y, int z);
/*!
-introduces a vector `v` initialized to `(x, y, z).
+introduces a vector `v` initialized to `(x, y, z)`.
*/
Vector_3(double x, double y, double z);
/*!
-introduces a vector `v` initialized to `(hx/hw, hy/hw, hz/hw).
+introduces a vector `v` initialized to `(hx/hw, hy/hw, hz/hw)`.
*/
Vector_3(const Kernel::RT &hx, const Kernel::RT &hy, const Kernel::RT &hz, const Kernel::RT &hw = RT(1));
diff --git a/Kernel_23/doc/Kernel_23/Concepts/FunctionObjectConcepts.h b/Kernel_23/doc/Kernel_23/Concepts/FunctionObjectConcepts.h
index b63475c7188..44e13cfbbe4 100644
--- a/Kernel_23/doc/Kernel_23/Concepts/FunctionObjectConcepts.h
+++ b/Kernel_23/doc/Kernel_23/Concepts/FunctionObjectConcepts.h
@@ -976,6 +976,40 @@ public:
/// @}
}; /* end Kernel::ComparePowerDistance_3 */
+
+
+
+/*!
+ \ingroup PkgKernel23ConceptsFunctionObjects
+ \cgalConcept
+
+ \cgalRefines `AdaptableFunctor` (with four arguments)
+*/
+class CompareSignedDistanceToLine_2 {
+public:
+
+ /// \name Operations
+ /// A model of this concept must provide:
+ /// @{
+
+ /*!
+ compares the signed distance of `r` and `s` to the directed line through `p` and `q`.
+ */
+ Comparison_result operator()(const Kernel::Point_2& p,
+ const Kernel::Point_2& q,
+ const Kernel::Point_2& r,
+ const Kernel::Point_2& s);
+
+ /*!
+ compares the signed distance of `r` and `s` to the directed line `l`.
+ */
+ Comparison_result operator()(const Kernel::Line_2& l,
+ const Kernel::Point_2& r,
+ const Kernel::Point_2& s);
+ /// @}
+}; /* end Kernel::CompareSignedDistanceToLine_2 */
+
+
/*!
\ingroup PkgKernel23ConceptsFunctionObjects
\cgalConcept
@@ -8757,7 +8791,7 @@ public:
\ingroup PkgKernel23ConceptsFunctionObjects
\cgalConcept
- \cgalRefines `AdaptableFunctor`` (with four arguments)
+ \cgalRefines `AdaptableFunctor` (with four arguments)
\sa `has_smaller_signed_distance_to_line_grp`
diff --git a/Kernel_23/doc/Kernel_23/Concepts/Kernel.h b/Kernel_23/doc/Kernel_23/Concepts/Kernel.h
index 83bd6f4c0bd..22efddcdf89 100644
--- a/Kernel_23/doc/Kernel_23/Concepts/Kernel.h
+++ b/Kernel_23/doc/Kernel_23/Concepts/Kernel.h
@@ -647,6 +647,11 @@ public:
*/
typedef unspecified_type Compare_angle_with_x_axis_2;
+ /*!
+ a model of `Kernel::CompareSignedDistanceToLine_2`
+ */
+ typedef unspecified_type Compare_signed_distance_to_line_2;
+
/*!
a model of `Kernel::CompareSlope_2`
*/
diff --git a/Kernel_23/doc/Kernel_23/PackageDescription.txt b/Kernel_23/doc/Kernel_23/PackageDescription.txt
index 982c92fc692..54fa6580087 100644
--- a/Kernel_23/doc/Kernel_23/PackageDescription.txt
+++ b/Kernel_23/doc/Kernel_23/PackageDescription.txt
@@ -281,6 +281,7 @@
- `Kernel::CompareSlope_3`
- `Kernel::ComparePowerDistance_2`
- `Kernel::ComparePowerDistance_3`
+- `Kernel::CompareSignedDistanceToLine_2`
- `Kernel::CompareSquaredDistance_2`
- `Kernel::CompareSquaredDistance_3`
- `Kernel::CompareSquaredRadius_3`
diff --git a/Kernel_23/include/CGAL/Kernel/global_functions_internal_2.h b/Kernel_23/include/CGAL/Kernel/global_functions_internal_2.h
index 6e1289b044e..42c1ac639ca 100644
--- a/Kernel_23/include/CGAL/Kernel/global_functions_internal_2.h
+++ b/Kernel_23/include/CGAL/Kernel/global_functions_internal_2.h
@@ -341,9 +341,7 @@ compare_signed_distance_to_line(const typename K::Point_2& p,
const typename K::Point_2& s,
const K& k)
{
- if (k.less_signed_distance_to_line_2_object()(p, q, r, s)) return SMALLER;
- if (k.less_signed_distance_to_line_2_object()(p, q, s, r)) return LARGER;
- return EQUAL;
+ return k.compare_signed_distance_to_line_2_object()(p, q, r, s);
}
template
@@ -354,9 +352,7 @@ compare_signed_distance_to_line(const typename K::Line_2& l,
const typename K::Point_2& q,
const K& k)
{
- if (k.less_signed_distance_to_line_2_object()(l, p, q)) return SMALLER;
- if (k.less_signed_distance_to_line_2_object()(l, q, p)) return LARGER;
- return EQUAL;
+ return k.compare_signed_distance_to_line_2_object()(l, p, q);
}
template < class K >
diff --git a/Kernel_23/include/CGAL/Kernel/interface_macros.h b/Kernel_23/include/CGAL/Kernel/interface_macros.h
index 9993c699f02..9495ca4e3a4 100644
--- a/Kernel_23/include/CGAL/Kernel/interface_macros.h
+++ b/Kernel_23/include/CGAL/Kernel/interface_macros.h
@@ -116,6 +116,8 @@ CGAL_Kernel_pred_RT(Compare_power_distance_2,
compare_power_distance_2_object)
CGAL_Kernel_pred_RT(Compare_power_distance_3,
compare_power_distance_3_object)
+CGAL_Kernel_pred(Compare_signed_distance_to_line_2,
+ compare_signed_distance_to_line_2_object)
CGAL_Kernel_pred(Compare_slope_2,
compare_slope_2_object)
CGAL_Kernel_pred(Compare_slope_3,
diff --git a/Optimal_transportation_reconstruction_2/demo/Optimal_transportation_reconstruction_2/scene.h b/Optimal_transportation_reconstruction_2/demo/Optimal_transportation_reconstruction_2/scene.h
index 758fc216ef4..6e804dc87a3 100644
--- a/Optimal_transportation_reconstruction_2/demo/Optimal_transportation_reconstruction_2/scene.h
+++ b/Optimal_transportation_reconstruction_2/demo/Optimal_transportation_reconstruction_2/scene.h
@@ -407,7 +407,7 @@ public:
Point_3_from_sample()),
boost::make_transform_iterator (m_samples.end(),
Point_3_from_sample())),
- 3);
+ 3, CGAL::parameters::point_map (CGAL::Identity_property_map_no_lvalue()));
std::cerr << "Average spacing = " << spacing << std::endl;
}
diff --git a/Point_set_processing_3/include/CGAL/Point_set_processing_3/internal/Callback_wrapper.h b/Point_set_processing_3/include/CGAL/Point_set_processing_3/internal/Callback_wrapper.h
new file mode 100644
index 00000000000..c52826db44b
--- /dev/null
+++ b/Point_set_processing_3/include/CGAL/Point_set_processing_3/internal/Callback_wrapper.h
@@ -0,0 +1,184 @@
+// Copyright (c) 2018 GeometryFactory (France).
+// All rights reserved.
+//
+// This file is part of CGAL (www.cgal.org).
+//
+// $URL$
+// $Id$
+// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
+//
+// Author(s) : Simon Giraudot
+
+#ifndef CGAL_PSP_INTERNAL_CALLBACK_WRAPPER_H
+#define CGAL_PSP_INTERNAL_CALLBACK_WRAPPER_H
+
+#include
+
+#include
+
+#include
+
+namespace CGAL {
+namespace Point_set_processing_3 {
+namespace internal {
+
+template
+class Callback_wrapper
+{
+ std::size_t m_advancement;
+ bool m_interrupted;
+
+public:
+ Callback_wrapper (const std::function&, std::size_t, std::size_t, bool = false) { }
+ void reset (std::size_t, std::size_t, bool = false) { }
+ std::size_t& advancement() { return m_advancement; }
+ bool& interrupted() { return m_interrupted; }
+ void join() { }
+};
+
+template <>
+class Callback_wrapper
+{
+ const std::function& m_callback;
+ std::size_t m_advancement;
+ bool m_interrupted;
+ std::size_t m_size;
+
+public:
+
+ Callback_wrapper (const std::function& callback,
+ std::size_t size,
+ std::size_t advancement = 0,
+ bool interrupted = false)
+ : m_callback (callback)
+ , m_advancement (advancement)
+ , m_interrupted (interrupted)
+ , m_size (size)
+ { }
+
+ Callback_wrapper (const Callback_wrapper& other)
+ : m_callback (other.m_callback)
+ , m_advancement (other.m_advancement)
+ , m_interrupted (other.m_interrupted)
+ , m_size (other.m_size)
+ { }
+
+ ~Callback_wrapper () { }
+
+ void reset (std::size_t size, std::size_t advancement, bool interrupted = false)
+ {
+ m_size = size;
+ m_advancement = advancement;
+ m_interrupted = interrupted;
+ }
+ std::size_t& advancement()
+ {
+ return m_advancement;
+ }
+
+ bool& interrupted()
+ {
+ if (m_callback)
+ m_interrupted = !(m_callback(m_advancement / double(m_size)));
+ return m_interrupted;
+ }
+
+ void join() { }
+};
+
+#ifdef CGAL_LINKED_WITH_TBB
+template <>
+class Callback_wrapper
+{
+ const std::function& m_callback;
+ cpp11::atomic* m_advancement;
+ cpp11::atomic* m_interrupted;
+ std::size_t m_size;
+ bool m_creator;
+ cpp11::thread* m_thread;
+
+ // assignment operator shouldn't be used (m_callback is const ref)
+ Callback_wrapper& operator= (const Callback_wrapper&)
+ {
+ return *this;
+ }
+
+public:
+ Callback_wrapper (const std::function& callback,
+ std::size_t size,
+ std::size_t advancement = 0,
+ bool interrupted = false)
+ : m_callback (callback)
+ , m_advancement (new cpp11::atomic())
+ , m_interrupted (new cpp11::atomic())
+ , m_size (size)
+ , m_creator (true)
+ , m_thread (nullptr)
+ {
+ // cpp11::atomic only has default constructor, initialization done in two steps
+ *m_advancement = advancement;
+ *m_interrupted = interrupted;
+ if (m_callback)
+ m_thread = new cpp11::thread (*this);
+ }
+
+ Callback_wrapper (const Callback_wrapper& other)
+ : m_callback (other.m_callback)
+ , m_advancement (other.m_advancement)
+ , m_interrupted (other.m_interrupted)
+ , m_size (other.m_size)
+ , m_creator (false)
+ , m_thread (nullptr)
+ {
+
+ }
+
+ ~Callback_wrapper ()
+ {
+ if (m_creator)
+ {
+ delete m_advancement;
+ delete m_interrupted;
+ }
+ if (m_thread != nullptr)
+ delete m_thread;
+ }
+
+ void reset (std::size_t size, std::size_t advancement, bool interrupted = false)
+ {
+ m_size = size;
+ *m_advancement = advancement;
+ *m_interrupted = interrupted;
+ if (m_callback)
+ m_thread = new cpp11::thread (*this);
+ }
+
+ cpp11::atomic& advancement() { return *m_advancement; }
+ cpp11::atomic& interrupted() { return *m_interrupted; }
+ void join()
+ {
+ if (m_thread != nullptr)
+ m_thread->join();
+ }
+
+ void operator()()
+ {
+ while (*m_advancement != m_size)
+ {
+ if (m_callback && !m_callback (*m_advancement / double(m_size)))
+ *m_interrupted = true;
+ if (*m_interrupted)
+ return;
+ cpp11::sleep_for (0.00001);
+ }
+ if (m_callback)
+ m_callback (1.);
+ }
+};
+#endif
+
+} // namespace internal
+} // namespace Point_set_processing_3
+} // namespace CGAL
+
+#endif // CGAL_PSP_INTERNAL_CALLBACK_WRAPPER_H
diff --git a/Point_set_processing_3/include/CGAL/Point_set_processing_3/internal/Neighbor_query.h b/Point_set_processing_3/include/CGAL/Point_set_processing_3/internal/Neighbor_query.h
new file mode 100644
index 00000000000..5e8996db035
--- /dev/null
+++ b/Point_set_processing_3/include/CGAL/Point_set_processing_3/internal/Neighbor_query.h
@@ -0,0 +1,180 @@
+// Copyright (c) 2019 GeometryFactory Sarl (France).
+// All rights reserved.
+//
+// This file is part of CGAL (www.cgal.org).
+//
+// $URL$
+// $Id$
+// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
+//
+// Author(s) : Simon Giraudot
+
+#ifndef CGAL_PSP_INTERNAL_NEIGHBOR_QUERY_H
+#define CGAL_PSP_INTERNAL_NEIGHBOR_QUERY_H
+
+#include
+
+#include
+#include
+#include
+#include
+
+#include
+
+#include
+
+namespace CGAL {
+namespace Point_set_processing_3 {
+namespace internal {
+
+struct Maximum_points_reached_exception : public std::exception { };
+
+template
+class Neighbor_query
+{
+public:
+
+ typedef Kernel_ Kernel;
+ typedef PointRangeRef Point_range;
+ typedef PointMap Point_map;
+
+ typedef typename Kernel::FT FT;
+ typedef typename Kernel::Point_3 Point_3;
+
+ typedef typename Range_iterator_type::type input_iterator;
+ typedef typename input_iterator::value_type value_type;
+
+ typedef CGAL::Prevent_deref iterator;
+
+ struct Deref_point_map
+ {
+ typedef input_iterator key_type;
+ typedef typename boost::property_traits::reference reference;
+ typedef typename boost::property_traits::value_type value_type;
+ typedef typename boost::property_traits::category category;
+
+ PointMap point_map;
+
+ Deref_point_map () { }
+ Deref_point_map (PointMap point_map) : point_map(point_map) { }
+
+ friend reference get (const Deref_point_map& map, key_type it)
+ {
+ return get(map.point_map, *it);
+ }
+ };
+
+ typedef CGAL::Search_traits_3 Tree_traits_base;
+ typedef CGAL::Search_traits_adapter Tree_traits;
+ typedef CGAL::Sliding_midpoint Splitter;
+ typedef CGAL::Distance_adapter > Distance;
+ typedef CGAL::Kd_tree Tree;
+ typedef CGAL::Fuzzy_sphere Sphere;
+
+ typedef CGAL::Orthogonal_k_neighbor_search Neighbor_search;
+ typedef typename Neighbor_search::iterator Search_iterator;
+
+private:
+
+ PointRangeRef m_points;
+ PointMap m_point_map;
+ Deref_point_map m_deref_map;
+ Tree_traits m_traits;
+ Tree m_tree;
+ Distance m_distance;
+
+ // Forbid copy
+ Neighbor_query (const Neighbor_query&) { }
+
+public:
+
+ Neighbor_query (PointRangeRef points, PointMap point_map)
+ : m_points (points)
+ , m_point_map (point_map)
+ , m_deref_map (point_map)
+ , m_traits (m_deref_map)
+ , m_tree (iterator(m_points.begin()), iterator(m_points.end()), Splitter(), m_traits)
+ , m_distance (m_deref_map)
+ {
+ m_tree.build();
+ }
+
+ PointMap point_map() const { return m_point_map; }
+
+ template
+ void get_iterators (const Point_3& query, unsigned int k, FT neighbor_radius,
+ OutputIterator output) const
+ {
+ if (neighbor_radius != FT(0))
+ {
+ Sphere fs (query, neighbor_radius, 0, m_traits);
+
+ // if k=0, no limit on the number of neighbors returned
+ if (k == 0)
+ k = (std::numeric_limits::max)();
+
+ unsigned int nb = 0;
+
+ try
+ {
+ std::function output_iterator_with_limit
+ = [&](const input_iterator& it)
+ {
+ *(output ++) = it;
+ if (++ nb == k)
+ throw Maximum_points_reached_exception();
+ };
+
+ auto function_output_iterator
+ = boost::make_function_output_iterator (output_iterator_with_limit);
+
+ m_tree.search (function_output_iterator, fs);
+ }
+ catch (const Maximum_points_reached_exception&)
+ { }
+
+ // Fallback, if less than 3 points are return, search for the 3
+ // first points
+ if (nb < 3)
+ k = 3;
+ // Else, no need to search for K nearest neighbors
+ else
+ k = 0;
+ }
+
+ if (k != 0)
+ {
+ // Gather set of (k+1) neighboring points.
+ // Perform k+1 queries (as in point set, the query point is
+ // output first). Search may be aborted if k is greater
+ // than number of input points.
+
+ Neighbor_search search (m_tree, query, k+1, 0, true, m_distance);
+ Search_iterator search_iterator = search.begin();
+ unsigned int i;
+ for (i = 0; i < (k+1); ++ i)
+ {
+ if(search_iterator == search.end())
+ break; // premature ending
+ *(output ++) = search_iterator->first;
+ search_iterator++;
+ }
+ }
+ }
+
+ template
+ void get_points (const Point_3& query, unsigned int k, FT neighbor_radius,
+ OutputIterator output) const
+ {
+ return get_iterators(query, k, neighbor_radius,
+ boost::make_function_output_iterator
+ ([&](const input_iterator& it)
+ {
+ *(output ++) = get (m_point_map, *it);
+ }));
+ }
+};
+
+} } } // namespace CGAL::Point_set_processing_3::internal
+
+#endif // CGAL_PSP_INTERNAL_NEIGHBOR_QUERY_H
diff --git a/Point_set_processing_3/include/CGAL/Point_set_processing_3/internal/Parallel_callback.h b/Point_set_processing_3/include/CGAL/Point_set_processing_3/internal/Parallel_callback.h
deleted file mode 100644
index 87925ce7f87..00000000000
--- a/Point_set_processing_3/include/CGAL/Point_set_processing_3/internal/Parallel_callback.h
+++ /dev/null
@@ -1,108 +0,0 @@
-// Copyright (c) 2018 GeometryFactory (France).
-// All rights reserved.
-//
-// This file is part of CGAL (www.cgal.org).
-//
-// $URL$
-// $Id$
-// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
-//
-// Author(s) : Simon Giraudot
-
-#ifndef CGAL_PSP_INTERNAL_PARALLEL_CALLBACK_H
-#define CGAL_PSP_INTERNAL_PARALLEL_CALLBACK_H
-
-#include
-
-#include
-
-#include
-
-namespace CGAL {
-namespace Point_set_processing_3 {
-namespace internal {
-
-class Parallel_callback
-{
- const std::function& m_callback;
- cpp11::atomic* m_advancement;
- cpp11::atomic* m_interrupted;
- std::size_t m_size;
- bool m_creator;
- cpp11::thread* m_thread;
-
- // assignment operator shouldn't be used (m_callback is const ref)
- Parallel_callback& operator= (const Parallel_callback&)
- {
- return *this;
- }
-
-public:
- Parallel_callback (const std::function& callback,
- std::size_t size,
- std::size_t advancement = 0,
- bool interrupted = false)
- : m_callback (callback)
- , m_advancement (new cpp11::atomic())
- , m_interrupted (new cpp11::atomic())
- , m_size (size)
- , m_creator (true)
- , m_thread (nullptr)
- {
- // cpp11::atomic only has default constructor, initialization done in two steps
- *m_advancement = advancement;
- *m_interrupted = interrupted;
- if (m_callback)
- m_thread = new cpp11::thread (*this);
- }
-
- Parallel_callback (const Parallel_callback& other)
- : m_callback (other.m_callback)
- , m_advancement (other.m_advancement)
- , m_interrupted (other.m_interrupted)
- , m_size (other.m_size)
- , m_creator (false)
- , m_thread (nullptr)
- {
-
- }
-
-
- ~Parallel_callback ()
- {
- if (m_creator)
- {
- delete m_advancement;
- delete m_interrupted;
- }
- if (m_thread != nullptr)
- delete m_thread;
- }
-
- cpp11::atomic& advancement() { return *m_advancement; }
- cpp11::atomic& interrupted() { return *m_interrupted; }
- void join()
- {
- if (m_thread != nullptr)
- m_thread->join();
- }
-
- void operator()()
- {
- while (*m_advancement != m_size)
- {
- if (!m_callback (*m_advancement / double(m_size)))
- *m_interrupted = true;
- if (*m_interrupted)
- return;
- cpp11::sleep_for (0.00001);
- }
- m_callback (1.);
- }
-};
-
-} // namespace internal
-} // namespace Point_set_processing_3
-} // namespace CGAL
-
-#endif // CGAL_PSP_INTERNAL_PARALLEL_CALLBACK_H
diff --git a/Point_set_processing_3/include/CGAL/Point_set_processing_3/internal/neighbor_query.h b/Point_set_processing_3/include/CGAL/Point_set_processing_3/internal/neighbor_query.h
deleted file mode 100644
index 1905a0dcd3d..00000000000
--- a/Point_set_processing_3/include/CGAL/Point_set_processing_3/internal/neighbor_query.h
+++ /dev/null
@@ -1,104 +0,0 @@
-// Copyright (c) 2019 GeometryFactory Sarl (France).
-// All rights reserved.
-//
-// This file is part of CGAL (www.cgal.org).
-//
-// $URL$
-// $Id$
-// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
-//
-// Author(s) : Simon Giraudot
-
-#ifndef CGAL_PSP_INTERNAL_NEIGHBOR_QUERY_H
-#define CGAL_PSP_INTERNAL_NEIGHBOR_QUERY_H
-
-#include
-
-#include
-#include
-#include
-#include
-
-#include
-
-namespace CGAL {
-namespace Point_set_processing_3 {
-namespace internal {
-
-struct Maximum_points_reached_exception : public std::exception { };
-
-template
-void neighbor_query (const Point& query,
- const CGAL::Kd_tree& tree,
- unsigned int k,
- FT neighbor_radius,
- PointContainer& points)
-{
- typedef typename CGAL::Orthogonal_k_neighbor_search Neighbor_search;
- typedef typename Neighbor_search::iterator Search_iterator;
- typedef CGAL::Fuzzy_sphere Sphere;
-
- if (neighbor_radius != FT(0))
- {
- Sphere fs (query, neighbor_radius, 0, tree.traits());
-
- // if k=0, no limit on the number of neighbors returned
- if (k == 0)
- k = (std::numeric_limits::max)();
-
- try
- {
- std::function back_insert_with_limit
- = [&](const Point& point) -> void
- {
- points.push_back (point);
- if (points.size() == k)
- throw Maximum_points_reached_exception();
- };
-
- auto function_output_iterator
- = boost::make_function_output_iterator (back_insert_with_limit);
-
- tree.search (function_output_iterator, fs);
- }
- catch (const Maximum_points_reached_exception&)
- { }
-
- // Fallback, if less than 3 points are return, search for the 3
- // first points
- if (points.size() < 3)
- k = 3;
- // Else, no need to search for K nearest neighbors
- else
- k = 0;
- }
-
- if (k != 0)
- {
- // Gather set of (k+1) neighboring points.
- // Perform k+1 queries (as in point set, the query point is
- // output first). Search may be aborted if k is greater
- // than number of input points.
- points.reserve(k+1);
- Neighbor_search search(tree,query,k+1);
- Search_iterator search_iterator = search.begin();
- unsigned int i;
- for(i=0;i<(k+1);i++)
- {
- if(search_iterator == search.end())
- break; // premature ending
- points.push_back(search_iterator->first);
- search_iterator++;
- }
- CGAL_point_set_processing_precondition(points.size() >= 1);
- }
-}
-
-} } } // namespace CGAL::Point_set_processing_3::internal
-
-#endif // CGAL_PSP_INTERNAL_NEIGHBOR_QUERY_H
diff --git a/Point_set_processing_3/include/CGAL/bilateral_smooth_point_set.h b/Point_set_processing_3/include/CGAL/bilateral_smooth_point_set.h
index 35fce6f1992..cd208ce0b41 100644
--- a/Point_set_processing_3/include/CGAL/bilateral_smooth_point_set.h
+++ b/Point_set_processing_3/include/CGAL/bilateral_smooth_point_set.h
@@ -17,18 +17,19 @@
#include
#include
-#include
-#include
-#include
+#include
+#include
+#include
#include
#include
-#include
#include
#include
#include
#include
+#include
+
#include
#include
#include
@@ -38,23 +39,6 @@
#include
#include
-#ifdef CGAL_LINKED_WITH_TBB
-
-#include
-#include
-#include
-#include
-#include
-#endif // CGAL_LINKED_WITH_TBB
-
-// Default allocator: use TBB allocators if available
-#ifdef CGAL_LINKED_WITH_TBB
-# define CGAL_PSP3_DEFAULT_ALLOCATOR tbb::scalable_allocator
-#else // CGAL_LINKED_WITH_TBB
-# define CGAL_PSP3_DEFAULT_ALLOCATOR std::allocator
-#endif // CGAL_LINKED_WITH_TBB
-
-
//#define CGAL_PSP3_VERBOSE
namespace CGAL {
@@ -66,47 +50,6 @@ namespace CGAL {
namespace bilateral_smooth_point_set_internal{
-// Item in the Kd-tree: position (Point_3) + index
-template
-class Kd_tree_element : public Point_with_normal_3
-{
-public:
- unsigned int index;
-
- // basic geometric types
- typedef typename CGAL::Origin Origin;
- typedef CGAL::Point_with_normal_3 Base;
-
- Kd_tree_element(const Origin& o = ORIGIN, unsigned int id=0)
- : Base(o), index(id)
- {}
- Kd_tree_element(const Base& p, unsigned int id=0)
- : Base(p), index(id)
- {}
- Kd_tree_element(const Kd_tree_element& other)
- : Base(other), index(other.index)
- {}
-
- Kd_tree_element& operator=(const Kd_tree_element&)=default;
-};
-
-
-// Helper class for the Kd-tree
-template
-class Kd_tree_gt : public Kernel
-{
-public:
- typedef Kd_tree_element Point_3;
-};
-
-template