summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorROUVREAU Vincent <vincent.rouvreau@inria.fr>2020-10-15 16:43:54 +0200
committerROUVREAU Vincent <vincent.rouvreau@inria.fr>2020-10-15 16:43:54 +0200
commit30efe05d095051e14cbaf26d12fc2a67134e5a60 (patch)
tree79efcc193d8410e0d4e5c3fdb9da9983f46e351a
parent51f4de9a42cbdf7686a0f36106b31c0d3296ccfa (diff)
Use unique_ptr for triangulation_
-rw-r--r--src/Alpha_complex/include/gudhi/Alpha_complex.h17
1 files 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 <stdlib.h>
#include <math.h> // isnan, fmax
+#include <memory> // for std::unique_ptr
#include <CGAL/Delaunay_triangulation.h>
#include <CGAL/Regular_triangulation.h> // 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> 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<Point_d> 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<typename InputPointRange >
- 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<Triangulation>(kernel_.get_dimension(*first));
std::vector<Point_d> point_cloud(first, last);