diff options
author | ROUVREAU Vincent <vincent.rouvreau@inria.fr> | 2020-05-21 11:08:25 +0200 |
---|---|---|
committer | ROUVREAU Vincent <vincent.rouvreau@inria.fr> | 2020-05-21 11:08:25 +0200 |
commit | c7b82f49f01075519189f1fdb56cc485e4ad9f46 (patch) | |
tree | 3ab3cd7e9fcaa32788865fa75a852f88c2d4a63c /src/python | |
parent | 57eb31fdb537406925661dad84ef6d4b2e02b67b (diff) |
Use unique_pointer and template alpha complex interface for python interface
Diffstat (limited to 'src/python')
-rw-r--r-- | src/python/gudhi/alpha_complex.pyx | 2 | ||||
-rw-r--r-- | src/python/include/Alpha_complex_interface.h | 18 |
2 files changed, 10 insertions, 10 deletions
diff --git a/src/python/gudhi/alpha_complex.pyx b/src/python/gudhi/alpha_complex.pyx index d75e374a..2b7ce00d 100644 --- a/src/python/gudhi/alpha_complex.pyx +++ b/src/python/gudhi/alpha_complex.pyx @@ -26,7 +26,7 @@ __copyright__ = "Copyright (C) 2016 Inria" __license__ = "GPL v3" cdef extern from "Alpha_complex_interface.h" namespace "Gudhi": - cdef cppclass Alpha_complex_interface "Gudhi::alpha_complex::Alpha_complex_interface": + cdef cppclass Alpha_complex_interface "Gudhi::alpha_complex::Alpha_complex_interface<Gudhi::alpha_complex::Exact_kernel>": Alpha_complex_interface(vector[vector[double]] points) nogil except + # bool from_file is a workaround for cython to find the correct signature Alpha_complex_interface(string off_file, bool from_file) nogil except + diff --git a/src/python/include/Alpha_complex_interface.h b/src/python/include/Alpha_complex_interface.h index 40de88f3..5fb694cd 100644 --- a/src/python/include/Alpha_complex_interface.h +++ b/src/python/include/Alpha_complex_interface.h @@ -23,29 +23,29 @@ #include <iostream> #include <vector> #include <string> +#include <memory> // for std::unique_ptr namespace Gudhi { namespace alpha_complex { +using Exact_kernel = CGAL::Epeck_d< CGAL::Dynamic_dimension_tag >; +using Inexact_kernel = CGAL::Epick_d< CGAL::Dynamic_dimension_tag >; + +template <class Kernel> class Alpha_complex_interface { - using Dynamic_kernel = CGAL::Epeck_d< CGAL::Dynamic_dimension_tag >; - using Point_d = Dynamic_kernel::Point_d; + using Point_d = typename Kernel::Point_d; public: Alpha_complex_interface(const std::vector<std::vector<double>>& points) { auto mkpt = [](std::vector<double> const& vec){ return Point_d(vec.size(), vec.begin(), vec.end()); }; - alpha_complex_ = new Alpha_complex<Dynamic_kernel>(boost::adaptors::transform(points, mkpt)); + alpha_complex_ = std::make_unique<Alpha_complex<Kernel>>(boost::adaptors::transform(points, mkpt)); } Alpha_complex_interface(const std::string& off_file_name, bool from_file = true) { - alpha_complex_ = new Alpha_complex<Dynamic_kernel>(off_file_name); - } - - ~Alpha_complex_interface() { - delete alpha_complex_; + alpha_complex_ = std::make_unique<Alpha_complex<Kernel>>(off_file_name); } std::vector<double> get_point(int vh) { @@ -61,7 +61,7 @@ class Alpha_complex_interface { } private: - Alpha_complex<Dynamic_kernel>* alpha_complex_; + std::unique_ptr<Alpha_complex<Kernel>> alpha_complex_; }; } // namespace alpha_complex |