From 68753b3c28321e28eedd5829c94234da84e25c8d Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Mon, 9 Sep 2019 16:03:40 +0200 Subject: Code review: rename cython as python (make target and directory --- src/python/include/Tangential_complex_interface.h | 111 ++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 src/python/include/Tangential_complex_interface.h (limited to 'src/python/include/Tangential_complex_interface.h') diff --git a/src/python/include/Tangential_complex_interface.h b/src/python/include/Tangential_complex_interface.h new file mode 100644 index 00000000..7c3f2789 --- /dev/null +++ b/src/python/include/Tangential_complex_interface.h @@ -0,0 +1,111 @@ +/* This file is part of the Gudhi Library. The Gudhi library + * (Geometric Understanding in Higher Dimensions) is a generic C++ + * library for computational topology. + * + * Author(s): Vincent Rouvreau + * + * Copyright (C) 2016 Inria + * + * Modification(s): + * - YYYY/MM Author: Description of the modification + */ + +#ifndef INCLUDE_TANGENTIAL_COMPLEX_INTERFACE_H_ +#define INCLUDE_TANGENTIAL_COMPLEX_INTERFACE_H_ + +#include +#include +#include +#include + +#include "Simplex_tree_interface.h" + +#include +#include // std::pair +#include +#include + +namespace Gudhi { + +namespace tangential_complex { + +class Tangential_complex_interface { + using Dynamic_kernel = CGAL::Epick_d< CGAL::Dynamic_dimension_tag >; + using Point_d = Dynamic_kernel::Point_d; + using TC = Tangential_complex; + + public: + Tangential_complex_interface(int intrisic_dim, const std::vector>& points) { + Dynamic_kernel k; + + tangential_complex_ = new TC(points, intrisic_dim, k); + } + + Tangential_complex_interface(int intrisic_dim, const std::string& off_file_name, bool from_file = true) { + Dynamic_kernel k; + + Gudhi::Points_off_reader off_reader(off_file_name); + std::vector points = off_reader.get_point_cloud(); + + tangential_complex_ = new TC(points, intrisic_dim, k); + } + + ~Tangential_complex_interface() { + delete tangential_complex_; + } + + void compute_tangential_complex() { + tangential_complex_->compute_tangential_complex(); + num_inconsistencies_ = tangential_complex_->number_of_inconsistent_simplices(); + } + + std::vector get_point(unsigned vh) { + std::vector vd; + if (vh < tangential_complex_->number_of_vertices()) { + Point_d ph = tangential_complex_->get_point(vh); + for (auto coord = ph.cartesian_begin(); coord < ph.cartesian_end(); coord++) + vd.push_back(*coord); + } + return vd; + } + + unsigned number_of_vertices() { + return tangential_complex_->number_of_vertices(); + } + + unsigned number_of_simplices() { + return num_inconsistencies_.num_simplices; + } + + unsigned number_of_inconsistent_simplices() { + return num_inconsistencies_.num_inconsistent_simplices; + } + + unsigned number_of_inconsistent_stars() { + return num_inconsistencies_.num_inconsistent_stars; + } + + void fix_inconsistencies_using_perturbation(double max_perturb, double time_limit) { + tangential_complex_->fix_inconsistencies_using_perturbation(max_perturb, time_limit); + num_inconsistencies_ = tangential_complex_->number_of_inconsistent_simplices(); + } + + void create_simplex_tree(Simplex_tree<>* simplex_tree) { + tangential_complex_->create_complex>(*simplex_tree); + simplex_tree->initialize_filtration(); + } + + void set_max_squared_edge_length(double max_squared_edge_length) { + tangential_complex_->set_max_squared_edge_length(max_squared_edge_length); + } + +private: + TC* tangential_complex_; + TC::Num_inconsistencies num_inconsistencies_; +}; + +} // namespace tangential_complex + +} // namespace Gudhi + +#endif // INCLUDE_TANGENTIAL_COMPLEX_INTERFACE_H_ -- cgit v1.2.3