11#ifndef INCLUDE_ALPHA_COMPLEX_FACTORY_H_
12#define INCLUDE_ALPHA_COMPLEX_FACTORY_H_
14#include <gudhi/Simplex_tree.h>
15#include <gudhi/Alpha_complex.h>
16#include <gudhi/Alpha_complex_3d.h>
17#include <gudhi/Alpha_complex_options.h>
18#include <CGAL/Epeck_d.h>
19#include <CGAL/Epick_d.h>
21#include <boost/range/adaptor/transformed.hpp>
23#include "Simplex_tree_interface.h"
32namespace alpha_complex {
34template <
typename CgalPo
intType>
35std::vector<double> pt_cgal_to_cython(CgalPointType
const& point) {
36 std::vector<double> vd;
37 vd.reserve(point.dimension());
38 for (
auto coord = point.cartesian_begin(); coord != point.cartesian_end(); coord++)
39 vd.push_back(CGAL::to_double(*coord));
43template <
typename CgalPo
intType>
44static CgalPointType pt_cython_to_cgal(std::vector<double>
const& vec) {
45 return CgalPointType(vec.size(), vec.begin(), vec.end());
48class Abstract_alpha_complex {
50 virtual std::vector<double> get_point(
int vh) = 0;
52 virtual bool create_simplex_tree(Simplex_tree_interface<>* simplex_tree,
double max_alpha_square,
53 bool default_filtration_value) = 0;
55 virtual ~Abstract_alpha_complex() =
default;
58class Exact_Alphacomplex_dD final :
public Abstract_alpha_complex {
60 using Kernel = CGAL::Epeck_d<CGAL::Dynamic_dimension_tag>;
61 using Point =
typename Kernel::Point_d;
64 Exact_Alphacomplex_dD(
const std::vector<std::vector<double>>& points,
bool exact_version)
65 : exact_version_(exact_version),
66 alpha_complex_(boost::adaptors::transform(points, pt_cython_to_cgal<Point>)) {
69 virtual std::vector<double> get_point(
int vh)
override {
70 Point
const& point = alpha_complex_.get_point(vh);
71 return pt_cgal_to_cython(point);
74 virtual bool create_simplex_tree(Simplex_tree_interface<>* simplex_tree,
double max_alpha_square,
75 bool default_filtration_value)
override {
76 return alpha_complex_.create_complex(*simplex_tree, max_alpha_square, exact_version_, default_filtration_value);
84class Inexact_Alphacomplex_dD final :
public Abstract_alpha_complex {
86 using Kernel = CGAL::Epick_d<CGAL::Dynamic_dimension_tag>;
87 using Point =
typename Kernel::Point_d;
90 Inexact_Alphacomplex_dD(
const std::vector<std::vector<double>>& points,
bool exact_version)
91 : exact_version_(exact_version),
92 alpha_complex_(boost::adaptors::transform(points, pt_cython_to_cgal<Point>)) {
95 virtual std::vector<double> get_point(
int vh)
override {
96 Point
const& point = alpha_complex_.get_point(vh);
97 return pt_cgal_to_cython(point);
99 virtual bool create_simplex_tree(Simplex_tree_interface<>* simplex_tree,
double max_alpha_square,
100 bool default_filtration_value)
override {
101 return alpha_complex_.create_complex(*simplex_tree, max_alpha_square, exact_version_, default_filtration_value);
109template <complexity Complexity>
110class Alphacomplex_3D final :
public Abstract_alpha_complex {
114 static Point pt_cython_to_cgal_3(std::vector<double>
const& vec) {
115 return Point(vec[0], vec[1], vec[2]);
119 Alphacomplex_3D(
const std::vector<std::vector<double>>& points)
120 : alpha_complex_(boost::adaptors::transform(points, pt_cython_to_cgal_3)) {
123 virtual std::vector<double> get_point(
int vh)
override {
124 Point
const& point = alpha_complex_.get_point(vh);
125 return pt_cgal_to_cython(point);
128 virtual bool create_simplex_tree(Simplex_tree_interface<>* simplex_tree,
double max_alpha_square,
129 bool default_filtration_value)
override {
130 return alpha_complex_.create_complex(*simplex_tree, max_alpha_square);
Alpha complex data structure for 3d specific case.
Definition: Alpha_complex_3d.h:121