From 30efe05d095051e14cbaf26d12fc2a67134e5a60 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Thu, 15 Oct 2020 16:43:54 +0200 Subject: Use unique_ptr for triangulation_ --- src/Alpha_complex/include/gudhi/Alpha_complex.h | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/Alpha_complex/include/gudhi/Alpha_complex.h b/src/Alpha_complex/include/gudhi/Alpha_complex.h index 1963f02b..4f7a7bd2 100644 --- a/src/Alpha_complex/include/gudhi/Alpha_complex.h +++ b/src/Alpha_complex/include/gudhi/Alpha_complex.h @@ -19,6 +19,7 @@ #include #include // isnan, fmax +#include // for std::unique_ptr #include #include // aka. Weighted Delaunay triangulation @@ -141,7 +142,7 @@ class Alpha_complex { * Vertex handles are inserted sequentially, starting at 0.*/ Vector_vertex_iterator vertex_handle_to_iterator_; /** \brief Pointer on the CGAL Delaunay triangulation.*/ - Triangulation* triangulation_; + std::unique_ptr triangulation_; /** \brief Kernel for triangulation_ functions access.*/ A_kernel_d kernel_; @@ -158,8 +159,7 @@ class Alpha_complex { * * @param[in] off_file_name OFF file [path and] name. */ - Alpha_complex(const std::string& off_file_name) - : triangulation_(nullptr) { + Alpha_complex(const std::string& off_file_name) { Gudhi::Points_off_reader off_reader(off_file_name); if (!off_reader.is_valid()) { std::cerr << "Alpha_complex - Unable to read file " << off_file_name << "\n"; @@ -180,8 +180,7 @@ class Alpha_complex { * Kernel::Point_d or Kernel::Weighted_point_d. */ template - Alpha_complex(const InputPointRange& points) - : triangulation_(nullptr) { + Alpha_complex(const InputPointRange& points) { init_from_range(points); } @@ -208,12 +207,6 @@ class Alpha_complex { init_from_range(weighted_points); } - /** \brief Alpha_complex destructor deletes the Delaunay triangulation. - */ - ~Alpha_complex() { - delete triangulation_; - } - // Forbid copy/move constructor/assignment operator Alpha_complex(const Alpha_complex& other) = delete; Alpha_complex& operator= (const Alpha_complex& other) = delete; @@ -249,7 +242,7 @@ class Alpha_complex { if (first != last) { // Delaunay triangulation init with point dimension. - triangulation_ = new Triangulation(kernel_.get_dimension(*first)); + triangulation_ = std::make_unique(kernel_.get_dimension(*first)); std::vector point_cloud(first, last); -- cgit v1.2.3