From 702d71119d8aaf3e36d3a91c7387ad5a3288a400 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Tue, 17 May 2016 08:43:47 +0000 Subject: Alpha complex get_point method and its example git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/ST_cythonize@1178 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 18a93331935ddf35fd15cddc0659c51e494537a4 --- src/cython/example/Alpha_complex_example.py | 2 ++ src/cython/src/cpp/Alpha_complex_interface.h | 11 +++++++---- src/cython/src/cython/Alpha_complex.pyx | 4 ++++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/cython/example/Alpha_complex_example.py b/src/cython/example/Alpha_complex_example.py index 5403fc17..da55bfd4 100755 --- a/src/cython/example/Alpha_complex_example.py +++ b/src/cython/example/Alpha_complex_example.py @@ -36,5 +36,7 @@ print("filtered_tree=", alpha_complex.get_filtered_tree()) print("star([0])=", alpha_complex.get_star_tree([0])) print("coface([0],1)=", alpha_complex.get_coface_tree([0], 1)) +print("point[0]=", alpha_complex.get_point(0)) +print("point[5]=", alpha_complex.get_point(5)) print("#######################################################################") diff --git a/src/cython/src/cpp/Alpha_complex_interface.h b/src/cython/src/cpp/Alpha_complex_interface.h index 2e5b56bb..3378ee6e 100644 --- a/src/cython/src/cpp/Alpha_complex_interface.h +++ b/src/cython/src/cpp/Alpha_complex_interface.h @@ -115,14 +115,17 @@ class Alpha_complex_interface : public Alpha_complex< CGAL::Epick_d< CGAL::Dynam return coface_tree; } - /*std::vector get_point__(int vh) { + std::vector get_point(int vh) { std::vector vd; - Simplex_handle sh = Alpha_complex::find(vh); - if (sh != Alpha_complex::null_simplex()) { + try { Point_d ph = Alpha_complex::get_point(vh); + for (auto coord = ph.cartesian_begin(); coord < ph.cartesian_end(); coord++) + vd.push_back(*coord); + } catch (std::out_of_range outofrange) { + // std::out_of_range is thrown in case not found. Other exceptions must be re-thrown } return vd; - }*/ + } }; diff --git a/src/cython/src/cython/Alpha_complex.pyx b/src/cython/src/cython/Alpha_complex.pyx index dbf55c69..93b7054f 100644 --- a/src/cython/src/cython/Alpha_complex.pyx +++ b/src/cython/src/cython/Alpha_complex.pyx @@ -45,6 +45,7 @@ cdef extern from "Alpha_complex_interface.h" namespace "Gudhi": vector[pair[vector[int], double]] get_star_tree(vector[int] simplex) vector[pair[vector[int], double]] get_coface_tree(vector[int] simplex, int dimension) void remove_maximal_simplex(vector[int] simplex) + vector[double] get_point(int vertex) # AlphaComplex python interface cdef class AlphaComplex: @@ -125,3 +126,6 @@ cdef class AlphaComplex: return ct def remove_maximal_simplex(self, simplex): self.thisptr.remove_maximal_simplex(simplex) + def get_point(self, vertex): + cdef vector[double] point = self.thisptr.get_point(vertex) + return point -- cgit v1.2.3