From c524232f734de875d69e2f190f01a6c976024368 Mon Sep 17 00:00:00 2001 From: Gard Spreemann Date: Thu, 14 Jun 2018 20:39:01 +0200 Subject: GUDHI 2.2.0 as released by upstream in a tarball. --- include/gudhi/Cech_complex_blocker.h | 91 ++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 include/gudhi/Cech_complex_blocker.h (limited to 'include/gudhi/Cech_complex_blocker.h') diff --git a/include/gudhi/Cech_complex_blocker.h b/include/gudhi/Cech_complex_blocker.h new file mode 100644 index 00000000..b0d347b1 --- /dev/null +++ b/include/gudhi/Cech_complex_blocker.h @@ -0,0 +1,91 @@ +/* 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) 2018 Inria + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef CECH_COMPLEX_BLOCKER_H_ +#define CECH_COMPLEX_BLOCKER_H_ + +#include // for Gudhi::Minimal_enclosing_ball_radius + +#include +#include +#include // for std::sqrt + +namespace Gudhi { + +namespace cech_complex { + +/** \internal + * \class Cech_blocker + * \brief Čech complex blocker. + * + * \ingroup cech_complex + * + * \details + * Čech blocker is an oracle constructed from a Cech_complex and a simplicial complex. + * + * \tparam SimplicialComplexForProximityGraph furnishes `Simplex_handle` and `Filtration_value` type definition, + * `simplex_vertex_range(Simplex_handle sh)`and `assign_filtration(Simplex_handle sh, Filtration_value filt)` methods. + * + * \tparam Chech_complex is required by the blocker. + */ +template +class Cech_blocker { + private: + using Point_cloud = typename Cech_complex::Point_cloud; + + using Simplex_handle = typename SimplicialComplexForCech::Simplex_handle; + using Filtration_value = typename SimplicialComplexForCech::Filtration_value; + + public: + /** \internal \brief Čech complex blocker operator() - the oracle - assigns the filtration value from the simplex + * radius and returns if the simplex expansion must be blocked. + * \param[in] sh The Simplex_handle. + * \return true if the simplex radius is greater than the Cech_complex max_radius*/ + bool operator()(Simplex_handle sh) { + Point_cloud points; + for (auto vertex : sc_ptr_->simplex_vertex_range(sh)) { + points.push_back(cc_ptr_->get_point(vertex)); +#ifdef DEBUG_TRACES + std::cout << "#(" << vertex << ")#"; +#endif // DEBUG_TRACES + } + Filtration_value radius = Gudhi::Minimal_enclosing_ball_radius()(points); +#ifdef DEBUG_TRACES + if (radius > cc_ptr_->max_radius()) std::cout << "radius > max_radius => expansion is blocked\n"; +#endif // DEBUG_TRACES + sc_ptr_->assign_filtration(sh, radius); + return (radius > cc_ptr_->max_radius()); + } + + /** \internal \brief Čech complex blocker constructor. */ + Cech_blocker(SimplicialComplexForCech* sc_ptr, Cech_complex* cc_ptr) : sc_ptr_(sc_ptr), cc_ptr_(cc_ptr) {} + + private: + SimplicialComplexForCech* sc_ptr_; + Cech_complex* cc_ptr_; +}; + +} // namespace cech_complex + +} // namespace Gudhi + +#endif // CECH_COMPLEX_BLOCKER_H_ -- cgit v1.2.3