11#ifndef CECH_COMPLEX_BLOCKER_H_
12#define CECH_COMPLEX_BLOCKER_H_
14#include <CGAL/NT_converter.h>
15#include <CGAL/Lazy_exact_nt.h>
24namespace cech_complex {
42template <
typename SimplicialComplexForCech,
typename Cech_complex,
typename Kernel>
47 using Point_d =
typename Kernel::Point_d;
49 using FT =
typename Kernel::FT;
51 using Sphere =
typename std::pair<Point_d, FT>;
57 using Simplex_key =
typename SimplicialComplexForCech::Simplex_key;
59 template<
class Po
intIterator>
60 Sphere get_sphere(PointIterator begin, PointIterator end)
const {
61 Point_d c = kernel_.construct_circumcenter_d_object()(begin, end);
62 FT r = kernel_.squared_distance_d_object()(c, *begin);
63 return std::make_pair(std::move(c), std::move(r));
72 bool operator()(Simplex_handle sh) {
73 using Point_cloud = std::vector<Point_d>;
75 bool is_min_enclos_ball =
false;
77 points.reserve(sc_ptr_->dimension(sh)+1);
80 for (
auto face_opposite_vertex : sc_ptr_->boundary_opposite_vertex_simplex_range(sh)) {
81 auto k = sc_ptr_->key(face_opposite_vertex.first);
83 if(k != sc_ptr_->null_key()) {
87 for (
auto vertex : sc_ptr_->simplex_vertex_range(face_opposite_vertex.first)) {
88 points.push_back(cc_ptr_->get_point(vertex));
90 std::clog <<
"#(" << vertex <<
")#";
94 sph_key = cc_ptr_->get_cache().size();
95 sc_ptr_->assign_key(face_opposite_vertex.first, sph_key);
96 cc_ptr_->get_cache().push_back(get_sphere(points.cbegin(), points.cend()));
101 Sphere
const& sph = cc_ptr_->get_cache()[sph_key];
102 if (kernel_.squared_distance_d_object()(sph.first, cc_ptr_->get_point(face_opposite_vertex.second)) <= sph.second) {
103 is_min_enclos_ball =
true;
104 sc_ptr_->assign_key(sh, sph_key);
105 radius = sc_ptr_->filtration(face_opposite_vertex.first);
107 std::clog <<
"center: " << sph.first <<
", radius: " << radius << std::endl;
113 if(!is_min_enclos_ball) {
114 for (
auto vertex : sc_ptr_->simplex_vertex_range(sh)) {
115 points.push_back(cc_ptr_->get_point(vertex));
117 Sphere sph = get_sphere(points.cbegin(), points.cend());
118#if CGAL_VERSION_NR >= 1050000000
119 if(cc_ptr_->is_exact()) CGAL::exact(sph.second);
121 CGAL::NT_converter<FT, Filtration_value> cast_to_fv;
122 radius = std::sqrt(cast_to_fv(sph.second));
124 sc_ptr_->assign_key(sh, cc_ptr_->get_cache().size());
125 cc_ptr_->get_cache().push_back(std::move(sph));
129 if (radius > cc_ptr_->max_radius()) std::clog <<
"radius > max_radius => expansion is blocked\n";
132 if (radius > sc_ptr_->filtration(sh)) sc_ptr_->assign_filtration(sh, radius);
133 return (radius > cc_ptr_->max_radius());
137 Cech_blocker(SimplicialComplexForCech* sc_ptr,
Cech_complex* cc_ptr) : sc_ptr_(sc_ptr), cc_ptr_(cc_ptr) {}
140 SimplicialComplexForCech* sc_ptr_;
Cech complex class.
Definition: Cech_complex.h:43
Value type for a filtration function on a cell complex.
Definition: FiltrationValue.h:20
unspecified Filtration_value
Definition: SimplicialComplexForCech.h:27
unspecified Simplex_handle
Definition: SimplicialComplexForCech.h:23