From 35fee4017481fd3f62fceb76a1b2bc8cd0f15b95 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 7 Sep 2018 14:17:13 +0000 Subject: Code review : rearrange documentation and examples according to making choices more orthogonal Rename Alpha_complex_3d_options.h Alpha_complex_options.h as it can be used by Alpha complex dD git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/alpha_complex_3d_module_vincent@3875 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 6c5b105248e4766a44438a187bb130a3722b310f --- src/Alpha_complex/include/gudhi/Alpha_complex_3d.h | 112 ++++++------- .../include/gudhi/Alpha_complex_3d_options.h | 179 --------------------- .../include/gudhi/Alpha_complex_options.h | 64 ++++++++ 3 files changed, 110 insertions(+), 245 deletions(-) delete mode 100644 src/Alpha_complex/include/gudhi/Alpha_complex_3d_options.h create mode 100644 src/Alpha_complex/include/gudhi/Alpha_complex_options.h (limited to 'src/Alpha_complex/include/gudhi') diff --git a/src/Alpha_complex/include/gudhi/Alpha_complex_3d.h b/src/Alpha_complex/include/gudhi/Alpha_complex_3d.h index bbe13be2..bf1aaa99 100644 --- a/src/Alpha_complex/include/gudhi/Alpha_complex_3d.h +++ b/src/Alpha_complex/include/gudhi/Alpha_complex_3d.h @@ -31,7 +31,7 @@ #endif #include -#include +#include #include #include @@ -57,13 +57,6 @@ namespace Gudhi { namespace alpha_complex { -enum class complexity: char -{ - fast='f', - safe='s', - exact='e', -}; - /** * \class Alpha_complex_3d * \brief Alpha complex data structure for 3d specific case. @@ -73,15 +66,30 @@ enum class complexity: char * \details * The data structure is constructing a CGAL 3D Alpha * Shapes from a range of points (can be read from an OFF file, cf. Points_off_reader). + * Duplicate points are inserted once in the Alpha_complex. This is the reason why the vertices may be not contiguous. + * + * \tparam Complexity shall be `Gudhi::alpha_complex::complexity`. Default value is + * `Gudhi::alpha_complex::complexity::fast`. + * + * \tparam Weighted Boolean used to set/unset the weighted version of Alpha_complex_3d. Default value is false. + * + * \tparam Periodic Boolean used to set/unset the periodic version of Alpha_complex_3d. Default value is false. * - * \tparam AlphaComplex3dOptions can be `Gudhi::alpha_complex::Alpha_shapes_3d`, - * `Gudhi::alpha_complex::Exact_alpha_shapes_3d`, `Gudhi::alpha_complex::Weighted_alpha_shapes_3d`, - * `Gudhi::alpha_complex::Periodic_alpha_shapes_3d` or `Gudhi::alpha_complex::Weighted_periodic_alpha_shapes_3d`. + * For the weighted version, weights values are explained on CGAL + * Alpha shapes 3d and + * Regular + * triangulation documentation. + * + * For the periodic version, refer to the + * CGAL’s 3D Periodic Triangulations User + * Manual for more details. + * The periodicity is defined by an iso-oriented cuboid with diagonal opposite vertices (x_min, y_min, z_min) and + * (x_max, y_max, z_max). * * Please refer to \ref alpha_complex for examples. * * \remark When Alpha_complex_3d is constructed with an infinite value of alpha (default value), the complex is a - * Delaunay complex. + * 3d Delaunay complex. * */ template @@ -157,9 +165,9 @@ class Alpha_complex_3d { using Triangulation_3 = CGAL::Periodic_3_regular_triangulation_3; }; +public: using Triangulation_3 = typename Triangulation::Triangulation_3; -public: using Alpha_shape_3 = CGAL::Alpha_shape_3; using Point_3 = typename Kernel::Point_3; @@ -184,20 +192,16 @@ private: public: /** \brief Alpha_complex constructor from a list of points. * - * Duplicate points are inserted once in the Alpha_complex. This is the reason why the vertices may be not contiguous. + * @param[in] points Range of points to triangulate. Points must be in `Alpha_complex_3d::Point_3` or + * `Alpha_complex_3d::Triangulation_3::Weighted_point`. * - * @param[in] points Range of points to triangulate. Points must be in AlphaComplex3dOptions::Point_3 + * @pre Available if Alpha_complex_3d is not Periodic. * - * @pre Available if AlphaComplex3dOptions is `Gudhi::alpha_complex::Alpha_shapes_3d` or - * `Gudhi::alpha_complex::Exact_alpha_shapes_3d`. - * - * The type InputPointRange must be a range for which std::begin and - * std::end return input iterators on a AlphaComplex3dOptions::Point_3. + * The type InputPointRange must be a range for which std::begin and std::end return input iterators on a + * `Alpha_complex_3d::Point_3` or a `Alpha_complex_3d::Triangulation_3::Weighted_point`. */ template Alpha_complex_3d(const InputPointRange& points) { - static_assert(!Weighted, - "This constructor is not available for weighted versions of Alpha_complex_3d"); static_assert(!Periodic, "This constructor is not available for periodic versions of Alpha_complex_3d"); @@ -215,23 +219,17 @@ public: /** \brief Alpha_complex constructor from a list of points and associated weights. * - * Duplicate points are inserted once in the Alpha_complex. This is the reason why the vertices may be not contiguous. - * Weights values are explained on CGAL Alpha - * shape and - * Regular - * triangulation documentation. - * * @exception std::invalid_argument In debug mode, if points and weights do not have the same size. * - * @param[in] points Range of points to triangulate. Points must be in AlphaComplex3dOptions::Point_3 - * @param[in] weights Range of weights on points. Points must be in AlphaComplex3dOptions::Point_3 + * @param[in] points Range of points to triangulate. Points must be in `Alpha_complex_3d::Point_3` + * @param[in] weights Range of weights on points. Weights shall be in `Alpha_complex_3d::Alpha_shape_3::FT` * - * @pre Available if AlphaComplex3dOptions is `Weighted_alpha_shapes_3d`. + * @pre Available if Alpha_complex_3d is Weighted and not Periodic. * * The type InputPointRange must be a range for which std::begin and - * std::end return input iterators on a AlphaComplex3dOptions::Point_3. + * std::end return input iterators on a `Alpha_complex_3d::Point_3`. * The type WeightRange must be a range for which std::begin and - * std::end return an input iterator on a AlphaComplex3dOptions::Alpha_shape_3::FT. + * std::end return an input iterator on a `Alpha_complex_3d::Alpha_shape_3::FT`. */ template Alpha_complex_3d(const InputPointRange& points, WeightRange weights) { @@ -268,16 +266,10 @@ public: /** \brief Alpha_complex constructor from a list of points and an iso-cuboid coordinates. * - * Duplicate points are inserted once in the Alpha_complex. This is the reason why the vertices may be not contiguous. - * - * Refer to the CGAL’s 3D Periodic - * Triangulations User Manual for more details. - * The periodicity is defined by an iso-oriented cuboid with diagonal opposite vertices (x_min, y_min, z_min) and - * (x_max, y_max, z_max). - * * @exception std::invalid_argument In debug mode, if the size of the cuboid in every directions is not the same. * - * @param[in] points Range of points to triangulate. Points must be in AlphaComplex3dOptions::Point_3 + * @param[in] points Range of points to triangulate. Points must be in `Alpha_complex_3d::Point_3` or + * `Alpha_complex_3d::Triangulation_3::Weighted_point`. * @param[in] x_min Iso-oriented cuboid x_min. * @param[in] y_min Iso-oriented cuboid y_min. * @param[in] z_min Iso-oriented cuboid z_min. @@ -285,18 +277,18 @@ public: * @param[in] y_max Iso-oriented cuboid y_max. * @param[in] z_max Iso-oriented cuboid z_max. * - * @pre Available if AlphaComplex3dOptions is `Periodic_alpha_shapes_3d`. + * @pre Available if Alpha_complex_3d is Periodic. * - * The type InputPointRange must be a range for which std::begin and - * std::end return input iterators on a AlphaComplex3dOptions::Point_3. - * The type of x_min, y_min, z_min, x_max, y_max and z_max is AlphaComplex3dOptions::Alpha_shape_3::FT. + * The type InputPointRange must be a range for which std::begin and std::end return input iterators on a + * `Alpha_complex_3d::Point_3` or a `Alpha_complex_3d::Triangulation_3::Weighted_point`. + * + * @note In weighted version, please check weights are greater than zero, and lower than 1/64*cuboid length + * squared. */ template Alpha_complex_3d(const InputPointRange& points, Alpha_value_type x_min, Alpha_value_type y_min, Alpha_value_type z_min, Alpha_value_type x_max, Alpha_value_type y_max, Alpha_value_type z_max) { - static_assert(!Weighted, - "This constructor is not available for weighted versions of Alpha_complex_3d"); static_assert(Periodic, "This constructor is not available for non-periodic versions of Alpha_complex_3d"); // Checking if the cuboid is the same in x,y and z direction. If not, CGAL will not process it. @@ -332,25 +324,13 @@ public: /** \brief Alpha_complex constructor from a list of points, associated weights and an iso-cuboid coordinates. * - * Duplicate points are inserted once in the Alpha_complex. This is the reason why the vertices may be not contiguous. - * - * Weights values are explained on CGAL Alpha - * shape and - * Regular - * triangulation documentation. - * - * Refer to the CGAL’s 3D Periodic - * Triangulations User Manual for more details. - * The periodicity is defined by an iso-oriented cuboid with diagonal opposite vertices (x_min, y_min, z_min) and - * (x_max, y_max, z_max). - * * @exception std::invalid_argument In debug mode, if points and weights do not have the same size. * @exception std::invalid_argument In debug mode, if the size of the cuboid in every directions is not the same. * @exception std::invalid_argument In debug mode, if a weight is negative, zero, or greater than 1/64*cuboid length * squared. * - * @param[in] points Range of points to triangulate. Points must be in AlphaComplex3dOptions::Point_3 - * @param[in] weights Range of weights on points. Points must be in AlphaComplex3dOptions::Point_3 + * @param[in] points Range of points to triangulate. Points must be in `Alpha_complex_3d::Point_3` + * @param[in] weights Range of weights on points. Weights shall be in `Alpha_complex_3d::Alpha_shape_3::FT` * @param[in] x_min Iso-oriented cuboid x_min. * @param[in] y_min Iso-oriented cuboid y_min. * @param[in] z_min Iso-oriented cuboid z_min. @@ -358,13 +338,13 @@ public: * @param[in] y_max Iso-oriented cuboid y_max. * @param[in] z_max Iso-oriented cuboid z_max. * - * @pre Available if AlphaComplex3dOptions is `Weighted_periodic_alpha_shapes_3d`. + * @pre Available if Alpha_complex_3d is Weighted and Periodic. * * The type InputPointRange must be a range for which std::begin and - * std::end return input iterators on a AlphaComplex3dOptions::Point_3. + * std::end return input iterators on a `Alpha_complex_3d::Point_3`. * The type WeightRange must be a range for which std::begin and - * std::end return an input iterator on a AlphaComplex3dOptions::Alpha_shape_3::FT. - * The type of x_min, y_min, z_min, x_max, y_max and z_max is AlphaComplex3dOptions::Alpha_shape_3::FT. + * std::end return an input iterator on a `Alpha_complex_3d::Alpha_shape_3::FT`. + * The type of x_min, y_min, z_min, x_max, y_max and z_max is `Alpha_complex_3d::Alpha_shape_3::FT`. */ template Alpha_complex_3d(const InputPointRange& points, WeightRange weights, @@ -395,7 +375,7 @@ public: while ((index < weights.size()) && (index < points.size())) { GUDHI_CHECK((weights[index] < maximal_possible_weight) && (weights[index] >= 0), - std::invalid_argument("Invalid weight at line" + std::to_string(index + 1) + + std::invalid_argument("Invalid weight at index " + std::to_string(index + 1) + ". Must be positive and less than maximal possible weight = 1/64*cuboid length " "squared, which is not an acceptable input.")); weighted_points_3.push_back(Weighted_point_3(points[index], weights[index])); diff --git a/src/Alpha_complex/include/gudhi/Alpha_complex_3d_options.h b/src/Alpha_complex/include/gudhi/Alpha_complex_3d_options.h deleted file mode 100644 index 567b19cb..00000000 --- a/src/Alpha_complex/include/gudhi/Alpha_complex_3d_options.h +++ /dev/null @@ -1,179 +0,0 @@ -/* 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 ALPHA_COMPLEX_3D_OPTIONS_H_ -#define ALPHA_COMPLEX_3D_OPTIONS_H_ - - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -namespace Gudhi { - -namespace alpha_complex { - -class Alpha_shapes_3d { -private: - using Kernel = CGAL::Exact_predicates_inexact_constructions_kernel; - using Vb = CGAL::Alpha_shape_vertex_base_3; - using Fb = CGAL::Alpha_shape_cell_base_3; - using Tds = CGAL::Triangulation_data_structure_3; - using Triangulation_3 = CGAL::Delaunay_triangulation_3; - -public: - using Alpha_shape_3 = CGAL::Alpha_shape_3; - using Point_3 = Kernel::Point_3; - - static const bool weighted = false; - static const bool periodic = false; - - // Default value_from_iterator as Alpha_shape_3 is not exact - template - static Filtration_value value_from_iterator(const Alpha_value_iterator avi) { - return /*std::sqrt*/ *avi; - } -}; - -class Exact_alpha_shapes_3d { -private: - // Alpha_shape_3 templates type definitions - using Kernel = CGAL::Exact_predicates_inexact_constructions_kernel; - using Exact_tag = CGAL::Tag_true; - using Vb = CGAL::Alpha_shape_vertex_base_3; - using Fb = CGAL::Alpha_shape_cell_base_3; - using Tds = CGAL::Triangulation_data_structure_3; - using Triangulation_3 = CGAL::Delaunay_triangulation_3; - -public: - using Alpha_shape_3 = CGAL::Alpha_shape_3; - using Point_3 = Kernel::Point_3; - - static const bool weighted = false; - static const bool periodic = false; - - // value_from_iterator needs to compute filtration value as Alpha_shape_3 is exact - template - static Filtration_value value_from_iterator(const Alpha_value_iterator avi) { - return /*std::sqrt*/ CGAL::to_double(avi->exact()); - } -}; - -class Weighted_alpha_shapes_3d { -private: - using Kernel = CGAL::Exact_predicates_inexact_constructions_kernel; - using Rvb = CGAL::Regular_triangulation_vertex_base_3; - using Vb = CGAL::Alpha_shape_vertex_base_3; - using Rcb = CGAL::Regular_triangulation_cell_base_3; - using Cb = CGAL::Alpha_shape_cell_base_3; - using Tds = CGAL::Triangulation_data_structure_3; - using Triangulation_3 = CGAL::Regular_triangulation_3; - - -public: - using Alpha_shape_3 = CGAL::Alpha_shape_3; - using Point_3 = Triangulation_3::Bare_point; - using Weighted_point_3 = Triangulation_3::Weighted_point; - - static const bool weighted = true; - static const bool periodic = false; - - // Default value_from_iterator as Alpha_shape_3 is not exact - template - static Filtration_value value_from_iterator(const Alpha_value_iterator avi) { - return /*std::sqrt*/ *avi; - } -}; - -class Periodic_alpha_shapes_3d { -private: - // Traits - using K = CGAL::Exact_predicates_inexact_constructions_kernel; - using PK = CGAL::Periodic_3_Delaunay_triangulation_traits_3; -// Vertex type - using DsVb = CGAL::Periodic_3_triangulation_ds_vertex_base_3<>; - using Vb = CGAL::Triangulation_vertex_base_3; - using AsVb = CGAL::Alpha_shape_vertex_base_3; -// Cell type - using DsCb = CGAL::Periodic_3_triangulation_ds_cell_base_3<>; - using Cb = CGAL::Triangulation_cell_base_3; - using AsCb = CGAL::Alpha_shape_cell_base_3; - using Tds = CGAL::Triangulation_data_structure_3; - -public: - using Periodic_delaunay_triangulation_3 = CGAL::Periodic_3_Delaunay_triangulation_3; - using Alpha_shape_3 = CGAL::Alpha_shape_3; - using Point_3 = PK::Point_3; - using Iso_cuboid_3 = PK::Iso_cuboid_3; - - static const bool weighted = false; - static const bool periodic = true; - - // Default value_from_iterator as Alpha_shape_3 is not exact - template - static Filtration_value value_from_iterator(const Alpha_value_iterator avi) { - return /*std::sqrt*/ *avi; - } -}; - -class Weighted_periodic_alpha_shapes_3d { -private: - using Kernel = CGAL::Exact_predicates_inexact_constructions_kernel; - using Periodic_kernel = CGAL::Periodic_3_regular_triangulation_traits_3; - using DsVb = CGAL::Periodic_3_triangulation_ds_vertex_base_3<>; - using Vb = CGAL::Regular_triangulation_vertex_base_3; - using AsVb = CGAL::Alpha_shape_vertex_base_3; - using DsCb = CGAL::Periodic_3_triangulation_ds_cell_base_3<>; - using Cb = CGAL::Regular_triangulation_cell_base_3; - using AsCb = CGAL::Alpha_shape_cell_base_3; - using Tds = CGAL::Triangulation_data_structure_3; - -public: - using Periodic_delaunay_triangulation_3 = CGAL::Periodic_3_regular_triangulation_3; - using Alpha_shape_3 = CGAL::Alpha_shape_3; - using Point_3 = Periodic_delaunay_triangulation_3::Bare_point; - using Weighted_point_3 = Periodic_delaunay_triangulation_3::Weighted_point; - using Iso_cuboid_3 = Periodic_kernel::Iso_cuboid_3; - - static const bool weighted = true; - static const bool periodic = true; - - // Default value_from_iterator as Alpha_shape_3 is not exact - template - static Filtration_value value_from_iterator(const Alpha_value_iterator avi) { - return /*std::sqrt*/ *avi; - } -}; - -} // namespace alpha_complex - -} // namespace Gudhi - -#endif // ALPHA_COMPLEX_3D_OPTIONS_H_ diff --git a/src/Alpha_complex/include/gudhi/Alpha_complex_options.h b/src/Alpha_complex/include/gudhi/Alpha_complex_options.h new file mode 100644 index 00000000..32980fa7 --- /dev/null +++ b/src/Alpha_complex/include/gudhi/Alpha_complex_options.h @@ -0,0 +1,64 @@ +/* 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 ALPHA_COMPLEX_OPTIONS_H_ +#define ALPHA_COMPLEX_OPTIONS_H_ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +namespace Gudhi { + +namespace alpha_complex { + + +/** + * \class complexity + * \brief Alpha complex complexity template parameter possible values. + * + * \ingroup alpha_complex + */ +enum class complexity: char +{ + /** \brief Fast version.*/ + fast='f', + /** \brief Safe version.*/ + safe='s', + /** \brief Exact version.*/ + exact='e', +}; + +} // namespace alpha_complex + +} // namespace Gudhi + +#endif // ALPHA_COMPLEX_OPTIONS_H_ -- cgit v1.2.3