summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Alpha_complex/concept/SimplicialComplexForAlpha.h14
-rw-r--r--src/Alpha_complex/concept/SimplicialComplexForAlpha3d.h58
-rw-r--r--src/Alpha_complex/doc/Intro_alpha_complex.h23
-rw-r--r--src/Alpha_complex/example/CMakeLists.txt66
-rw-r--r--src/Alpha_complex/example/Weighted_alpha_complex_3d_from_points.cpp71
-rw-r--r--src/Alpha_complex/example/weightedalpha3dfrompoints_for_doc.txt31
-rw-r--r--src/Alpha_complex/include/gudhi/Alpha_complex_3d.h498
-rw-r--r--src/Alpha_complex/include/gudhi/Alpha_complex_3d_options.h179
-rw-r--r--src/Alpha_complex/test/Alpha_complex_3d_unit_test.cpp663
-rw-r--r--src/Alpha_complex/test/CMakeLists.txt7
-rw-r--r--src/Alpha_complex/utilities/CMakeLists.txt74
-rw-r--r--src/Alpha_complex/utilities/alpha_complex_3d_helper.h74
-rw-r--r--src/Alpha_complex/utilities/alpha_complex_3d_persistence.cpp268
-rw-r--r--src/Alpha_complex/utilities/alphacomplex.md145
-rw-r--r--src/Alpha_complex/utilities/exact_alpha_complex_3d_persistence.cpp265
-rw-r--r--src/Alpha_complex/utilities/periodic_alpha_complex_3d_persistence.cpp302
-rw-r--r--src/Alpha_complex/utilities/weighted_alpha_complex_3d_persistence.cpp316
-rw-r--r--src/Alpha_complex/utilities/weighted_periodic_alpha_complex_3d_persistence.cpp288
-rw-r--r--src/common/doc/examples.h5
-rw-r--r--src/common/doc/installation.h30
-rw-r--r--src/common/doc/main_page.h2
21 files changed, 1790 insertions, 1589 deletions
diff --git a/src/Alpha_complex/concept/SimplicialComplexForAlpha.h b/src/Alpha_complex/concept/SimplicialComplexForAlpha.h
index a51df127..ba97c802 100644
--- a/src/Alpha_complex/concept/SimplicialComplexForAlpha.h
+++ b/src/Alpha_complex/concept/SimplicialComplexForAlpha.h
@@ -41,9 +41,6 @@ struct SimplicialComplexForAlpha {
/** Returns the number of vertices in the simplicial complex. */
std::size_t num_vertices();
- /** Sets the simplicial complex dimension. */
- void set_dimension(int dimension);
-
/** Gets the 'simplex' dimension. */
int dimension(Simplex_handle simplex);
@@ -65,8 +62,7 @@ struct SimplicialComplexForAlpha {
* 'value type' must be 'Vertex_handle'.*/
typedef unspecified Simplex_vertex_range;
- /** \brief Returns a range over vertices of a given
- * simplex. */
+ /** \brief Returns a range over vertices of a given simplex. */
Simplex_vertex_range simplex_vertex_range(Simplex_handle const & simplex);
/** \brief Iterator over the boundaries of the complex, in an arbitrary order.
@@ -77,6 +73,14 @@ struct SimplicialComplexForAlpha {
/** \brief Returns a range over boundaries of a given simplex. */
Boundary_simplex_range boundary_simplex_range(Simplex_handle const & simplex);
+ /** \brief Iterator over the simplices of the skeleton of the complex, for a given dimension.
+ *
+ * 'value_type' must be 'Simplex_handle'. */
+ typedef unspecified Skeleton_simplex_range;
+ /** \brief Returns a range over the simplices of the skeleton of the simplicial complex, for a given
+ * dimension. */
+ Skeleton_simplex_range skeleton_simplex_range;
+
/** \brief Return type of an insertion of a simplex
*/
typedef unspecified Insertion_result_type;
diff --git a/src/Alpha_complex/concept/SimplicialComplexForAlpha3d.h b/src/Alpha_complex/concept/SimplicialComplexForAlpha3d.h
new file mode 100644
index 00000000..f6085a26
--- /dev/null
+++ b/src/Alpha_complex/concept/SimplicialComplexForAlpha3d.h
@@ -0,0 +1,58 @@
+/* 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 <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef CONCEPT_ALPHA_COMPLEX_SIMPLICIAL_COMPLEX_FOR_ALPHA_3D_H_
+#define CONCEPT_ALPHA_COMPLEX_SIMPLICIAL_COMPLEX_FOR_ALPHA_3D_H_
+
+namespace Gudhi {
+
+namespace alpha_complex {
+
+/** \brief The concept SimplicialComplexForAlpha3d describes the requirements for a type to implement a simplicial
+ * complex, that can be created from a `Alpha_complex_3d`.
+ */
+struct SimplicialComplexForAlpha3d {
+ /** Handle to specify a vertex. Must be a non-negative integer. */
+ typedef unspecified Vertex_handle;
+ /** Handle to specify the simplex filtration value. */
+ typedef unspecified Filtration_value;
+
+ /** Returns the number of vertices in the simplicial complex. */
+ std::size_t num_vertices();
+
+ /** \brief Inserts a simplex from a given simplex (represented by a vector of Vertex_handle) in the
+ * simplicial complex with the given 'filtration' value. */
+ void insert_simplex(std::vector<Vertex_handle> const & vertex_range, Filtration_value filtration);
+
+ /** Browses the simplicial complex to make the filtration non-decreasing. */
+ void make_filtration_non_decreasing();
+
+ /** Prune the simplicial complex above 'filtration' value given as parameter. */
+ void prune_above_filtration(Filtration_value filtration);
+
+};
+
+} // namespace alpha_complex
+
+} // namespace Gudhi
+
+#endif // CONCEPT_ALPHA_COMPLEX_SIMPLICIAL_COMPLEX_FOR_ALPHA_3D_H_
diff --git a/src/Alpha_complex/doc/Intro_alpha_complex.h b/src/Alpha_complex/doc/Intro_alpha_complex.h
index 7a375c9f..82aee275 100644
--- a/src/Alpha_complex/doc/Intro_alpha_complex.h
+++ b/src/Alpha_complex/doc/Intro_alpha_complex.h
@@ -165,6 +165,29 @@ namespace alpha_complex {
*
* \include Alpha_complex/alphaoffreader_for_doc_32.txt
*
+ *
+ * \section weighted3dexample 3d specific example
+ *
+ * A specific module for Alpha complex is available in 3d (cf. Alpha_complex_3d) and allows to construct default, exact,
+ * weighted, periodic or weighted and periodic versions of alpha complexes
+ *
+ * This example builds the CGAL 3d weighted alpha shapes from a small molecule, and initializes the alpha complex with
+ * it. This example is taken from <a href="https://doc.cgal.org/latest/Alpha_shapes_3/index.html#title13">CGAL 3d
+ * weighted alpha shapes</a>.
+ *
+ * Then, it is asked to display information about the alpha complex.
+ *
+ * \include Alpha_complex/Weighted_alpha_complex_3d_from_points.cpp
+ *
+ * When launching:
+ *
+ * \code $> ./Alpha_complex_example_weighted_3d_from_points
+ * \endcode
+ *
+ * the program output is:
+ *
+ * \include Alpha_complex/weightedalpha3dfrompoints_for_doc.txt
+ *
*/
/** @} */ // end defgroup alpha_complex
diff --git a/src/Alpha_complex/example/CMakeLists.txt b/src/Alpha_complex/example/CMakeLists.txt
index 2fc62452..4a1cd26d 100644
--- a/src/Alpha_complex/example/CMakeLists.txt
+++ b/src/Alpha_complex/example/CMakeLists.txt
@@ -1,35 +1,43 @@
project(Alpha_complex_examples)
-# need CGAL 4.7
-# cmake -DCGAL_DIR=~/workspace/CGAL-4.7 ..
-if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.7.0)
- add_executable ( Alpha_complex_example_from_points Alpha_complex_from_points.cpp )
- target_link_libraries(Alpha_complex_example_from_points ${CGAL_LIBRARY})
- add_executable ( Alpha_complex_example_from_off Alpha_complex_from_off.cpp )
- target_link_libraries(Alpha_complex_example_from_off ${CGAL_LIBRARY})
- if (TBB_FOUND)
- target_link_libraries(Alpha_complex_example_from_points ${TBB_LIBRARIES})
- target_link_libraries(Alpha_complex_example_from_off ${TBB_LIBRARIES})
- endif()
+if(CGAL_FOUND)
+ # need CGAL 4.7
+ # cmake -DCGAL_DIR=~/workspace/CGAL-4.7 ..
+ if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.7.0)
+ add_executable ( Alpha_complex_example_from_points Alpha_complex_from_points.cpp )
+ target_link_libraries(Alpha_complex_example_from_points ${CGAL_LIBRARY})
+ add_executable ( Alpha_complex_example_from_off Alpha_complex_from_off.cpp )
+ target_link_libraries(Alpha_complex_example_from_off ${CGAL_LIBRARY})
+ if (TBB_FOUND)
+ target_link_libraries(Alpha_complex_example_from_points ${TBB_LIBRARIES})
+ target_link_libraries(Alpha_complex_example_from_off ${TBB_LIBRARIES})
+ endif()
- add_test(NAME Alpha_complex_example_from_points COMMAND $<TARGET_FILE:Alpha_complex_example_from_points>)
+ add_test(NAME Alpha_complex_example_from_points COMMAND $<TARGET_FILE:Alpha_complex_example_from_points>)
- add_test(NAME Alpha_complex_example_from_off_60 COMMAND $<TARGET_FILE:Alpha_complex_example_from_off>
- "${CMAKE_SOURCE_DIR}/data/points/alphacomplexdoc.off" "60.0" "${CMAKE_CURRENT_BINARY_DIR}/alphaoffreader_result_60.txt")
- add_test(NAME Alpha_complex_example_from_off_32 COMMAND $<TARGET_FILE:Alpha_complex_example_from_off>
- "${CMAKE_SOURCE_DIR}/data/points/alphacomplexdoc.off" "32.0" "${CMAKE_CURRENT_BINARY_DIR}/alphaoffreader_result_32.txt")
- if (DIFF_PATH)
- # Do not forget to copy test results files in current binary dir
- file(COPY "alphaoffreader_for_doc_32.txt" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/)
- file(COPY "alphaoffreader_for_doc_60.txt" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/)
+ add_test(NAME Alpha_complex_example_from_off_60 COMMAND $<TARGET_FILE:Alpha_complex_example_from_off>
+ "${CMAKE_SOURCE_DIR}/data/points/alphacomplexdoc.off" "60.0" "${CMAKE_CURRENT_BINARY_DIR}/alphaoffreader_result_60.txt")
+ add_test(NAME Alpha_complex_example_from_off_32 COMMAND $<TARGET_FILE:Alpha_complex_example_from_off>
+ "${CMAKE_SOURCE_DIR}/data/points/alphacomplexdoc.off" "32.0" "${CMAKE_CURRENT_BINARY_DIR}/alphaoffreader_result_32.txt")
+ if (DIFF_PATH)
+ # Do not forget to copy test results files in current binary dir
+ file(COPY "alphaoffreader_for_doc_32.txt" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/)
+ file(COPY "alphaoffreader_for_doc_60.txt" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/)
- add_test(Alpha_complex_example_from_off_60_diff_files ${DIFF_PATH}
- ${CMAKE_CURRENT_BINARY_DIR}/alphaoffreader_result_60.txt ${CMAKE_CURRENT_BINARY_DIR}/alphaoffreader_for_doc_60.txt)
- add_test(Alpha_complex_example_from_off_32_diff_files ${DIFF_PATH}
- ${CMAKE_CURRENT_BINARY_DIR}/alphaoffreader_result_32.txt ${CMAKE_CURRENT_BINARY_DIR}/alphaoffreader_for_doc_32.txt)
- endif()
+ add_test(Alpha_complex_example_from_off_60_diff_files ${DIFF_PATH}
+ ${CMAKE_CURRENT_BINARY_DIR}/alphaoffreader_result_60.txt ${CMAKE_CURRENT_BINARY_DIR}/alphaoffreader_for_doc_60.txt)
+ add_test(Alpha_complex_example_from_off_32_diff_files ${DIFF_PATH}
+ ${CMAKE_CURRENT_BINARY_DIR}/alphaoffreader_result_32.txt ${CMAKE_CURRENT_BINARY_DIR}/alphaoffreader_for_doc_32.txt)
+ endif()
+ endif(NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.7.0)
+ if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0)
+ add_executable ( Alpha_complex_example_weighted_3d_from_points Weighted_alpha_complex_3d_from_points.cpp )
+ target_link_libraries(Alpha_complex_example_weighted_3d_from_points ${CGAL_LIBRARY})
+ if (TBB_FOUND)
+ target_link_libraries(Alpha_complex_example_weighted_3d_from_points ${TBB_LIBRARIES})
+ endif()
+ add_test(NAME Alpha_complex_example_weighted_3d_from_points
+ COMMAND $<TARGET_FILE:Alpha_complex_example_weighted_3d_from_points>)
- install(TARGETS Alpha_complex_example_from_points DESTINATION bin)
- install(TARGETS Alpha_complex_example_from_off DESTINATION bin)
-
-endif(NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.7.0)
+ endif(NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0)
+endif() \ No newline at end of file
diff --git a/src/Alpha_complex/example/Weighted_alpha_complex_3d_from_points.cpp b/src/Alpha_complex/example/Weighted_alpha_complex_3d_from_points.cpp
new file mode 100644
index 00000000..abb73427
--- /dev/null
+++ b/src/Alpha_complex/example/Weighted_alpha_complex_3d_from_points.cpp
@@ -0,0 +1,71 @@
+#include <gudhi/Alpha_complex_3d.h>
+#include <gudhi/Alpha_complex_3d_options.h>
+// to construct a simplex_tree from alpha complex
+#include <gudhi/Simplex_tree.h>
+
+#include <iostream>
+#include <string>
+#include <vector>
+#include <limits> // for numeric limits
+
+using Weighted_alpha_shapes_3d = Gudhi::alpha_complex::Weighted_alpha_shapes_3d;
+using Weighted_alpha_complex_3d = Gudhi::alpha_complex::Alpha_complex_3d<Weighted_alpha_shapes_3d>;
+using Point = Gudhi::alpha_complex::Weighted_alpha_shapes_3d::Point_3 ;
+using Vector_of_points = std::vector<Point>;
+using Vector_of_weights = std::vector<Gudhi::alpha_complex::Weighted_alpha_shapes_3d::Alpha_shape_3::FT>;
+
+void usage(int nbArgs, char * const progName) {
+ std::cerr << "Error: Number of arguments (" << nbArgs << ") is not correct\n";
+ std::cerr << "Usage: " << progName << " \n";
+ exit(-1); // ----- >>
+}
+
+int main(int argc, char **argv) {
+ if (argc != 1) {
+ std::cerr << "Error: Number of arguments (" << argc << ") is not correct\n";
+ std::cerr << "Usage: " << (argv[0] - 1) << " \n";
+ exit(-1); // ----- >>
+ }
+
+ // ----------------------------------------------------------------------------
+ // Init of a list of points and weights from a small molecule
+ // ----------------------------------------------------------------------------
+ Vector_of_points points;
+ Vector_of_weights weights;
+ points.push_back(Point(1, -1, -1));
+ weights.push_back(4.);
+ points.push_back(Point(-1, 1, -1));
+ weights.push_back(4.);
+ points.push_back(Point(-1, -1, 1));
+ weights.push_back(4.);
+ points.push_back(Point(1, 1, 1));
+ weights.push_back(4.);
+ points.push_back(Point(2, 2, 2));
+ weights.push_back(1.);
+
+ // ----------------------------------------------------------------------------
+ // Init of an alpha complex from the list of points
+ // ----------------------------------------------------------------------------
+ Weighted_alpha_complex_3d alpha_complex_from_points(points, weights);
+
+ Gudhi::Simplex_tree<> simplex;
+ if (alpha_complex_from_points.create_complex(simplex)) {
+ // ----------------------------------------------------------------------------
+ // Display information about the alpha complex
+ // ----------------------------------------------------------------------------
+ std::cout << "Alpha complex is of dimension " << simplex.dimension() <<
+ " - " << simplex.num_simplices() << " simplices - " <<
+ simplex.num_vertices() << " vertices." << std::endl;
+
+ std::cout << "Iterator on alpha complex simplices in the filtration order, with [filtration value]:" << std::endl;
+ for (auto f_simplex : simplex.filtration_simplex_range()) {
+ std::cout << " ( ";
+ for (auto vertex : simplex.simplex_vertex_range(f_simplex)) {
+ std::cout << vertex << " ";
+ }
+ std::cout << ") -> " << "[" << simplex.filtration(f_simplex) << "] ";
+ std::cout << std::endl;
+ }
+ }
+ return 0;
+}
diff --git a/src/Alpha_complex/example/weightedalpha3dfrompoints_for_doc.txt b/src/Alpha_complex/example/weightedalpha3dfrompoints_for_doc.txt
new file mode 100644
index 00000000..7a09998d
--- /dev/null
+++ b/src/Alpha_complex/example/weightedalpha3dfrompoints_for_doc.txt
@@ -0,0 +1,31 @@
+Alpha complex is of dimension 3 - 29 simplices - 5 vertices.
+Iterator on alpha complex simplices in the filtration order, with [filtration value]:
+ ( 0 ) -> [-4]
+ ( 1 ) -> [-4]
+ ( 2 ) -> [-4]
+ ( 3 ) -> [-4]
+ ( 1 0 ) -> [-2]
+ ( 2 0 ) -> [-2]
+ ( 2 1 ) -> [-2]
+ ( 3 0 ) -> [-2]
+ ( 3 1 ) -> [-2]
+ ( 3 2 ) -> [-2]
+ ( 2 1 0 ) -> [-1.33333]
+ ( 3 1 0 ) -> [-1.33333]
+ ( 3 2 0 ) -> [-1.33333]
+ ( 3 2 1 ) -> [-1.33333]
+ ( 3 2 1 0 ) -> [-1]
+ ( 4 ) -> [-1]
+ ( 4 2 ) -> [-1]
+ ( 4 0 ) -> [23]
+ ( 4 1 ) -> [23]
+ ( 4 2 0 ) -> [23]
+ ( 4 2 1 ) -> [23]
+ ( 4 3 ) -> [23]
+ ( 4 3 2 ) -> [23]
+ ( 4 1 0 ) -> [95]
+ ( 4 2 1 0 ) -> [95]
+ ( 4 3 0 ) -> [95]
+ ( 4 3 1 ) -> [95]
+ ( 4 3 2 0 ) -> [95]
+ ( 4 3 2 1 ) -> [95]
diff --git a/src/Alpha_complex/include/gudhi/Alpha_complex_3d.h b/src/Alpha_complex/include/gudhi/Alpha_complex_3d.h
new file mode 100644
index 00000000..15acd7bd
--- /dev/null
+++ b/src/Alpha_complex/include/gudhi/Alpha_complex_3d.h
@@ -0,0 +1,498 @@
+/* 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 <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef ALPHA_COMPLEX_3D_H_
+#define ALPHA_COMPLEX_3D_H_
+
+#include <boost/version.hpp>
+#include <boost/variant.hpp>
+
+#if BOOST_VERSION >= 105400
+#include <boost/container/static_vector.hpp>
+#endif
+
+#include <gudhi/Debug_utils.h>
+#include <gudhi/Alpha_complex_3d_options.h>
+
+#include <CGAL/Object.h>
+#include <CGAL/tuple.h>
+#include <CGAL/iterator.h>
+#include <CGAL/version.h>
+
+#include <iostream>
+#include <vector>
+#include <map>
+#include <stdexcept>
+#include <cstddef>
+#include <memory> // for std::unique_ptr
+
+#if CGAL_VERSION_NR < 1041101000
+ // Make compilation fail - required for external projects - https://gitlab.inria.fr/GUDHI/gudhi-devel/issues/10
+ static_assert(false,
+ "Alpha_complex_3d is only available for CGAL >= 4.11");
+#endif
+
+namespace Gudhi {
+
+namespace alpha_complex {
+
+/**
+ * \class Alpha_complex_3d
+ * \brief Alpha complex data structure for 3d specific case.
+ *
+ * \ingroup alpha_complex
+ *
+ * \details
+ * The data structure is constructing a <a href="https://doc.cgal.org/latest/Alpha_shapes_3/index.html">CGAL 3D Alpha
+ * Shapes</a> from a range of points (can be read from an OFF file, cf. Points_off_reader).
+ *
+ * \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`.
+ *
+ * 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.
+ *
+ */
+template<typename AlphaComplex3dOptions>
+class Alpha_complex_3d {
+ using Alpha_shape_3 = typename AlphaComplex3dOptions::Alpha_shape_3;
+ using Alpha_value_type = typename Alpha_shape_3::FT;
+ using Dispatch =
+ CGAL::Dispatch_output_iterator<CGAL::cpp11::tuple<CGAL::Object, Alpha_value_type>,
+ CGAL::cpp11::tuple<std::back_insert_iterator<std::vector<CGAL::Object> >,
+ std::back_insert_iterator<std::vector<Alpha_value_type> > > >;
+
+ using Cell_handle = typename Alpha_shape_3::Cell_handle;
+ using Facet = typename Alpha_shape_3::Facet;
+ using Edge = typename Alpha_shape_3::Edge;
+ using Alpha_vertex_handle = typename Alpha_shape_3::Vertex_handle;
+#if BOOST_VERSION >= 105400
+ using Vertex_list = boost::container::static_vector<Alpha_vertex_handle, 4>;
+#else
+ using Vertex_list = std::vector<Alpha_vertex_handle>;
+#endif
+
+public:
+ using Point_3 = typename AlphaComplex3dOptions::Point_3;
+
+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 AlphaComplex3dOptions::Point_3
+ *
+ * @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.
+ */
+ template<typename InputPointRange >
+ Alpha_complex_3d(const InputPointRange& points) {
+ static_assert(!AlphaComplex3dOptions::weighted,
+ "This constructor is not available for weighted versions of Alpha_complex_3d");
+ static_assert(!AlphaComplex3dOptions::periodic,
+ "This constructor is not available for periodic versions of Alpha_complex_3d");
+
+ alpha_shape_3_ptr_ = std::unique_ptr<Alpha_shape_3>(new Alpha_shape_3(std::begin(points), std::end(points), 0,
+ Alpha_shape_3::GENERAL));
+ Dispatch dispatcher = CGAL::dispatch_output<CGAL::Object, Alpha_value_type>(std::back_inserter(objects_),
+ std::back_inserter(alpha_values_));
+
+ alpha_shape_3_ptr_->filtration_with_alpha_values(dispatcher);
+#ifdef DEBUG_TRACES
+ std::cout << "filtration_with_alpha_values returns : " << objects_.size() << " objects" << std::endl;
+#endif // DEBUG_TRACES
+
+ }
+
+ /** \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 <a href="https://doc.cgal.org/latest/Alpha_shapes_3/index.html#title0">Alpha
+ * shape</a> and
+ * <a href="https://doc.cgal.org/latest/Triangulation_3/index.html#Triangulation3secclassRegulartriangulation">Regular
+ * triangulation</a> 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
+ *
+ * @pre Available if AlphaComplex3dOptions is `Weighted_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 WeightRange must be a range for which std::begin and
+ * std::end return an input iterator on a AlphaComplex3dOptions::Alpha_shape_3::FT.
+ */
+ template<typename InputPointRange , typename WeightRange>
+ Alpha_complex_3d(const InputPointRange& points, WeightRange weights) {
+ static_assert(AlphaComplex3dOptions::weighted,
+ "This constructor is not available for non-weighted versions of Alpha_complex_3d");
+ static_assert(!AlphaComplex3dOptions::periodic,
+ "This constructor is not available for periodic versions of Alpha_complex_3d");
+ GUDHI_CHECK((weights.size() == points.size()),
+ std::invalid_argument("Points number in range different from weights range number"));
+
+ using Weighted_point_3 = typename AlphaComplex3dOptions::Weighted_point_3;
+ std::vector<Weighted_point_3> weighted_points_3;
+
+ std::size_t index = 0;
+ weighted_points_3.reserve(points.size());
+ while ((index < weights.size()) && (index < points.size())) {
+ weighted_points_3.push_back(Weighted_point_3(points[index], weights[index]));
+ index++;
+ }
+
+ alpha_shape_3_ptr_ = std::unique_ptr<Alpha_shape_3>(new Alpha_shape_3(std::begin(weighted_points_3),
+ std::end(weighted_points_3),
+ 0,
+ Alpha_shape_3::GENERAL));
+
+ Dispatch dispatcher = CGAL::dispatch_output<CGAL::Object, Alpha_value_type>(std::back_inserter(objects_),
+ std::back_inserter(alpha_values_));
+
+ alpha_shape_3_ptr_->filtration_with_alpha_values(dispatcher);
+#ifdef DEBUG_TRACES
+ std::cout << "filtration_with_alpha_values returns : " << objects_.size() << " objects" << std::endl;
+#endif // DEBUG_TRACES
+ }
+
+ /** \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 <a href="https://doc.cgal.org/latest/Periodic_3_triangulation_3/index.html">CGAL’s 3D Periodic
+ * Triangulations User Manual </a> 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] 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.
+ * @param[in] x_max Iso-oriented cuboid x_max.
+ * @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`.
+ *
+ * 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.
+ */
+ template<typename InputPointRange>
+ 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(!AlphaComplex3dOptions::weighted,
+ "This constructor is not available for weighted versions of Alpha_complex_3d");
+ static_assert(AlphaComplex3dOptions::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.
+ GUDHI_CHECK((x_max - x_min == y_max - y_min) &&
+ (x_max - x_min == z_max - z_min) &&
+ (z_max - z_min == y_max - y_min),
+ std::invalid_argument("The size of the cuboid in every directions is not the same."));
+
+ using Periodic_delaunay_triangulation_3 = typename AlphaComplex3dOptions::Periodic_delaunay_triangulation_3;
+ using Iso_cuboid_3 = typename AlphaComplex3dOptions::Iso_cuboid_3;
+ // Define the periodic cube
+ Periodic_delaunay_triangulation_3 pdt(Iso_cuboid_3(x_min, y_min, z_min, x_max, y_max, z_max));
+ // Heuristic for inserting large point sets (if pts is reasonably large)
+ pdt.insert(std::begin(points), std::end(points), true);
+ // As pdt won't be modified anymore switch to 1-sheeted cover if possible
+ if (!pdt.is_triangulation_in_1_sheet()) {
+ throw std::invalid_argument("Unable to construct a triangulation within a single periodic domain.");
+ }
+ pdt.convert_to_1_sheeted_covering();
+
+ // alpha shape construction from points. CGAL has a strange behavior in REGULARIZED mode. This is the default mode
+ // Maybe need to set it to GENERAL mode
+ alpha_shape_3_ptr_ = std::unique_ptr<Alpha_shape_3>(new Alpha_shape_3(pdt, 0,
+ Alpha_shape_3::GENERAL));
+
+ Dispatch dispatcher = CGAL::dispatch_output<CGAL::Object, Alpha_value_type>(std::back_inserter(objects_),
+ std::back_inserter(alpha_values_));
+
+ alpha_shape_3_ptr_->filtration_with_alpha_values(dispatcher);
+#ifdef DEBUG_TRACES
+ std::cout << "filtration_with_alpha_values returns : " << objects_.size() << " objects" << std::endl;
+#endif // DEBUG_TRACES
+
+ }
+
+ /** \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 <a href="https://doc.cgal.org/latest/Alpha_shapes_3/index.html#title0">Alpha
+ * shape</a> and
+ * <a href="https://doc.cgal.org/latest/Triangulation_3/index.html#Triangulation3secclassRegulartriangulation">Regular
+ * triangulation</a> documentation.
+ *
+ * Refer to the <a href="https://doc.cgal.org/latest/Periodic_3_triangulation_3/index.html">CGAL’s 3D Periodic
+ * Triangulations User Manual</a> 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] 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.
+ * @param[in] x_max Iso-oriented cuboid x_max.
+ * @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`.
+ *
+ * The type InputPointRange must be a range for which std::begin and
+ * std::end return input iterators on a AlphaComplex3dOptions::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.
+ */
+ template<typename InputPointRange , typename WeightRange>
+ Alpha_complex_3d(const InputPointRange& points, WeightRange weights,
+ 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(AlphaComplex3dOptions::weighted,
+ "This constructor is not available for non-weighted versions of Alpha_complex_3d");
+ static_assert(AlphaComplex3dOptions::periodic,
+ "This constructor is not available for non-periodic versions of Alpha_complex_3d");
+ GUDHI_CHECK((weights.size() == points.size()),
+ std::invalid_argument("Points number in range different from weights range number"));
+ // Checking if the cuboid is the same in x,y and z direction. If not, CGAL will not process it.
+ GUDHI_CHECK((x_max - x_min == y_max - y_min) &&
+ (x_max - x_min == z_max - z_min) &&
+ (z_max - z_min == y_max - y_min),
+ std::invalid_argument("The size of the cuboid in every directions is not the same."));
+
+ using Weighted_point_3 = typename AlphaComplex3dOptions::Weighted_point_3;
+ std::vector<Weighted_point_3> weighted_points_3;
+
+ std::size_t index = 0;
+ weighted_points_3.reserve(points.size());
+
+#ifdef GUDHI_DEBUG
+ // Defined in GUDHI_DEBUG to avoid unused variable warning for GUDHI_CHECK
+ double maximal_possible_weight = 0.015625 * (x_max - x_min) * (x_max - x_min);
+#endif
+
+ 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) +
+ ". 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]));
+ index++;
+ }
+
+ using Periodic_delaunay_triangulation_3 = typename AlphaComplex3dOptions::Periodic_delaunay_triangulation_3;
+ using Iso_cuboid_3 = typename AlphaComplex3dOptions::Iso_cuboid_3;
+ // Define the periodic cube
+ Periodic_delaunay_triangulation_3 pdt(Iso_cuboid_3(x_min, y_min, z_min, x_max, y_max, z_max));
+ // Heuristic for inserting large point sets (if pts is reasonably large)
+ pdt.insert(std::begin(weighted_points_3), std::end(weighted_points_3), true);
+ // As pdt won't be modified anymore switch to 1-sheeted cover if possible
+ if (!pdt.is_triangulation_in_1_sheet()) {
+ throw std::invalid_argument("Unable to construct a triangulation within a single periodic domain.");
+ }
+ pdt.convert_to_1_sheeted_covering();
+
+ // alpha shape construction from points. CGAL has a strange behavior in REGULARIZED mode. This is the default mode
+ // Maybe need to set it to GENERAL mode
+ alpha_shape_3_ptr_ = std::unique_ptr<Alpha_shape_3>(new Alpha_shape_3(pdt, 0,
+ Alpha_shape_3::GENERAL));
+
+ Dispatch dispatcher = CGAL::dispatch_output<CGAL::Object, Alpha_value_type>(std::back_inserter(objects_),
+ std::back_inserter(alpha_values_));
+
+ alpha_shape_3_ptr_->filtration_with_alpha_values(dispatcher);
+#ifdef DEBUG_TRACES
+ std::cout << "filtration_with_alpha_values returns : " << objects_.size() << " objects" << std::endl;
+#endif // DEBUG_TRACES
+ }
+
+
+ template <typename SimplicialComplexForAlpha3d>
+ bool create_complex(SimplicialComplexForAlpha3d& complex) {
+ using Filtration_value = typename SimplicialComplexForAlpha3d::Filtration_value;
+ return create_complex(complex, std::numeric_limits<Filtration_value>::infinity());
+ }
+
+ /** \brief Inserts all Delaunay triangulation into the simplicial complex.
+ * It also computes the filtration values accordingly to the \ref createcomplexalgorithm
+ *
+ * \tparam SimplicialComplexForAlpha3d must meet `SimplicialComplexForAlpha3d` concept.
+ *
+ * @param[in] complex SimplicialComplexForAlpha3d to be created.
+ * @param[in] max_alpha_square maximum for alpha square value. Default value is +\f$\infty\f$.
+ *
+ * @return true if creation succeeds, false otherwise.
+ *
+ * @pre The simplicial complex must be empty (no vertices)
+ *
+ * Initialization can be launched once.
+ */
+ template <typename SimplicialComplexForAlpha3d>
+ bool create_complex(SimplicialComplexForAlpha3d& complex,
+ typename SimplicialComplexForAlpha3d::Filtration_value max_alpha_square) {
+ if (complex.num_vertices() > 0) {
+ std::cerr << "Alpha_complex_3d create_complex - complex is not empty\n";
+ return false; // ----- >>
+ }
+
+ using Filtration_value = typename SimplicialComplexForAlpha3d::Filtration_value;
+ using Complex_vertex_handle = typename SimplicialComplexForAlpha3d::Vertex_handle;
+ using Alpha_shape_simplex_tree_map = std::map<Alpha_vertex_handle,
+ Complex_vertex_handle>;
+ using Simplex_tree_vector_vertex = std::vector<Complex_vertex_handle>;
+
+#ifdef DEBUG_TRACES
+ std::size_t count_vertices = 0;
+ std::size_t count_edges = 0;
+ std::size_t count_facets = 0;
+ std::size_t count_cells = 0;
+#endif // DEBUG_TRACES
+
+ Alpha_shape_simplex_tree_map map_cgal_simplex_tree;
+ auto the_alpha_value_iterator = alpha_values_.begin();
+ for (auto object_iterator : objects_) {
+ Vertex_list vertex_list;
+
+ // Retrieve Alpha shape vertex list from object
+ if (const Cell_handle *cell = CGAL::object_cast<Cell_handle>(&object_iterator)) {
+ for (auto i = 0; i < 4; i++) {
+#ifdef DEBUG_TRACES
+ std::cout << "from cell[" << i << "]=" << (*cell)->vertex(i)->point() << std::endl;
+#endif // DEBUG_TRACES
+ vertex_list.push_back((*cell)->vertex(i));
+ }
+#ifdef DEBUG_TRACES
+ count_cells++;
+#endif // DEBUG_TRACES
+ } else if (const Facet *facet = CGAL::object_cast<Facet>(&object_iterator)) {
+ for (auto i = 0; i < 4; i++) {
+ if ((*facet).second != i) {
+#ifdef DEBUG_TRACES
+ std::cout << "from facet=[" << i << "]" << (*facet).first->vertex(i)->point() << std::endl;
+#endif // DEBUG_TRACES
+ vertex_list.push_back((*facet).first->vertex(i));
+ }
+ }
+#ifdef DEBUG_TRACES
+ count_facets++;
+#endif // DEBUG_TRACES
+ } else if (const Edge *edge = CGAL::object_cast<Edge>(&object_iterator)) {
+ for (auto i : {(*edge).second, (*edge).third}) {
+#ifdef DEBUG_TRACES
+ std::cout << "from edge[" << i << "]=" << (*edge).first->vertex(i)->point() << std::endl;
+#endif // DEBUG_TRACES
+ vertex_list.push_back((*edge).first->vertex(i));
+ }
+#ifdef DEBUG_TRACES
+ count_edges++;
+#endif // DEBUG_TRACES
+ } else if (const Alpha_vertex_handle *vertex = CGAL::object_cast<Alpha_vertex_handle>(&object_iterator)) {
+#ifdef DEBUG_TRACES
+ count_vertices++;
+ std::cout << "from vertex=" << (*vertex)->point() << std::endl;
+#endif // DEBUG_TRACES
+ vertex_list.push_back((*vertex));
+ }
+ // Construction of the vector of simplex_tree vertex from list of alpha_shapes vertex
+ Simplex_tree_vector_vertex the_simplex;
+ for (auto the_alpha_shape_vertex : vertex_list) {
+ auto the_map_iterator = map_cgal_simplex_tree.find(the_alpha_shape_vertex);
+ if (the_map_iterator == map_cgal_simplex_tree.end()) {
+ // alpha shape not found
+ Complex_vertex_handle vertex = map_cgal_simplex_tree.size();
+#ifdef DEBUG_TRACES
+ std::cout << "vertex [" << the_alpha_shape_vertex->point() << "] not found - insert " << vertex << std::endl;
+#endif // DEBUG_TRACES
+ the_simplex.push_back(vertex);
+ map_cgal_simplex_tree.emplace(the_alpha_shape_vertex, vertex);
+ } else {
+ // alpha shape found
+ Complex_vertex_handle vertex = the_map_iterator->second;
+#ifdef DEBUG_TRACES
+ std::cout << "vertex [" << the_alpha_shape_vertex->point() << "] found in " << vertex << std::endl;
+#endif // DEBUG_TRACES
+ the_simplex.push_back(vertex);
+ }
+ }
+ // Construction of the simplex_tree
+ //Alpha_value_type filtr;
+ Filtration_value filtr =
+ AlphaComplex3dOptions::template value_from_iterator<Filtration_value,
+ typename std::vector<Alpha_value_type>::iterator>
+ (the_alpha_value_iterator);
+#ifdef DEBUG_TRACES
+ std::cout << "filtration = " << filtr << std::endl;
+#endif // DEBUG_TRACES
+ complex.insert_simplex(the_simplex, static_cast<Filtration_value>(filtr));
+ GUDHI_CHECK(the_alpha_value_iterator != alpha_values_.end(), "CGAL provided more simplices than values");
+ ++the_alpha_value_iterator;
+ }
+
+#ifdef DEBUG_TRACES
+ std::cout << "vertices \t" << count_vertices << std::endl;
+ std::cout << "edges \t\t" << count_edges << std::endl;
+ std::cout << "facets \t\t" << count_facets << std::endl;
+ std::cout << "cells \t\t" << count_cells << std::endl;
+#endif // DEBUG_TRACES
+ // --------------------------------------------------------------------------------------------
+ // As Alpha value is an approximation, we have to make filtration non decreasing while increasing the dimension
+ complex.make_filtration_non_decreasing();
+ // Remove all simplices that have a filtration value greater than max_alpha_square
+ complex.prune_above_filtration(max_alpha_square);
+ // --------------------------------------------------------------------------------------------
+ return true;
+ }
+
+private:
+ // Needs to store alpha_shape_3_ptr_ as objects_ and alpha_shape_3_ptr_ are freed with alpha_shape_3_ptr_
+ std::unique_ptr<Alpha_shape_3> alpha_shape_3_ptr_;
+ std::vector<CGAL::Object> objects_;
+ std::vector<Alpha_value_type> alpha_values_;
+
+};
+
+} // namespace alpha_complex
+
+} // namespace Gudhi
+
+#endif // ALPHA_COMPLEX_3D_H_
diff --git a/src/Alpha_complex/include/gudhi/Alpha_complex_3d_options.h b/src/Alpha_complex/include/gudhi/Alpha_complex_3d_options.h
new file mode 100644
index 00000000..567b19cb
--- /dev/null
+++ b/src/Alpha_complex/include/gudhi/Alpha_complex_3d_options.h
@@ -0,0 +1,179 @@
+/* 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 <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef ALPHA_COMPLEX_3D_OPTIONS_H_
+#define ALPHA_COMPLEX_3D_OPTIONS_H_
+
+
+#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
+#include <CGAL/Delaunay_triangulation_3.h>
+#include <CGAL/Periodic_3_Delaunay_triangulation_traits_3.h>
+#include <CGAL/Periodic_3_Delaunay_triangulation_3.h>
+#include <CGAL/Periodic_3_regular_triangulation_traits_3.h>
+#include <CGAL/Periodic_3_regular_triangulation_3.h>
+#include <CGAL/Regular_triangulation_3.h>
+#include <CGAL/Alpha_shape_3.h>
+#include <CGAL/Alpha_shape_cell_base_3.h>
+#include <CGAL/Alpha_shape_vertex_base_3.h>
+
+
+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<Kernel>;
+ using Fb = CGAL::Alpha_shape_cell_base_3<Kernel>;
+ using Tds = CGAL::Triangulation_data_structure_3<Vb, Fb>;
+ using Triangulation_3 = CGAL::Delaunay_triangulation_3<Kernel, Tds>;
+
+public:
+ using Alpha_shape_3 = CGAL::Alpha_shape_3<Triangulation_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<class Filtration_value, class Alpha_value_iterator>
+ 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<Kernel, CGAL::Default, Exact_tag>;
+ using Fb = CGAL::Alpha_shape_cell_base_3<Kernel, CGAL::Default, Exact_tag>;
+ using Tds = CGAL::Triangulation_data_structure_3<Vb, Fb>;
+ using Triangulation_3 = CGAL::Delaunay_triangulation_3<Kernel, Tds>;
+
+public:
+ using Alpha_shape_3 = CGAL::Alpha_shape_3<Triangulation_3, Exact_tag>;
+ 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<class Filtration_value, class Alpha_value_iterator>
+ 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<Kernel>;
+ using Vb = CGAL::Alpha_shape_vertex_base_3<Kernel, Rvb>;
+ using Rcb = CGAL::Regular_triangulation_cell_base_3<Kernel>;
+ using Cb = CGAL::Alpha_shape_cell_base_3<Kernel, Rcb>;
+ using Tds = CGAL::Triangulation_data_structure_3<Vb, Cb>;
+ using Triangulation_3 = CGAL::Regular_triangulation_3<Kernel, Tds>;
+
+
+public:
+ using Alpha_shape_3 = CGAL::Alpha_shape_3<Triangulation_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<class Filtration_value, class Alpha_value_iterator>
+ 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<K>;
+// Vertex type
+ using DsVb = CGAL::Periodic_3_triangulation_ds_vertex_base_3<>;
+ using Vb = CGAL::Triangulation_vertex_base_3<PK, DsVb>;
+ using AsVb = CGAL::Alpha_shape_vertex_base_3<PK, Vb>;
+// Cell type
+ using DsCb = CGAL::Periodic_3_triangulation_ds_cell_base_3<>;
+ using Cb = CGAL::Triangulation_cell_base_3<PK, DsCb>;
+ using AsCb = CGAL::Alpha_shape_cell_base_3<PK, Cb>;
+ using Tds = CGAL::Triangulation_data_structure_3<AsVb, AsCb>;
+
+public:
+ using Periodic_delaunay_triangulation_3 = CGAL::Periodic_3_Delaunay_triangulation_3<PK, Tds>;
+ using Alpha_shape_3 = CGAL::Alpha_shape_3<Periodic_delaunay_triangulation_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<class Filtration_value, class Alpha_value_iterator>
+ 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<Kernel>;
+ using DsVb = CGAL::Periodic_3_triangulation_ds_vertex_base_3<>;
+ using Vb = CGAL::Regular_triangulation_vertex_base_3<Periodic_kernel, DsVb>;
+ using AsVb = CGAL::Alpha_shape_vertex_base_3<Periodic_kernel, Vb>;
+ using DsCb = CGAL::Periodic_3_triangulation_ds_cell_base_3<>;
+ using Cb = CGAL::Regular_triangulation_cell_base_3<Periodic_kernel, DsCb>;
+ using AsCb = CGAL::Alpha_shape_cell_base_3<Periodic_kernel, Cb>;
+ using Tds = CGAL::Triangulation_data_structure_3<AsVb, AsCb>;
+
+public:
+ using Periodic_delaunay_triangulation_3 = CGAL::Periodic_3_regular_triangulation_3<Periodic_kernel, Tds>;
+ using Alpha_shape_3 = CGAL::Alpha_shape_3<Periodic_delaunay_triangulation_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<class Filtration_value, class Alpha_value_iterator>
+ 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/test/Alpha_complex_3d_unit_test.cpp b/src/Alpha_complex/test/Alpha_complex_3d_unit_test.cpp
new file mode 100644
index 00000000..7873deca
--- /dev/null
+++ b/src/Alpha_complex/test/Alpha_complex_3d_unit_test.cpp
@@ -0,0 +1,663 @@
+/* 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) 2015 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 <http://www.gnu.org/licenses/>.
+ */
+
+#define BOOST_TEST_DYN_LINK
+#define BOOST_TEST_MODULE "alpha_complex_3d"
+#include <boost/test/unit_test.hpp>
+#include <boost/mpl/list.hpp>
+
+#include <cmath> // float comparison
+#include <limits>
+#include <string>
+#include <vector>
+#include <random>
+
+#include <gudhi/Alpha_complex_3d.h>
+#include <gudhi/Alpha_complex_3d_options.h>
+// to construct a simplex_tree from Delaunay_triangulation
+#include <gudhi/graph_simplicial_complex.h>
+#include <gudhi/Simplex_tree.h>
+#include <gudhi/Unitary_tests_utils.h>
+#include <gudhi/Points_3D_off_io.h>
+
+using Alpha_shapes_3d = Gudhi::alpha_complex::Alpha_shapes_3d;
+using Exact_alpha_shapes_3d = Gudhi::alpha_complex::Exact_alpha_shapes_3d;
+using Weighted_alpha_shapes_3d = Gudhi::alpha_complex::Weighted_alpha_shapes_3d;
+using Periodic_alpha_shapes_3d = Gudhi::alpha_complex::Periodic_alpha_shapes_3d;
+using Weighted_periodic_alpha_shapes_3d = Gudhi::alpha_complex::Weighted_periodic_alpha_shapes_3d;
+
+BOOST_AUTO_TEST_CASE(Alpha_complex_3d_from_points) {
+ // -----------------
+ // Non exact version
+ // -----------------
+ std::cout << "Alpha complex 3d" << std::endl;
+ std::vector<Alpha_shapes_3d::Point_3> points;
+ points.push_back(Alpha_shapes_3d::Point_3(0.0, 0.0, 0.0));
+ points.push_back(Alpha_shapes_3d::Point_3(0.0, 0.0, 0.2));
+ points.push_back(Alpha_shapes_3d::Point_3(0.2, 0.0, 0.2));
+ points.push_back(Alpha_shapes_3d::Point_3(0.6, 0.6, 0.0));
+ points.push_back(Alpha_shapes_3d::Point_3(0.8, 0.8, 0.2));
+ points.push_back(Alpha_shapes_3d::Point_3(0.2, 0.8, 0.6));
+
+ Gudhi::alpha_complex::Alpha_complex_3d<Alpha_shapes_3d> alpha_complex(points);
+
+ Gudhi::Simplex_tree<> stree;
+ alpha_complex.create_complex(stree);
+
+ // -----------------
+ // Exact version
+ // -----------------
+ std::cout << "Exact alpha complex 3d" << std::endl;
+ using Exact_alpha_shapes_3d = Gudhi::alpha_complex::Exact_alpha_shapes_3d;
+
+ Gudhi::alpha_complex::Alpha_complex_3d<Exact_alpha_shapes_3d> exact_alpha_complex(points);
+
+ Gudhi::Simplex_tree<> exact_stree;
+ exact_alpha_complex.create_complex(exact_stree);
+
+ // ---------------------
+ // Compare both versions
+ // ---------------------
+ std::cout << "Exact Alpha complex 3d is of dimension " << exact_stree.dimension()
+ << " - Non exact is " << stree.dimension() << std::endl;
+ BOOST_CHECK(exact_stree.dimension() == stree.dimension());
+ std::cout << "Exact Alpha complex 3d num_simplices " << exact_stree.num_simplices()
+ << " - Non exact is " << stree.num_simplices() << std::endl;
+ BOOST_CHECK(exact_stree.num_simplices() == stree.num_simplices());
+ std::cout << "Exact Alpha complex 3d num_vertices " << exact_stree.num_vertices()
+ << " - Non exact is " << stree.num_vertices() << std::endl;
+ BOOST_CHECK(exact_stree.num_vertices() == stree.num_vertices());
+
+ auto sh = stree.filtration_simplex_range().begin();
+ auto sh_exact = exact_stree.filtration_simplex_range().begin();
+ while(sh != stree.filtration_simplex_range().end() && sh_exact != exact_stree.filtration_simplex_range().end()) {
+ std::vector<int> simplex;
+ std::vector<int> exact_simplex;
+ std::cout << "Non-exact ( ";
+ for (auto vertex : stree.simplex_vertex_range(*sh)) {
+ simplex.push_back(vertex);
+ std::cout << vertex << " ";
+ }
+ std::cout << ") -> " << "[" << stree.filtration(*sh) << "] ";
+ std::cout << std::endl;
+ std::cout << "Exact ( ";
+ for (auto vertex : exact_stree.simplex_vertex_range(*sh_exact)) {
+ exact_simplex.push_back(vertex);
+ std::cout << vertex << " ";
+ }
+ std::cout << ") -> " << "[" << exact_stree.filtration(*sh_exact) << "] ";
+ std::cout << std::endl;
+ BOOST_CHECK(exact_simplex == simplex);
+
+ // Exact and non-exact version is not exactly the same due to float comparison
+ GUDHI_TEST_FLOAT_EQUALITY_CHECK(exact_stree.filtration(*sh_exact), stree.filtration(*sh));
+ ++sh;
+ ++sh_exact;
+ }
+}
+
+#ifdef GUDHI_DEBUG
+BOOST_AUTO_TEST_CASE(Alpha_complex_weighted_throw) {
+ std::vector<Weighted_alpha_shapes_3d::Point_3> w_points;
+ w_points.push_back(Weighted_alpha_shapes_3d::Point_3(0.0, 0.0, 0.0));
+ w_points.push_back(Weighted_alpha_shapes_3d::Point_3(0.0, 0.0, 0.2));
+ w_points.push_back(Weighted_alpha_shapes_3d::Point_3(0.2, 0.0, 0.2));
+ // w_points.push_back(Weighted_alpha_shapes_3d::Point_3(0.6, 0.6, 0.0));
+ // w_points.push_back(Weighted_alpha_shapes_3d::Point_3(0.8, 0.8, 0.2));
+ // w_points.push_back(Weighted_alpha_shapes_3d::Point_3(0.2, 0.8, 0.6));
+
+ // weights size is different from w_points size to make weighted Alpha_complex_3d throw in debug mode
+ std::vector<double> weights = {0.01, 0.005, 0.006, 0.01, 0.009, 0.001};
+
+ std::cout << "Check exception throw in debug mode" << std::endl;
+ BOOST_CHECK_THROW (Gudhi::alpha_complex::Alpha_complex_3d<Weighted_alpha_shapes_3d> wac(w_points, weights),
+ std::invalid_argument);
+}
+#endif
+
+BOOST_AUTO_TEST_CASE(Alpha_complex_weighted) {
+ std::cout << "Weighted alpha complex 3d" << std::endl;
+ using Weighted_alpha_shapes_3d = Gudhi::alpha_complex::Weighted_alpha_shapes_3d;
+ std::vector<Weighted_alpha_shapes_3d::Point_3> w_points;
+ w_points.push_back(Weighted_alpha_shapes_3d::Point_3(0.0, 0.0, 0.0));
+ w_points.push_back(Weighted_alpha_shapes_3d::Point_3(0.0, 0.0, 0.2));
+ w_points.push_back(Weighted_alpha_shapes_3d::Point_3(0.2, 0.0, 0.2));
+ w_points.push_back(Weighted_alpha_shapes_3d::Point_3(0.6, 0.6, 0.0));
+ w_points.push_back(Weighted_alpha_shapes_3d::Point_3(0.8, 0.8, 0.2));
+ w_points.push_back(Weighted_alpha_shapes_3d::Point_3(0.2, 0.8, 0.6));
+
+ // weights size is different from w_points size to make weighted Alpha_complex_3d throw in debug mode
+ std::vector<double> weights = {0.01, 0.005, 0.006, 0.01, 0.009, 0.001};
+
+ Gudhi::alpha_complex::Alpha_complex_3d<Weighted_alpha_shapes_3d> weighted_alpha_complex(w_points, weights);
+ Gudhi::Simplex_tree<> w_stree;
+ weighted_alpha_complex.create_complex(w_stree);
+
+ std::cout << "Weighted Alpha complex 3d is of dimension " << w_stree.dimension() << std::endl;
+ BOOST_CHECK(w_stree.dimension() == 3);
+ std::cout << " num_simplices " << w_stree.num_simplices() << std::endl;
+ BOOST_CHECK(w_stree.num_simplices() == 35);
+ std::cout << " num_vertices " << w_stree.num_vertices() << std::endl;
+ BOOST_CHECK(w_stree.num_vertices() == 6);
+}
+
+#ifdef GUDHI_DEBUG
+BOOST_AUTO_TEST_CASE(Alpha_complex_periodic_throw) {
+ std::cout << "Periodic alpha complex 3d exception throw" << std::endl;
+ std::vector<Periodic_alpha_shapes_3d::Point_3> p_points;
+
+ // Not important, this is not what we want to check
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.0, 0.0));
+
+ std::cout << "Check exception throw in debug mode" << std::endl;
+ using Periodic_alpha_complex_3d = Gudhi::alpha_complex::Alpha_complex_3d<Periodic_alpha_shapes_3d>;
+ // Check it throws an exception when the cuboid is not iso
+ BOOST_CHECK_THROW (Periodic_alpha_complex_3d periodic_alpha_complex(p_points, 0., 0., 0., 0.9, 1., 1.),
+ std::invalid_argument);
+ BOOST_CHECK_THROW (Periodic_alpha_complex_3d periodic_alpha_complex(p_points, 0., 0., 0., 1., 0.9, 1.),
+ std::invalid_argument);
+ BOOST_CHECK_THROW (Periodic_alpha_complex_3d periodic_alpha_complex(p_points, 0., 0., 0., 1., 1., 0.9),
+ std::invalid_argument);
+
+}
+#endif
+
+BOOST_AUTO_TEST_CASE(Alpha_complex_periodic) {
+ std::cout << "Periodic alpha complex 3d" << std::endl;
+ std::vector<Periodic_alpha_shapes_3d::Point_3> p_points;
+
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.0, 0.0));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.0, 0.2));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.0, 0.4));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.0, 0.6));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.0, 0.8));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.2, 0.0));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.2, 0.2));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.2, 0.4));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.2, 0.6));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.2, 0.8));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.4, 0.0));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.4, 0.2));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.4, 0.4));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.4, 0.6));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.4, 0.8));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.6, 0.0));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.6, 0.2));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.6, 0.4));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.6, 0.6));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.6, 0.8));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.8, 0.0));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.8, 0.2));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.8, 0.4));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.8, 0.6));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.8, 0.8));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.0, 0.0));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.0, 0.2));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.0, 0.4));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.0, 0.6));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.0, 0.8));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.2, 0.0));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.2, 0.2));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.2, 0.4));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.2, 0.6));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.2, 0.8));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.4, 0.0));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.4, 0.2));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.4, 0.4));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.4, 0.6));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.4, 0.8));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.6, 0.0));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.6, 0.2));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.6, 0.4));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.6, 0.6));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.6, 0.8));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.8, 0.0));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.8, 0.2));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.8, 0.4));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.8, 0.6));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.8, 0.8));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.0, 0.0));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.0, 0.2));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.0, 0.4));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.0, 0.6));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.0, 0.8));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.2, 0.0));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.2, 0.2));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.2, 0.4));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.2, 0.6));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.2, 0.8));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.4, 0.0));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.4, 0.2));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.4, 0.4));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.4, 0.6));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.4, 0.8));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.6, 0.0));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.6, 0.2));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.6, 0.4));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.6, 0.6));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.6, 0.8));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.8, 0.0));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.8, 0.2));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.8, 0.4));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.8, 0.6));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.8, 0.8));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.0, 0.0));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.0, 0.2));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.0, 0.4));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.0, 0.6));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.0, 0.8));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.1, 0.0));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.2, 0.0));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.2, 0.2));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.2, 0.4));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.2, 0.6));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.2, 0.8));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.4, 0.0));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.4, 0.2));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.4, 0.4));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.4, 0.6));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.4, 0.8));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.6, 0.0));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.6, 0.2));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.6, 0.4));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.6, 0.6));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.6, 0.8));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.8, 0.0));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.8, 0.2));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.8, 0.4));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.8, 0.6));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.8, 0.8));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.0, 0.0));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.0, 0.2));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.0, 0.4));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.0, 0.6));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.0, 0.8));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.2, 0.0));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.2, 0.2));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.2, 0.4));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.2, 0.6));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.2, 0.8));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.4, 0.0));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.4, 0.2));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.4, 0.4));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.4, 0.6));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.4, 0.8));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.6, 0.0));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.6, 0.2));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.6, 0.4));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.6, 0.6));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.6, 0.8));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.8, 0.0));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.8, 0.2));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.8, 0.4));
+ p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.8, 0.6));
+
+ Gudhi::alpha_complex::Alpha_complex_3d<Periodic_alpha_shapes_3d> periodic_alpha_complex(p_points,
+ 0., 0., 0.,
+ 1., 1., 1.);
+
+ Gudhi::Simplex_tree<> p_stree;
+ periodic_alpha_complex.create_complex(p_stree);
+
+ std::cout << "Periodic Alpha complex 3d is of dimension " << p_stree.dimension() << std::endl;
+ BOOST_CHECK(p_stree.dimension() == 3);
+ std::cout << " num_simplices " << p_stree.num_simplices() << std::endl;
+ BOOST_CHECK(p_stree.num_simplices() == 3266);
+ std::cout << " num_vertices " << p_stree.num_vertices() << std::endl;
+ BOOST_CHECK(p_stree.num_vertices() == 125);
+
+}
+
+#ifdef GUDHI_DEBUG
+BOOST_AUTO_TEST_CASE(Alpha_complex_weighted_periodic_throw) {
+ std::cout << "Weighted periodic alpha complex 3d exception throw" << std::endl;
+
+ std::vector<Weighted_periodic_alpha_shapes_3d::Point_3> wp_points;
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.0, 0.0));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.0, 0.2));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.0, 0.4));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.0, 0.6));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.0, 0.8));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.2, 0.0));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.2, 0.2));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.2, 0.4));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.2, 0.6));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.2, 0.8));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.4, 0.0));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.4, 0.2));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.4, 0.4));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.4, 0.6));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.4, 0.8));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.6, 0.0));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.6, 0.2));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.6, 0.4));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.6, 0.6));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.6, 0.8));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.8, 0.0));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.8, 0.2));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.8, 0.4));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.8, 0.6));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.8, 0.8));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.0, 0.0));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.0, 0.2));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.0, 0.4));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.0, 0.6));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.0, 0.8));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.2, 0.0));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.2, 0.2));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.2, 0.4));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.2, 0.6));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.2, 0.8));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.4, 0.0));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.4, 0.2));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.4, 0.4));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.4, 0.6));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.4, 0.8));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.6, 0.0));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.6, 0.2));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.6, 0.4));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.6, 0.6));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.6, 0.8));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.8, 0.0));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.8, 0.2));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.8, 0.4));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.8, 0.6));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.8, 0.8));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.0, 0.0));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.0, 0.2));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.0, 0.4));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.0, 0.6));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.0, 0.8));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.2, 0.0));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.2, 0.2));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.2, 0.4));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.2, 0.6));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.2, 0.8));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.4, 0.0));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.4, 0.2));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.4, 0.4));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.4, 0.6));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.4, 0.8));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.6, 0.0));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.6, 0.2));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.6, 0.4));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.6, 0.6));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.6, 0.8));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.8, 0.0));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.8, 0.2));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.8, 0.4));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.8, 0.6));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.8, 0.8));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.0, 0.0));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.0, 0.2));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.0, 0.4));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.0, 0.6));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.0, 0.8));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.1, 0.0));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.2, 0.0));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.2, 0.2));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.2, 0.4));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.2, 0.6));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.2, 0.8));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.4, 0.0));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.4, 0.2));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.4, 0.4));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.4, 0.6));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.4, 0.8));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.6, 0.0));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.6, 0.2));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.6, 0.4));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.6, 0.6));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.6, 0.8));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.8, 0.0));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.8, 0.2));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.8, 0.4));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.8, 0.6));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.8, 0.8));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.0, 0.0));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.0, 0.2));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.0, 0.4));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.0, 0.6));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.0, 0.8));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.2, 0.0));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.2, 0.2));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.2, 0.4));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.2, 0.6));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.2, 0.8));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.4, 0.0));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.4, 0.2));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.4, 0.4));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.4, 0.6));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.4, 0.8));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.6, 0.0));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.6, 0.2));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.6, 0.4));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.6, 0.6));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.6, 0.8));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.8, 0.0));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.8, 0.2));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.8, 0.4));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.8, 0.6));
+
+ std::vector<double> p_weights;
+
+ std::random_device rd;
+ std::mt19937 mt(rd());
+ // Weights must be in range [0, <1/64]
+ std::uniform_real_distribution<double> dist(0.0, 0.0156245);
+
+ for (std::size_t i = 0; i < wp_points.size(); ++i) {
+ double value = dist(mt);
+ p_weights.push_back(value);
+ }
+
+ std::cout << "Cuboid is not iso exception" << std::endl;
+ using Weighted_periodic_alpha_complex_3d = Gudhi::alpha_complex::Alpha_complex_3d<Weighted_periodic_alpha_shapes_3d>;
+ // Check it throws an exception when the cuboid is not iso
+ BOOST_CHECK_THROW (Weighted_periodic_alpha_complex_3d periodic_alpha_complex(wp_points, p_weights, 0., 0., 0., 0.9, 1., 1.),
+ std::invalid_argument);
+ BOOST_CHECK_THROW (Weighted_periodic_alpha_complex_3d periodic_alpha_complex(wp_points, p_weights, 0., 0., 0., 1., 0.9, 1.),
+ std::invalid_argument);
+ BOOST_CHECK_THROW (Weighted_periodic_alpha_complex_3d periodic_alpha_complex(wp_points, p_weights, 0., 0., 0., 1., 1., 0.9),
+ std::invalid_argument);
+
+ std::cout << "0 <= point.weight() < 1/64 * domain_size * domain_size exception" << std::endl;
+ // Weights must be in range [0, <1/64]
+ p_weights[25] = 1.0;
+ BOOST_CHECK_THROW (Weighted_periodic_alpha_complex_3d periodic_alpha_complex(wp_points, p_weights, 0., 0., 0., 1., 1., 1.),
+ std::invalid_argument);
+ // Weights must be in range [0, <1/64]
+ p_weights[25] = 0.012;
+ p_weights[14] = -0.012;
+ BOOST_CHECK_THROW (Weighted_periodic_alpha_complex_3d periodic_alpha_complex(wp_points, p_weights, 0., 0., 0., 1., 1., 1.),
+ std::invalid_argument);
+ p_weights[14] = 0.005;
+
+ std::cout << "wp_points and p_weights size exception" << std::endl;
+ // Weights and points must have the same size
+ // + 1
+ p_weights.push_back(0.007);
+ BOOST_CHECK_THROW (Weighted_periodic_alpha_complex_3d periodic_alpha_complex(wp_points, p_weights, 0., 0., 0., 1., 1., 1.),
+ std::invalid_argument);
+ // - 1
+ p_weights.pop_back();
+ p_weights.pop_back();
+ BOOST_CHECK_THROW (Weighted_periodic_alpha_complex_3d periodic_alpha_complex(wp_points, p_weights, 0., 0., 0., 1., 1., 1.),
+ std::invalid_argument);
+}
+#endif
+
+BOOST_AUTO_TEST_CASE(Alpha_complex_weighted_periodic) {
+ std::cout << "Weighted periodic alpha complex 3d" << std::endl;
+
+ std::vector<Weighted_periodic_alpha_shapes_3d::Point_3> wp_points;
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.0, 0.0));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.0, 0.2));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.0, 0.4));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.0, 0.6));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.0, 0.8));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.2, 0.0));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.2, 0.2));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.2, 0.4));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.2, 0.6));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.2, 0.8));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.4, 0.0));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.4, 0.2));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.4, 0.4));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.4, 0.6));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.4, 0.8));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.6, 0.0));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.6, 0.2));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.6, 0.4));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.6, 0.6));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.6, 0.8));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.8, 0.0));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.8, 0.2));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.8, 0.4));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.8, 0.6));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.8, 0.8));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.0, 0.0));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.0, 0.2));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.0, 0.4));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.0, 0.6));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.0, 0.8));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.2, 0.0));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.2, 0.2));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.2, 0.4));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.2, 0.6));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.2, 0.8));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.4, 0.0));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.4, 0.2));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.4, 0.4));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.4, 0.6));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.4, 0.8));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.6, 0.0));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.6, 0.2));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.6, 0.4));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.6, 0.6));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.6, 0.8));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.8, 0.0));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.8, 0.2));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.8, 0.4));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.8, 0.6));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.8, 0.8));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.0, 0.0));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.0, 0.2));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.0, 0.4));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.0, 0.6));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.0, 0.8));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.2, 0.0));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.2, 0.2));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.2, 0.4));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.2, 0.6));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.2, 0.8));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.4, 0.0));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.4, 0.2));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.4, 0.4));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.4, 0.6));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.4, 0.8));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.6, 0.0));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.6, 0.2));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.6, 0.4));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.6, 0.6));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.6, 0.8));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.8, 0.0));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.8, 0.2));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.8, 0.4));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.8, 0.6));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.8, 0.8));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.0, 0.0));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.0, 0.2));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.0, 0.4));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.0, 0.6));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.0, 0.8));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.1, 0.0));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.2, 0.0));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.2, 0.2));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.2, 0.4));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.2, 0.6));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.2, 0.8));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.4, 0.0));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.4, 0.2));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.4, 0.4));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.4, 0.6));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.4, 0.8));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.6, 0.0));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.6, 0.2));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.6, 0.4));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.6, 0.6));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.6, 0.8));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.8, 0.0));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.8, 0.2));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.8, 0.4));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.8, 0.6));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.8, 0.8));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.0, 0.0));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.0, 0.2));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.0, 0.4));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.0, 0.6));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.0, 0.8));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.2, 0.0));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.2, 0.2));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.2, 0.4));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.2, 0.6));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.2, 0.8));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.4, 0.0));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.4, 0.2));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.4, 0.4));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.4, 0.6));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.4, 0.8));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.6, 0.0));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.6, 0.2));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.6, 0.4));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.6, 0.6));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.6, 0.8));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.8, 0.0));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.8, 0.2));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.8, 0.4));
+ wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.8, 0.6));
+
+ std::vector<double> p_weights;
+
+ std::random_device rd;
+ std::mt19937 mt(rd());
+ // Weights must be in range [0, <1/64]
+ std::uniform_real_distribution<double> dist(0.01, 0.0156245);
+
+ for (std::size_t i = 0; i < wp_points.size(); ++i) {
+ double value = dist(mt);
+ p_weights.push_back(value);
+ }
+
+ using Weighted_periodic_alpha_complex_3d = Gudhi::alpha_complex::Alpha_complex_3d<Weighted_periodic_alpha_shapes_3d>;
+ Weighted_periodic_alpha_complex_3d weighted_periodic_alpha_complex(wp_points, p_weights, 0., 0., 0., 1., 1., 1.);
+
+ Gudhi::Simplex_tree<> wp_stree;
+ weighted_periodic_alpha_complex.create_complex(wp_stree);
+
+ std::cout << "Weighted periodic Alpha complex 3d is of dimension " << wp_stree.dimension() << std::endl;
+ BOOST_CHECK(wp_stree.dimension() == 3);
+ std::cout << " num_simplices " << wp_stree.num_simplices() << std::endl;
+ BOOST_CHECK(wp_stree.num_simplices() >= 3100);
+ std::cout << " num_vertices " << wp_stree.num_vertices() << std::endl;
+ BOOST_CHECK(wp_stree.num_vertices() == 125);
+}
diff --git a/src/Alpha_complex/test/CMakeLists.txt b/src/Alpha_complex/test/CMakeLists.txt
index 9255d3db..7b6de748 100644
--- a/src/Alpha_complex/test/CMakeLists.txt
+++ b/src/Alpha_complex/test/CMakeLists.txt
@@ -9,10 +9,17 @@ if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.7.0)
target_link_libraries(Alpha_complex_test_unit ${TBB_LIBRARIES})
endif()
+ add_executable ( Alpha_complex_3d_test_unit Alpha_complex_3d_unit_test.cpp )
+ target_link_libraries(Alpha_complex_3d_test_unit ${CGAL_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
+ if (TBB_FOUND)
+ target_link_libraries(Alpha_complex_3d_test_unit ${TBB_LIBRARIES})
+ endif()
+
# Do not forget to copy test files in current binary dir
file(COPY "${CMAKE_SOURCE_DIR}/data/points/alphacomplexdoc.off" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/)
gudhi_add_coverage_test(Alpha_complex_test_unit)
+ gudhi_add_coverage_test(Alpha_complex_3d_test_unit)
endif (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.7.0)
diff --git a/src/Alpha_complex/utilities/CMakeLists.txt b/src/Alpha_complex/utilities/CMakeLists.txt
index 7ace6064..13476ba5 100644
--- a/src/Alpha_complex/utilities/CMakeLists.txt
+++ b/src/Alpha_complex/utilities/CMakeLists.txt
@@ -1,64 +1,58 @@
project(Alpha_complex_utilities)
if(CGAL_FOUND)
- add_executable(alpha_complex_3d_persistence alpha_complex_3d_persistence.cpp)
- target_link_libraries(alpha_complex_3d_persistence ${CGAL_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY})
- add_executable(exact_alpha_complex_3d_persistence exact_alpha_complex_3d_persistence.cpp)
- target_link_libraries(exact_alpha_complex_3d_persistence ${CGAL_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY})
- add_executable(weighted_alpha_complex_3d_persistence weighted_alpha_complex_3d_persistence.cpp)
- target_link_libraries(weighted_alpha_complex_3d_persistence ${CGAL_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY})
-
- if (TBB_FOUND)
- target_link_libraries(alpha_complex_3d_persistence ${TBB_LIBRARIES})
- target_link_libraries(exact_alpha_complex_3d_persistence ${TBB_LIBRARIES})
- target_link_libraries(weighted_alpha_complex_3d_persistence ${TBB_LIBRARIES})
- endif(TBB_FOUND)
-
- add_test(NAME Alpha_complex_utilities_alpha_complex_3d_persistence COMMAND $<TARGET_FILE:alpha_complex_3d_persistence>
- "${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off" "-p" "2" "-m" "0.45")
- add_test(NAME Alpha_complex_utilities_exact_alpha_complex_3d COMMAND $<TARGET_FILE:exact_alpha_complex_3d_persistence>
- "${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off" "-p" "2" "-m" "0.45")
- add_test(NAME Alpha_complex_utilities_weighted_alpha_complex_3d COMMAND $<TARGET_FILE:weighted_alpha_complex_3d_persistence>
- "${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off" "${CMAKE_SOURCE_DIR}/data/points/tore3D_300.weights" "-p" "2" "-m" "0.45")
-
- install(TARGETS alpha_complex_3d_persistence DESTINATION bin)
- install(TARGETS exact_alpha_complex_3d_persistence DESTINATION bin)
- install(TARGETS weighted_alpha_complex_3d_persistence DESTINATION bin)
-
if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.7.0)
add_executable (alpha_complex_persistence alpha_complex_persistence.cpp)
target_link_libraries(alpha_complex_persistence ${CGAL_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY})
- add_executable(periodic_alpha_complex_3d_persistence periodic_alpha_complex_3d_persistence.cpp)
- target_link_libraries(periodic_alpha_complex_3d_persistence ${CGAL_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY})
-
if (TBB_FOUND)
target_link_libraries(alpha_complex_persistence ${TBB_LIBRARIES})
- target_link_libraries(periodic_alpha_complex_3d_persistence ${TBB_LIBRARIES})
endif(TBB_FOUND)
add_test(NAME Alpha_complex_utilities_alpha_complex_persistence COMMAND $<TARGET_FILE:alpha_complex_persistence>
"${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off" "-p" "2" "-m" "0.45")
- add_test(NAME Alpha_complex_utilities_periodic_alpha_complex_3d_persistence COMMAND $<TARGET_FILE:periodic_alpha_complex_3d_persistence>
- "${CMAKE_SOURCE_DIR}/data/points/grid_10_10_10_in_0_1.off" "${CMAKE_SOURCE_DIR}/data/points/iso_cuboid_3_in_0_1.txt" "-p" "2" "-m" "0")
install(TARGETS alpha_complex_persistence DESTINATION bin)
- install(TARGETS periodic_alpha_complex_3d_persistence DESTINATION bin)
endif (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.7.0)
- if (NOT CGAL_VERSION VERSION_LESS 4.11.0)
- add_executable(weighted_periodic_alpha_complex_3d_persistence weighted_periodic_alpha_complex_3d_persistence.cpp)
- target_link_libraries(weighted_periodic_alpha_complex_3d_persistence ${CGAL_LIBRARY})
+ if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0)
+ add_executable(alpha_complex_3d_persistence alpha_complex_3d_persistence.cpp)
+ target_link_libraries(alpha_complex_3d_persistence ${CGAL_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY})
if (TBB_FOUND)
- target_link_libraries(weighted_periodic_alpha_complex_3d_persistence ${TBB_LIBRARIES})
+ target_link_libraries(alpha_complex_3d_persistence ${TBB_LIBRARIES})
endif(TBB_FOUND)
- add_test(NAME Alpha_complex_utilities_weigted_periodic_alpha_complex_3d COMMAND $<TARGET_FILE:weighted_periodic_alpha_complex_3d_persistence>
- "${CMAKE_SOURCE_DIR}/data/points/grid_10_10_10_in_0_1.off" "${CMAKE_SOURCE_DIR}/data/points/grid_10_10_10_in_0_1.weights"
- "${CMAKE_SOURCE_DIR}/data/points/iso_cuboid_3_in_0_1.txt" "3" "1.0")
+ add_test(NAME Alpha_complex_utilities_alpha_complex_3d COMMAND $<TARGET_FILE:alpha_complex_3d_persistence>
+ "${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off"
+ "-p" "2" "-m" "0.45" "-o" "alpha.pers")
+
+ add_test(NAME Alpha_complex_utilities_exact_alpha_complex_3d COMMAND $<TARGET_FILE:alpha_complex_3d_persistence>
+ "${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off"
+ "-p" "2" "-m" "0.45" "-o" "exact.pers" "-e")
+
+ if (DIFF_PATH)
+ add_test(Alpha_complex_utilities_diff_alpha_complex_3d ${DIFF_PATH}
+ "exact.pers" "alpha.pers")
+ endif()
+
+ add_test(NAME Alpha_complex_utilities_periodic_alpha_complex_3d_persistence COMMAND $<TARGET_FILE:alpha_complex_3d_persistence>
+ "${CMAKE_SOURCE_DIR}/data/points/grid_10_10_10_in_0_1.off"
+ "-c" "${CMAKE_SOURCE_DIR}/data/points/iso_cuboid_3_in_0_1.txt"
+ "-p" "2" "-m" "0")
+
+ add_test(NAME Alpha_complex_utilities_weighted_alpha_complex_3d COMMAND $<TARGET_FILE:alpha_complex_3d_persistence>
+ "${CMAKE_SOURCE_DIR}/data/points/grid_10_10_10_in_0_1.off"
+ "-w" "${CMAKE_SOURCE_DIR}/data/points/grid_10_10_10_in_0_1.weights"
+ "-p" "2" "-m" "0")
+
+ add_test(NAME Alpha_complex_utilities_weighted_periodic_alpha_complex_3d COMMAND $<TARGET_FILE:alpha_complex_3d_persistence>
+ "${CMAKE_SOURCE_DIR}/data/points/grid_10_10_10_in_0_1.off"
+ "-w" "${CMAKE_SOURCE_DIR}/data/points/grid_10_10_10_in_0_1.weights"
+ "-c" "${CMAKE_SOURCE_DIR}/data/points/iso_cuboid_3_in_0_1.txt"
+ "-p" "2" "-m" "0")
- install(TARGETS weighted_periodic_alpha_complex_3d_persistence DESTINATION bin)
+ install(TARGETS alpha_complex_3d_persistence DESTINATION bin)
- endif (NOT CGAL_VERSION VERSION_LESS 4.11.0)
+ endif (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0)
endif(CGAL_FOUND)
diff --git a/src/Alpha_complex/utilities/alpha_complex_3d_helper.h b/src/Alpha_complex/utilities/alpha_complex_3d_helper.h
deleted file mode 100644
index a72fd96d..00000000
--- a/src/Alpha_complex/utilities/alpha_complex_3d_helper.h
+++ /dev/null
@@ -1,74 +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) 2014 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 <http://www.gnu.org/licenses/>.
- */
-
-#ifndef ALPHA_COMPLEX_3D_HELPER_H_
-#define ALPHA_COMPLEX_3D_HELPER_H_
-
-template <class Vertex_list, class Cell_handle>
-Vertex_list from_cell(const Cell_handle& ch) {
- Vertex_list the_list;
- for (auto i = 0; i < 4; i++) {
-#ifdef DEBUG_TRACES
- std::cout << "from cell[" << i << "]=" << ch->vertex(i)->point() << std::endl;
-#endif // DEBUG_TRACES
- the_list.push_back(ch->vertex(i));
- }
- return the_list;
-}
-
-template <class Vertex_list, class Facet>
-Vertex_list from_facet(const Facet& fct) {
- Vertex_list the_list;
- for (auto i = 0; i < 4; i++) {
- if (fct.second != i) {
-#ifdef DEBUG_TRACES
- std::cout << "from facet=[" << i << "]" << fct.first->vertex(i)->point() << std::endl;
-#endif // DEBUG_TRACES
- the_list.push_back(fct.first->vertex(i));
- }
- }
- return the_list;
-}
-
-template <class Vertex_list, class Edge_3>
-Vertex_list from_edge(const Edge_3& edg) {
- Vertex_list the_list;
- for (auto i : {edg.second, edg.third}) {
-#ifdef DEBUG_TRACES
- std::cout << "from edge[" << i << "]=" << edg.first->vertex(i)->point() << std::endl;
-#endif // DEBUG_TRACES
- the_list.push_back(edg.first->vertex(i));
- }
- return the_list;
-}
-
-template <class Vertex_list, class Vertex_handle>
-Vertex_list from_vertex(const Vertex_handle& vh) {
- Vertex_list the_list;
-#ifdef DEBUG_TRACES
- std::cout << "from vertex=" << vh->point() << std::endl;
-#endif // DEBUG_TRACES
- the_list.push_back(vh);
- return the_list;
-}
-
-#endif // ALPHA_COMPLEX_3D_HELPER_H_
diff --git a/src/Alpha_complex/utilities/alpha_complex_3d_persistence.cpp b/src/Alpha_complex/utilities/alpha_complex_3d_persistence.cpp
index 6e603155..536de444 100644
--- a/src/Alpha_complex/utilities/alpha_complex_3d_persistence.cpp
+++ b/src/Alpha_complex/utilities/alpha_complex_3d_persistence.cpp
@@ -20,188 +20,141 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <boost/version.hpp>
#include <boost/program_options.hpp>
#include <boost/variant.hpp>
-#if BOOST_VERSION >= 105400
-#include <boost/container/static_vector.hpp>
-#endif
-
+#include <gudhi/Alpha_complex_3d.h>
+#include <gudhi/Alpha_complex_3d_options.h>
#include <gudhi/Simplex_tree.h>
#include <gudhi/Persistent_cohomology.h>
#include <gudhi/Points_3D_off_io.h>
-#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
-#include <CGAL/Delaunay_triangulation_3.h>
-#include <CGAL/Alpha_shape_3.h>
-#include <CGAL/Alpha_shape_cell_base_3.h>
-#include <CGAL/Alpha_shape_vertex_base_3.h>
-#include <CGAL/iterator.h>
-
#include <fstream>
-#include <cmath>
#include <string>
-#include <tuple>
-#include <map>
-#include <utility>
#include <vector>
-#include <cstdlib>
-
-#include "alpha_complex_3d_helper.h"
-
-// Alpha_shape_3 templates type definitions
-using Kernel = CGAL::Exact_predicates_inexact_constructions_kernel;
-using Vb = CGAL::Alpha_shape_vertex_base_3<Kernel>;
-using Fb = CGAL::Alpha_shape_cell_base_3<Kernel>;
-using Tds = CGAL::Triangulation_data_structure_3<Vb, Fb>;
-using Triangulation_3 = CGAL::Delaunay_triangulation_3<Kernel, Tds>;
-using Alpha_shape_3 = CGAL::Alpha_shape_3<Triangulation_3>;
-
-// From file type definition
-using Point_3 = Kernel::Point_3;
-
-// filtration with alpha values needed type definition
-using Alpha_value_type = Alpha_shape_3::FT;
-using Object = CGAL::Object;
-using Dispatch =
- CGAL::Dispatch_output_iterator<CGAL::cpp11::tuple<Object, Alpha_value_type>,
- CGAL::cpp11::tuple<std::back_insert_iterator<std::vector<Object> >,
- std::back_insert_iterator<std::vector<Alpha_value_type> > > >;
-using Cell_handle = Alpha_shape_3::Cell_handle;
-using Facet = Alpha_shape_3::Facet;
-using Edge_3 = Alpha_shape_3::Edge;
-using Vertex_handle = Alpha_shape_3::Vertex_handle;
-
-#if BOOST_VERSION >= 105400
-using Vertex_list = boost::container::static_vector<Alpha_shape_3::Vertex_handle, 4>;
-#else
-using Vertex_list = std::vector<Alpha_shape_3::Vertex_handle>;
-#endif
// gudhi type definition
-using ST = Gudhi::Simplex_tree<Gudhi::Simplex_tree_options_fast_persistence>;
-using Filtration_value = ST::Filtration_value;
-using Simplex_tree_vertex = ST::Vertex_handle;
-using Alpha_shape_simplex_tree_map = std::map<Alpha_shape_3::Vertex_handle, Simplex_tree_vertex>;
-using Simplex_tree_vector_vertex = std::vector<Simplex_tree_vertex>;
+using Weighted_periodic_alpha_complex_3d = Gudhi::alpha_complex::Alpha_complex_3d<Gudhi::alpha_complex::Weighted_periodic_alpha_shapes_3d>;
+using Periodic_alpha_complex_3d = Gudhi::alpha_complex::Alpha_complex_3d<Gudhi::alpha_complex::Periodic_alpha_shapes_3d>;
+using Weighted_alpha_complex_3d = Gudhi::alpha_complex::Alpha_complex_3d<Gudhi::alpha_complex::Weighted_alpha_shapes_3d>;
+using Exact_alpha_complex_3d = Gudhi::alpha_complex::Alpha_complex_3d<Gudhi::alpha_complex::Exact_alpha_shapes_3d>;
+using Alpha_complex_3d = Gudhi::alpha_complex::Alpha_complex_3d<Gudhi::alpha_complex::Alpha_shapes_3d>;
+using Simplex_tree = Gudhi::Simplex_tree<Gudhi::Simplex_tree_options_fast_persistence>;
+using Filtration_value = Simplex_tree::Filtration_value;
using Persistent_cohomology =
- Gudhi::persistent_cohomology::Persistent_cohomology<ST, Gudhi::persistent_cohomology::Field_Zp>;
+ Gudhi::persistent_cohomology::Persistent_cohomology<Simplex_tree, Gudhi::persistent_cohomology::Field_Zp>;
-void program_options(int argc, char *argv[], std::string &off_file_points, std::string &output_file_diag,
+void program_options(int argc, char *argv[], std::string &off_file_points, bool& exact, std::string &weight_file,
+ std::string &cuboid_file, std::string &output_file_diag, Filtration_value &alpha_square_max_value,
int &coeff_field_characteristic, Filtration_value &min_persistence);
+template<typename AlphaComplex3d>
+bool create_complex(AlphaComplex3d& alpha_complex, Simplex_tree& simplex_tree,
+ Filtration_value alpha_square_max_value) {
+ return alpha_complex.create_complex(simplex_tree, alpha_square_max_value);
+}
+
+bool read_weight_file(const std::string& weight_file, std::vector<double>& weights) {
+ // Read weights information from file
+ std::ifstream weights_ifstr(weight_file);
+ if (weights_ifstr.good()) {
+ double weight = 0.0;
+ // Attempt read the weight in a double format, return false if it fails
+ while (weights_ifstr >> weight) {
+ weights.push_back(weight);
+ }
+ } else {
+ return false;
+ }
+ return true;
+}
+
+bool read_cuboid_file(const std::string& cuboid_file, double& x_min, double& y_min, double& z_min,
+ double& x_max, double& y_max, double& z_max) {
+ // Read weights information from file
+ std::ifstream iso_cuboid_str(cuboid_file);
+ if (iso_cuboid_str.is_open()) {
+ if (!(iso_cuboid_str >> x_min >> y_min >> z_min >> x_max >> y_max >> z_max)) {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ return true;
+}
+
int main(int argc, char **argv) {
std::string off_file_points;
+ std::string weight_file;
+ std::string cuboid_file;
std::string output_file_diag;
- int coeff_field_characteristic;
- Filtration_value min_persistence;
+ Filtration_value alpha_square_max_value = 0.;
+ int coeff_field_characteristic = 0;
+ Filtration_value min_persistence = 0.;
+ bool exact_version = false;
+ bool weighted_version = false;
+ bool periodic_version = false;
- program_options(argc, argv, off_file_points, output_file_diag, coeff_field_characteristic, min_persistence);
+ program_options(argc, argv, off_file_points, exact_version, weight_file, cuboid_file, output_file_diag,
+ alpha_square_max_value, coeff_field_characteristic, min_persistence);
// Read the OFF file (input file name given as parameter) and triangulate points
- Gudhi::Points_3D_off_reader<Point_3> off_reader(off_file_points);
+ Gudhi::Points_3D_off_reader<Alpha_complex_3d::Point_3> off_reader(off_file_points);
// Check the read operation was correct
if (!off_reader.is_valid()) {
- std::cerr << "Unable to read file " << off_file_points << std::endl;
+ std::cerr << "Unable to read OFF file " << off_file_points << std::endl;
exit(-1);
}
- // Retrieve the points
- std::vector<Point_3> lp = off_reader.get_point_cloud();
-
- // alpha shape construction from points. CGAL has a strange behavior in REGULARIZED mode.
- Alpha_shape_3 as(lp.begin(), lp.end(), 0, Alpha_shape_3::GENERAL);
-#ifdef DEBUG_TRACES
- std::cout << "Alpha shape computed in GENERAL mode" << std::endl;
-#endif // DEBUG_TRACES
-
- // filtration with alpha values from alpha shape
- std::vector<Object> the_objects;
- std::vector<Alpha_value_type> the_alpha_values;
-
- Dispatch disp = CGAL::dispatch_output<Object, Alpha_value_type>(std::back_inserter(the_objects),
- std::back_inserter(the_alpha_values));
+ std::vector<double> weights;
+ if (weight_file != std::string()) {
+ if (!read_weight_file(weight_file, weights)) {
+ std::cerr << "Unable to read weights file " << weight_file << std::endl;
+ exit(-1);
+ }
+ weighted_version = true;
+ }
- as.filtration_with_alpha_values(disp);
-#ifdef DEBUG_TRACES
- std::cout << "filtration_with_alpha_values returns : " << the_objects.size() << " objects" << std::endl;
-#endif // DEBUG_TRACES
+ double x_min=0., y_min=0., z_min=0., x_max=0., y_max=0., z_max=0.;
+ std::ifstream iso_cuboid_str(argv[3]);
+ if (cuboid_file != std::string()) {
+ if (!read_cuboid_file(cuboid_file, x_min, y_min, z_min, x_max, y_max, z_max)) {
+ std::cerr << "Unable to read cuboid file " << cuboid_file << std::endl;
+ exit(-1);
+ }
+ periodic_version = true;
+ }
- Alpha_shape_3::size_type count_vertices = 0;
- Alpha_shape_3::size_type count_edges = 0;
- Alpha_shape_3::size_type count_facets = 0;
- Alpha_shape_3::size_type count_cells = 0;
+ Simplex_tree simplex_tree;
- // Loop on objects vector
- Vertex_list vertex_list;
- ST simplex_tree;
- Alpha_shape_simplex_tree_map map_cgal_simplex_tree;
- std::vector<Alpha_value_type>::iterator the_alpha_value_iterator = the_alpha_values.begin();
- for (auto object_iterator : the_objects) {
- // Retrieve Alpha shape vertex list from object
- if (const Cell_handle *cell = CGAL::object_cast<Cell_handle>(&object_iterator)) {
- vertex_list = from_cell<Vertex_list, Cell_handle>(*cell);
- count_cells++;
- } else if (const Facet *facet = CGAL::object_cast<Facet>(&object_iterator)) {
- vertex_list = from_facet<Vertex_list, Facet>(*facet);
- count_facets++;
- } else if (const Edge_3 *edge = CGAL::object_cast<Edge_3>(&object_iterator)) {
- vertex_list = from_edge<Vertex_list, Edge_3>(*edge);
- count_edges++;
- } else if (const Vertex_handle *vertex = CGAL::object_cast<Vertex_handle>(&object_iterator)) {
- count_vertices++;
- vertex_list = from_vertex<Vertex_list, Vertex_handle>(*vertex);
+ if (exact_version) {
+ if ((weighted_version) || (periodic_version)) {
+ std::cerr << "Unable to compute exact version of a weighted and/or periodic alpha shape" << std::endl;
+ exit(-1);
+ } else {
+ Exact_alpha_complex_3d alpha_complex(off_reader.get_point_cloud());
+ create_complex(alpha_complex, simplex_tree, alpha_square_max_value);
}
- // Construction of the vector of simplex_tree vertex from list of alpha_shapes vertex
- Simplex_tree_vector_vertex the_simplex;
- for (auto the_alpha_shape_vertex : vertex_list) {
- Alpha_shape_simplex_tree_map::iterator the_map_iterator = map_cgal_simplex_tree.find(the_alpha_shape_vertex);
- if (the_map_iterator == map_cgal_simplex_tree.end()) {
- // alpha shape not found
- Simplex_tree_vertex vertex = map_cgal_simplex_tree.size();
-#ifdef DEBUG_TRACES
- std::cout << "vertex [" << the_alpha_shape_vertex->point() << "] not found - insert " << vertex << std::endl;
-#endif // DEBUG_TRACES
- the_simplex.push_back(vertex);
- map_cgal_simplex_tree.emplace(the_alpha_shape_vertex, vertex);
+ } else {
+ if (weighted_version) {
+ if (periodic_version) {
+ Weighted_periodic_alpha_complex_3d alpha_complex(off_reader.get_point_cloud(), weights,
+ x_min, y_min, z_min, x_max, y_max, z_max);
+ create_complex(alpha_complex, simplex_tree, alpha_square_max_value);
+ } else {
+ Weighted_alpha_complex_3d alpha_complex(off_reader.get_point_cloud(), weights);
+ create_complex(alpha_complex, simplex_tree, alpha_square_max_value);
+ }
+ } else {
+ if (periodic_version) {
+ Periodic_alpha_complex_3d alpha_complex(off_reader.get_point_cloud(), x_min, y_min, z_min, x_max, y_max, z_max);
+ create_complex(alpha_complex, simplex_tree, alpha_square_max_value);
} else {
- // alpha shape found
- Simplex_tree_vertex vertex = the_map_iterator->second;
-#ifdef DEBUG_TRACES
- std::cout << "vertex [" << the_alpha_shape_vertex->point() << "] found in " << vertex << std::endl;
-#endif // DEBUG_TRACES
- the_simplex.push_back(vertex);
+ Alpha_complex_3d alpha_complex(off_reader.get_point_cloud());
+ create_complex(alpha_complex, simplex_tree, alpha_square_max_value);
}
}
- // Construction of the simplex_tree
- Filtration_value filtr = /*std::sqrt*/ (*the_alpha_value_iterator);
-#ifdef DEBUG_TRACES
- std::cout << "filtration = " << filtr << std::endl;
-#endif // DEBUG_TRACES
- simplex_tree.insert_simplex(the_simplex, filtr);
- GUDHI_CHECK(the_alpha_value_iterator != the_alpha_values.end(), "CGAL provided more simplices than values");
- ++the_alpha_value_iterator;
- }
-
-#ifdef DEBUG_TRACES
- std::cout << "vertices \t\t" << count_vertices << std::endl;
- std::cout << "edges \t\t" << count_edges << std::endl;
- std::cout << "facets \t\t" << count_facets << std::endl;
- std::cout << "cells \t\t" << count_cells << std::endl;
-
- std::cout << "Information of the Simplex Tree: " << std::endl;
- std::cout << " Number of vertices = " << simplex_tree.num_vertices() << " ";
- std::cout << " Number of simplices = " << simplex_tree.num_simplices() << std::endl << std::endl;
- std::cout << " Dimension = " << simplex_tree.dimension() << " ";
-#endif // DEBUG_TRACES
-
-#ifdef DEBUG_TRACES
- std::cout << "Iterator on vertices: " << std::endl;
- for (auto vertex : simplex_tree.complex_vertex_range()) {
- std::cout << vertex << " ";
}
-#endif // DEBUG_TRACES
// Sort the simplices in the order of the filtration
simplex_tree.initialize_filtration();
@@ -227,7 +180,8 @@ int main(int argc, char **argv) {
return 0;
}
-void program_options(int argc, char *argv[], std::string &off_file_points, std::string &output_file_diag,
+void program_options(int argc, char *argv[], std::string &off_file_points, bool& exact, std::string &weight_file,
+ std::string &cuboid_file, std::string &output_file_diag, Filtration_value &alpha_square_max_value,
int &coeff_field_characteristic, Filtration_value &min_persistence) {
namespace po = boost::program_options;
po::options_description hidden("Hidden options");
@@ -236,8 +190,17 @@ void program_options(int argc, char *argv[], std::string &off_file_points, std::
po::options_description visible("Allowed options", 100);
visible.add_options()("help,h", "produce help message")(
+ "exact,e", po::bool_switch(&exact),
+ "To activate exact version of Alpha complex 3d (default is false, not available for weighted and/or periodic)")(
+ "weight-file,w", po::value<std::string>(&weight_file)->default_value(std::string()),
+ "Name of file containing a point weights. Format is one weight per line:\n W1\n ...\n Wn ")(
+ "cuboid-file,c", po::value<std::string>(&cuboid_file),
+ "Name of file describing the periodic domain. Format is:\n min_hx min_hy min_hz\n max_hx max_hy max_hz")(
"output-file,o", po::value<std::string>(&output_file_diag)->default_value(std::string()),
"Name of file in which the persistence diagram is written. Default print in std::cout")(
+ "max-alpha-square-value,r", po::value<Filtration_value>(&alpha_square_max_value)
+ ->default_value(std::numeric_limits<Filtration_value>::infinity()),
+ "Maximal alpha square value for the Alpha complex construction.")(
"field-charac,p", po::value<int>(&coeff_field_characteristic)->default_value(11),
"Characteristic p of the coefficient field Z/pZ for computing homology.")(
"min-persistence,m", po::value<Filtration_value>(&min_persistence),
@@ -254,17 +217,18 @@ void program_options(int argc, char *argv[], std::string &off_file_points, std::
po::store(po::command_line_parser(argc, argv).options(all).positional(pos).run(), vm);
po::notify(vm);
- if (vm.count("help") || !vm.count("input-file")) {
+ if (vm.count("help") || !vm.count("input-file") || !vm.count("weight-file")) {
std::cout << std::endl;
std::cout << "Compute the persistent homology with coefficient field Z/pZ \n";
- std::cout << "of a 3D Alpha complex defined on a set of input points.\n \n";
+ std::cout << "of a 3D Alpha complex defined on a set of input points.\n";
+ std::cout << "3D Alpha complex can be exact or weighted and/or periodic\n\n";
std::cout << "The output diagram contains one bar per line, written with the convention: \n";
std::cout << " p dim b d \n";
std::cout << "where dim is the dimension of the homological feature,\n";
std::cout << "b and d are respectively the birth and death of the feature and \n";
- std::cout << "p is the characteristic of the field Z/pZ used for homology coefficients." << std::endl << std::endl;
+ std::cout << "p is the characteristic of the field Z/pZ used for homology coefficients.\n\n";
- std::cout << "Usage: " << argv[0] << " [options] input-file" << std::endl << std::endl;
+ std::cout << "Usage: " << argv[0] << " [options] input-file weight-file\n\n";
std::cout << visible << std::endl;
exit(-1);
}
diff --git a/src/Alpha_complex/utilities/alphacomplex.md b/src/Alpha_complex/utilities/alphacomplex.md
index 0fe98837..7fc6cc0c 100644
--- a/src/Alpha_complex/utilities/alphacomplex.md
+++ b/src/Alpha_complex/utilities/alphacomplex.md
@@ -12,15 +12,18 @@ Leave the lines above as it is required by the web site generator 'Jekyll'
## alpha_complex_persistence ##
-This program computes the persistent homology with coefficient field Z/pZ of the dD alpha complex built from a dD point cloud.
+This program computes the persistent homology with coefficient field Z/pZ of
+the dD alpha complex built from a dD point cloud.
The output diagram contains one bar per line, written with the convention:
```
p dim birth death
```
-where `dim` is the dimension of the homological feature, `birth` and `death` are respectively the birth and death of the feature,
-and `p` is the characteristic of the field *Z/pZ* used for homology coefficients (`p` must be a prime number).
+where `dim` is the dimension of the homological feature, `birth` and `death`
+are respectively the birth and death of the feature, and `p` is the
+characteristic of the field *Z/pZ* used for homology coefficients (`p` must be
+a prime number).
**Usage**
@@ -29,15 +32,20 @@ and `p` is the characteristic of the field *Z/pZ* used for homology coefficients
```
where
-`<input OFF file>` is the path to the input point cloud in [nOFF ASCII format](http://www.geomview.org/docs/html/OFF.html).
+`<input OFF file>` is the path to the input point cloud in
+[nOFF ASCII format](http://www.geomview.org/docs/html/OFF.html).
**Allowed options**
* `-h [ --help ]` Produce help message
-* `-o [ --output-file ]` Name of file in which the persistence diagram is written. Default print in standard output.
-* `-r [ --max-alpha-square-value ]` (default = inf) Maximal alpha square value for the Alpha complex construction.
-* `-p [ --field-charac ]` (default = 11) Characteristic p of the coefficient field Z/pZ for computing homology.
-* `-m [ --min-persistence ]` (default = 0) Minimal lifetime of homology feature to be recorded. Enter a negative value to see zero length intervals.
+* `-o [ --output-file ]` Name of file in which the persistence diagram is
+written. Default print in standard output.
+* `-r [ --max-alpha-square-value ]` (default = inf) Maximal alpha square value
+for the Alpha complex construction.
+* `-p [ --field-charac ]` (default = 11) Characteristic p of the
+coefficient field Z/pZ for computing homology.
+* `-m [ --min-persistence ]` (default = 0) Minimal lifetime of homology feature
+to be recorded. Enter a negative value to see zero length intervals.
**Example**
@@ -51,13 +59,26 @@ N.B.:
## alpha_complex_3d_persistence ##
-This program computes the persistent homology with coefficient field Z/pZ of the 3D alpha complex built from a 3D point cloud. The output diagram contains one bar per line, written with the convention:
+This program computes the persistent homology with coefficient field Z/pZ of
+the 3D alpha complex built from a 3D point cloud.
+One can use exact computation. It is slower, but it is necessary when points
+are on a grid for instance.
+Alpha complex 3d can be weighted and/or periodic (refer to the
+[CGAL's 3D Periodic Triangulations User Manual](
+https://doc.cgal.org/latest/Periodic_3_triangulation_3/index.html)
+for more details).
+
+The output diagram contains
+one bar per line, written with the convention:
```
p dim birth death
```
-where `dim` is the dimension of the homological feature, `birth` and `death` are respectively the birth and death of the feature, and `p` is the characteristic of the field *Z/pZ* used for homology coefficients (`p` must be a prime number).
+where `dim` is the dimension of the homological feature, `birth` and `death`
+are respectively the birth and death of the feature, and `p` is the
+characteristic of the field *Z/pZ* used for homology coefficients (`p` must be
+a prime number).
**Usage**
@@ -65,14 +86,27 @@ where `dim` is the dimension of the homological feature, `birth` and `death` are
alpha_complex_3d_persistence [options] <input OFF file>
```
-where `<input OFF file>` is the path to the input point cloud in [nOFF ASCII format](http://www.geomview.org/docs/html/OFF.html).
+where `<input OFF file>` is the path to the input point cloud in
+[nOFF ASCII format](http://www.geomview.org/docs/html/OFF.html).
**Allowed options**
* `-h [ --help ]` Produce help message
-* `-o [ --output-file ]` Name of file in which the persistence diagram is written. Default print in standard output.
-* `-p [ --field-charac ]` (default=11) Characteristic p of the coefficient field Z/pZ for computing homology.
-* `-m [ --min-persistence ]` (default = 0) Minimal lifetime of homology feature to be recorded. Enter a negative value to see zero length intervals.
+* `-o [ --output-file ]` Name of file in which the persistence diagram is
+written. Default print in standard output.
+* `-r [ --max-alpha-square-value ]` (default = inf) Maximal alpha square value
+for the Alpha complex construction.
+* `-p [ --field-charac ]` (default=11) Characteristic p of the coefficient
+field Z/pZ for computing homology.
+* `-m [ --min-persistence ]` (default = 0) Minimal lifetime of homology feature
+to be recorded. Enter a negative value to see zero length intervals.
+* `-c [ --cuboid-file ]` is the path to the file describing the periodic domain.
+It must be in the format described
+[here](/doc/latest/fileformats.html#FileFormatsIsoCuboid).
+* `-w [ --weight-file ]` is the path to the file containing the weights of the
+points (one value per line).
+* `-e [ --exact ]` for the exact computation version (not compatible with
+weight and periodic version).
**Example**
@@ -84,82 +118,7 @@ N.B.:
* `alpha_complex_3d_persistence` only accepts OFF files in dimension 3.
* Filtration values are alpha square values.
-
-
-## exact_alpha_complex_3d_persistence ##
-
-Same as `alpha_complex_3d_persistence`, but using exact computation.
-It is slower, but it is necessary when points are on a grid for instance.
-
-
-
-## weighted_alpha_complex_3d_persistence ##
-
-Same as `alpha_complex_3d_persistence`, but using weighted points.
-
-**Usage**
-
-```
- weighted_alpha_complex_3d_persistence [options] <input OFF file> <weights input file>
-```
-
-where
-
-* `<input OFF file>` is the path to the input point cloud in [nOFF ASCII format](http://www.geomview.org/docs/html/OFF.html).
-* `<input weights file>` is the path to the file containing the weights of the points (one value per line).
-
-**Allowed options**
-
-* `-h [ --help ]` Produce help message
-* `-o [ --output-file ]` Name of file in which the persistence diagram is written. Default print in standard output.
-* `-p [ --field-charac ]` (default=11) Characteristic p of the coefficient field Z/pZ for computing homology.
-* `-m [ --min-persistence ]` (default = 0) Minimal lifetime of homology feature to be recorded. Enter a negative value to see zero length intervals.
-
-**Example**
-
-```
- weighted_alpha_complex_3d_persistence ../../data/points/tore3D_300.off ../../data/points/tore3D_300.weights -p 2 -m 0.45
-```
-
-
-N.B.:
-
-* Weights values are explained on CGAL [Alpha shape](https://doc.cgal.org/latest/Alpha_shapes_3/index.html#title0)
-and [Regular triangulation](https://doc.cgal.org/latest/Triangulation_3/index.html#Triangulation3secclassRegulartriangulation) documentation.
-* Filtration values are alpha square values.
-
-
-## periodic_alpha_complex_3d_persistence ##
-Same as `alpha_complex_3d_persistence`, but using periodic alpha shape 3d.
-Refer to the [CGAL's 3D Periodic Triangulations User Manual](https://doc.cgal.org/latest/Periodic_3_triangulation_3/index.html) for more details.
-
-**Usage**
-
-```
- periodic_alpha_complex_3d_persistence [options] <input OFF file> <cuboid file>
-```
-
-where
-
-* `<input OFF file>` is the path to the input point cloud in [nOFF ASCII format](http://www.geomview.org/docs/html/OFF.html).
-* `<cuboid file>` is the path to the file describing the periodic domain. It must be in the format described
-[here](/doc/latest/fileformats.html#FileFormatsIsoCuboid).
-
-**Allowed options**
-
-* `-h [ --help ]` Produce help message
-* `-o [ --output-file ]` Name of file in which the persistence diagram is written. Default print in standard output.
-* `-p [ --field-charac ]` (default=11) Characteristic p of the coefficient field Z/pZ for computing homology.
-* `-m [ --min-persistence ]` (default = 0) Minimal lifetime of homology feature to be recorded. Enter a negative value to see zero length intervals
-
-
-**Example**
-
-```
-periodic_alpha_complex_3d_persistence ../../data/points/grid_10_10_10_in_0_1.off ../../data/points/iso_cuboid_3_in_0_1.txt -p 3 -m 1.0
-```
-
-N.B.:
-
-* Cuboid file must be in the format described [here](/doc/latest/fileformats.html#FileFormatsIsoCuboid).
-* Filtration values are alpha square values.
+* Weights values are explained on CGAL
+[Alpha shape](https://doc.cgal.org/latest/Alpha_shapes_3/index.html#title0)
+and
+[Regular triangulation](https://doc.cgal.org/latest/Triangulation_3/index.html#Triangulation3secclassRegulartriangulation) documentation.
diff --git a/src/Alpha_complex/utilities/exact_alpha_complex_3d_persistence.cpp b/src/Alpha_complex/utilities/exact_alpha_complex_3d_persistence.cpp
deleted file mode 100644
index 61f49bb1..00000000
--- a/src/Alpha_complex/utilities/exact_alpha_complex_3d_persistence.cpp
+++ /dev/null
@@ -1,265 +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) 2014 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 <http://www.gnu.org/licenses/>.
- */
-
-#include <boost/program_options.hpp>
-#include <boost/variant.hpp>
-
-#include <gudhi/Simplex_tree.h>
-#include <gudhi/Persistent_cohomology.h>
-#include <gudhi/Points_3D_off_io.h>
-
-#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
-#include <CGAL/Delaunay_triangulation_3.h>
-#include <CGAL/Alpha_shape_3.h>
-#include <CGAL/Alpha_shape_cell_base_3.h>
-#include <CGAL/Alpha_shape_vertex_base_3.h>
-#include <CGAL/iterator.h>
-
-#include <fstream>
-#include <cmath>
-#include <string>
-#include <tuple>
-#include <map>
-#include <utility>
-#include <vector>
-#include <cstdlib>
-
-#include "alpha_complex_3d_helper.h"
-
-// 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<Kernel, CGAL::Default, Exact_tag>;
-using Fb = CGAL::Alpha_shape_cell_base_3<Kernel, CGAL::Default, Exact_tag>;
-using Tds = CGAL::Triangulation_data_structure_3<Vb, Fb>;
-using Triangulation_3 = CGAL::Delaunay_triangulation_3<Kernel, Tds>;
-using Alpha_shape_3 = CGAL::Alpha_shape_3<Triangulation_3, Exact_tag>;
-
-// From file type definition
-using Point_3 = Kernel::Point_3;
-
-// filtration with alpha values needed type definition
-using Alpha_value_type = Alpha_shape_3::FT;
-using Object = CGAL::Object;
-using Dispatch =
- CGAL::Dispatch_output_iterator<CGAL::cpp11::tuple<Object, Alpha_value_type>,
- CGAL::cpp11::tuple<std::back_insert_iterator<std::vector<Object> >,
- std::back_insert_iterator<std::vector<Alpha_value_type> > > >;
-using Cell_handle = Alpha_shape_3::Cell_handle;
-using Facet = Alpha_shape_3::Facet;
-using Edge_3 = Alpha_shape_3::Edge;
-using Vertex_handle = Alpha_shape_3::Vertex_handle;
-using Vertex_list = std::vector<Vertex_handle>;
-
-// gudhi type definition
-using ST = Gudhi::Simplex_tree<Gudhi::Simplex_tree_options_fast_persistence>;
-using Filtration_value = ST::Filtration_value;
-using Simplex_tree_vertex = ST::Vertex_handle;
-using Alpha_shape_simplex_tree_map = std::map<Alpha_shape_3::Vertex_handle, Simplex_tree_vertex>;
-using Simplex_tree_vector_vertex = std::vector<Simplex_tree_vertex>;
-using Persistent_cohomology =
- Gudhi::persistent_cohomology::Persistent_cohomology<ST, Gudhi::persistent_cohomology::Field_Zp>;
-
-void program_options(int argc, char *argv[], std::string &off_file_points, std::string &output_file_diag,
- int &coeff_field_characteristic, Filtration_value &min_persistence);
-
-int main(int argc, char **argv) {
- std::string off_file_points;
- std::string output_file_diag;
- int coeff_field_characteristic;
- Filtration_value min_persistence;
-
- program_options(argc, argv, off_file_points, output_file_diag, coeff_field_characteristic, min_persistence);
-
- // Read the OFF file (input file name given as parameter) and triangulate points
- Gudhi::Points_3D_off_reader<Point_3> off_reader(off_file_points);
- // Check the read operation was correct
- if (!off_reader.is_valid()) {
- std::cerr << "Unable to read file " << off_file_points << std::endl;
- exit(-1);
- }
-
- // Retrieve the points
- std::vector<Point_3> lp = off_reader.get_point_cloud();
-
- // alpha shape construction from points. CGAL has a strange behavior in REGULARIZED mode.
- Alpha_shape_3 as(lp.begin(), lp.end(), 0, Alpha_shape_3::GENERAL);
-#ifdef DEBUG_TRACES
- std::cout << "Alpha shape computed in GENERAL mode" << std::endl;
-#endif // DEBUG_TRACES
-
- // filtration with alpha values from alpha shape
- std::vector<Object> the_objects;
- std::vector<Alpha_value_type> the_alpha_values;
-
- Dispatch disp = CGAL::dispatch_output<Object, Alpha_value_type>(std::back_inserter(the_objects),
- std::back_inserter(the_alpha_values));
-
- as.filtration_with_alpha_values(disp);
-#ifdef DEBUG_TRACES
- std::cout << "filtration_with_alpha_values returns : " << the_objects.size() << " objects" << std::endl;
-#endif // DEBUG_TRACES
-
- Alpha_shape_3::size_type count_vertices = 0;
- Alpha_shape_3::size_type count_edges = 0;
- Alpha_shape_3::size_type count_facets = 0;
- Alpha_shape_3::size_type count_cells = 0;
-
- // Loop on objects vector
- Vertex_list vertex_list;
- ST simplex_tree;
- Alpha_shape_simplex_tree_map map_cgal_simplex_tree;
- std::vector<Alpha_value_type>::iterator the_alpha_value_iterator = the_alpha_values.begin();
- for (auto object_iterator : the_objects) {
- // Retrieve Alpha shape vertex list from object
- if (const Cell_handle *cell = CGAL::object_cast<Cell_handle>(&object_iterator)) {
- vertex_list = from_cell<Vertex_list, Cell_handle>(*cell);
- count_cells++;
- } else if (const Facet *facet = CGAL::object_cast<Facet>(&object_iterator)) {
- vertex_list = from_facet<Vertex_list, Facet>(*facet);
- count_facets++;
- } else if (const Edge_3 *edge = CGAL::object_cast<Edge_3>(&object_iterator)) {
- vertex_list = from_edge<Vertex_list, Edge_3>(*edge);
- count_edges++;
- } else if (const Vertex_handle *vertex = CGAL::object_cast<Vertex_handle>(&object_iterator)) {
- count_vertices++;
- vertex_list = from_vertex<Vertex_list, Vertex_handle>(*vertex);
- }
- // Construction of the vector of simplex_tree vertex from list of alpha_shapes vertex
- Simplex_tree_vector_vertex the_simplex;
- for (auto the_alpha_shape_vertex : vertex_list) {
- Alpha_shape_simplex_tree_map::iterator the_map_iterator = map_cgal_simplex_tree.find(the_alpha_shape_vertex);
- if (the_map_iterator == map_cgal_simplex_tree.end()) {
- // alpha shape not found
- Simplex_tree_vertex vertex = map_cgal_simplex_tree.size();
-#ifdef DEBUG_TRACES
- std::cout << "vertex [" << the_alpha_shape_vertex->point() << "] not found - insert " << vertex << std::endl;
-#endif // DEBUG_TRACES
- the_simplex.push_back(vertex);
- map_cgal_simplex_tree.emplace(the_alpha_shape_vertex, vertex);
- } else {
- // alpha shape found
- Simplex_tree_vertex vertex = the_map_iterator->second;
-#ifdef DEBUG_TRACES
- std::cout << "vertex [" << the_alpha_shape_vertex->point() << "] found in " << vertex << std::endl;
-#endif // DEBUG_TRACES
- the_simplex.push_back(vertex);
- }
- }
- // Construction of the simplex_tree
- // you can also use the_alpha_value_iterator->exact()
- Filtration_value filtr = /*std::sqrt*/ CGAL::to_double(the_alpha_value_iterator->exact());
-#ifdef DEBUG_TRACES
- std::cout << "filtration = " << filtr << std::endl;
-#endif // DEBUG_TRACES
- simplex_tree.insert_simplex(the_simplex, filtr);
- if (the_alpha_value_iterator != the_alpha_values.end())
- ++the_alpha_value_iterator;
- else
- std::cout << "This shall not happen" << std::endl;
- }
-
-#ifdef DEBUG_TRACES
- std::cout << "vertices \t\t" << count_vertices << std::endl;
- std::cout << "edges \t\t" << count_edges << std::endl;
- std::cout << "facets \t\t" << count_facets << std::endl;
- std::cout << "cells \t\t" << count_cells << std::endl;
-
- std::cout << "Information of the Simplex Tree: " << std::endl;
- std::cout << " Number of vertices = " << simplex_tree.num_vertices() << " ";
- std::cout << " Number of simplices = " << simplex_tree.num_simplices() << std::endl << std::endl;
- std::cout << " Dimension = " << simplex_tree.dimension() << " ";
-#endif // DEBUG_TRACES
-
-#ifdef DEBUG_TRACES
- std::cout << "Iterator on vertices: " << std::endl;
- for (auto vertex : simplex_tree.complex_vertex_range()) {
- std::cout << vertex << " ";
- }
-#endif // DEBUG_TRACES
-
- // Sort the simplices in the order of the filtration
- simplex_tree.initialize_filtration();
-
- std::cout << "Simplex_tree dim: " << simplex_tree.dimension() << std::endl;
- // Compute the persistence diagram of the complex
- Persistent_cohomology pcoh(simplex_tree, true);
- // initializes the coefficient field for homology
- pcoh.init_coefficients(coeff_field_characteristic);
-
- pcoh.compute_persistent_cohomology(min_persistence);
-
- // Output the diagram in filediag
- if (output_file_diag.empty()) {
- pcoh.output_diagram();
- } else {
- std::cout << "Result in file: " << output_file_diag << std::endl;
- std::ofstream out(output_file_diag);
- pcoh.output_diagram(out);
- out.close();
- }
-
- return 0;
-}
-
-void program_options(int argc, char *argv[], std::string &off_file_points, std::string &output_file_diag,
- int &coeff_field_characteristic, Filtration_value &min_persistence) {
- namespace po = boost::program_options;
- po::options_description hidden("Hidden options");
- hidden.add_options()("input-file", po::value<std::string>(&off_file_points),
- "Name of file containing a point set. Format is one point per line: X1 ... Xd ");
-
- po::options_description visible("Allowed options", 100);
- visible.add_options()("help,h", "produce help message")(
- "output-file,o", po::value<std::string>(&output_file_diag)->default_value(std::string()),
- "Name of file in which the persistence diagram is written. Default print in std::cout")(
- "field-charac,p", po::value<int>(&coeff_field_characteristic)->default_value(11),
- "Characteristic p of the coefficient field Z/pZ for computing homology.")(
- "min-persistence,m", po::value<Filtration_value>(&min_persistence),
- "Minimal lifetime of homology feature to be recorded. Default is 0. Enter a negative value to see zero length "
- "intervals");
-
- po::positional_options_description pos;
- pos.add("input-file", 1);
-
- po::options_description all;
- all.add(visible).add(hidden);
-
- po::variables_map vm;
- po::store(po::command_line_parser(argc, argv).options(all).positional(pos).run(), vm);
- po::notify(vm);
-
- if (vm.count("help") || !vm.count("input-file")) {
- std::cout << std::endl;
- std::cout << "Compute the persistent homology with coefficient field Z/pZ \n";
- std::cout << "of a 3D Alpha complex defined on a set of input points.\n \n";
- std::cout << "The output diagram contains one bar per line, written with the convention: \n";
- std::cout << " p dim b d \n";
- std::cout << "where dim is the dimension of the homological feature,\n";
- std::cout << "b and d are respectively the birth and death of the feature and \n";
- std::cout << "p is the characteristic of the field Z/pZ used for homology coefficients." << std::endl << std::endl;
-
- std::cout << "Usage: " << argv[0] << " [options] input-file" << std::endl << std::endl;
- std::cout << visible << std::endl;
- exit(-1);
- }
-}
diff --git a/src/Alpha_complex/utilities/periodic_alpha_complex_3d_persistence.cpp b/src/Alpha_complex/utilities/periodic_alpha_complex_3d_persistence.cpp
deleted file mode 100644
index a261c5a3..00000000
--- a/src/Alpha_complex/utilities/periodic_alpha_complex_3d_persistence.cpp
+++ /dev/null
@@ -1,302 +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
- * Pawel Dlotko - 2017 - Swansea University, UK
- *
- * Copyright (C) 2014 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 <http://www.gnu.org/licenses/>.
- */
-
-#include <boost/program_options.hpp>
-#include <boost/variant.hpp>
-
-#include <gudhi/Simplex_tree.h>
-#include <gudhi/Persistent_cohomology.h>
-#include <gudhi/Points_3D_off_io.h>
-
-#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
-#include <CGAL/Periodic_3_Delaunay_triangulation_traits_3.h>
-#include <CGAL/Periodic_3_Delaunay_triangulation_3.h>
-#include <CGAL/Alpha_shape_3.h>
-#include <CGAL/Alpha_shape_cell_base_3.h>
-#include <CGAL/Alpha_shape_vertex_base_3.h>
-#include <CGAL/iterator.h>
-
-#include <fstream>
-#include <cmath>
-#include <string>
-#include <tuple>
-#include <map>
-#include <utility>
-#include <vector>
-#include <cstdlib>
-
-#include "alpha_complex_3d_helper.h"
-
-// Traits
-using K = CGAL::Exact_predicates_inexact_constructions_kernel;
-using PK = CGAL::Periodic_3_Delaunay_triangulation_traits_3<K>;
-// Vertex type
-using DsVb = CGAL::Periodic_3_triangulation_ds_vertex_base_3<>;
-using Vb = CGAL::Triangulation_vertex_base_3<PK, DsVb>;
-using AsVb = CGAL::Alpha_shape_vertex_base_3<PK, Vb>;
-// Cell type
-using DsCb = CGAL::Periodic_3_triangulation_ds_cell_base_3<>;
-using Cb = CGAL::Triangulation_cell_base_3<PK, DsCb>;
-using AsCb = CGAL::Alpha_shape_cell_base_3<PK, Cb>;
-using Tds = CGAL::Triangulation_data_structure_3<AsVb, AsCb>;
-using P3DT3 = CGAL::Periodic_3_Delaunay_triangulation_3<PK, Tds>;
-using Alpha_shape_3 = CGAL::Alpha_shape_3<P3DT3>;
-using Point_3 = PK::Point_3;
-
-// filtration with alpha values needed type definition
-using Alpha_value_type = Alpha_shape_3::FT;
-using Object = CGAL::Object;
-using Dispatch =
- CGAL::Dispatch_output_iterator<CGAL::cpp11::tuple<Object, Alpha_value_type>,
- CGAL::cpp11::tuple<std::back_insert_iterator<std::vector<Object> >,
- std::back_insert_iterator<std::vector<Alpha_value_type> > > >;
-using Cell_handle = Alpha_shape_3::Cell_handle;
-using Facet = Alpha_shape_3::Facet;
-using Edge_3 = Alpha_shape_3::Edge;
-using Vertex_handle = Alpha_shape_3::Vertex_handle;
-using Vertex_list = std::vector<Alpha_shape_3::Vertex_handle>;
-
-// gudhi type definition
-using ST = Gudhi::Simplex_tree<Gudhi::Simplex_tree_options_fast_persistence>;
-using Filtration_value = ST::Filtration_value;
-using Simplex_tree_vertex = ST::Vertex_handle;
-using Alpha_shape_simplex_tree_map = std::map<Alpha_shape_3::Vertex_handle, Simplex_tree_vertex>;
-using Simplex_tree_vector_vertex = std::vector<Simplex_tree_vertex>;
-using Persistent_cohomology =
- Gudhi::persistent_cohomology::Persistent_cohomology<ST, Gudhi::persistent_cohomology::Field_Zp>;
-
-void program_options(int argc, char *argv[], std::string &off_file_points, std::string &cuboid_file,
- std::string &output_file_diag, int &coeff_field_characteristic, Filtration_value &min_persistence);
-
-int main(int argc, char **argv) {
- std::string off_file_points;
- std::string cuboid_file;
- std::string output_file_diag;
- int coeff_field_characteristic;
- Filtration_value min_persistence;
-
- program_options(argc, argv, off_file_points, cuboid_file, output_file_diag, coeff_field_characteristic,
- min_persistence);
-
- // Read the OFF file (input file name given as parameter) and triangulate points
- Gudhi::Points_3D_off_reader<Point_3> off_reader(off_file_points);
- // Check the read operation was correct
- if (!off_reader.is_valid()) {
- std::cerr << "Unable to read OFF file " << off_file_points << std::endl;
- exit(-1);
- }
-
- // Read iso_cuboid_3 information from file
- std::ifstream iso_cuboid_str(cuboid_file);
- double x_min, y_min, z_min, x_max, y_max, z_max;
- if (iso_cuboid_str.good()) {
- iso_cuboid_str >> x_min >> y_min >> z_min >> x_max >> y_max >> z_max;
- } else {
- std::cerr << "Unable to read file " << cuboid_file << std::endl;
- exit(-1);
- }
- // Checking if the cuboid is the same in x,y and z direction. If not, CGAL will not process it.
- if ((x_max - x_min != y_max - y_min) || (x_max - x_min != z_max - z_min) || (z_max - z_min != y_max - y_min)) {
- std::cerr << "The size of the cuboid in every directions is not the same." << std::endl;
- exit(-1);
- }
-
- // Retrieve the points
- std::vector<Point_3> lp = off_reader.get_point_cloud();
-
- // Define the periodic cube
- P3DT3 pdt(PK::Iso_cuboid_3(x_min, y_min, z_min, x_max, y_max, z_max));
- // Heuristic for inserting large point sets (if pts is reasonably large)
- pdt.insert(lp.begin(), lp.end(), true);
- // As pdt won't be modified anymore switch to 1-sheeted cover if possible
- if (pdt.is_triangulation_in_1_sheet()) {
- pdt.convert_to_1_sheeted_covering();
- } else {
- std::cerr << "ERROR: we were not able to construct a triangulation within a single periodic domain." << std::endl;
- exit(-1);
- }
- std::cout << "Periodic Delaunay computed." << std::endl;
-
- // alpha shape construction from points. CGAL has a strange behavior in REGULARIZED mode. This is the default mode
- // Maybe need to set it to GENERAL mode
- Alpha_shape_3 as(pdt, 0, Alpha_shape_3::GENERAL);
-
- // filtration with alpha values from alpha shape
- std::vector<Object> the_objects;
- std::vector<Alpha_value_type> the_alpha_values;
-
- Dispatch disp = CGAL::dispatch_output<Object, Alpha_value_type>(std::back_inserter(the_objects),
- std::back_inserter(the_alpha_values));
-
- as.filtration_with_alpha_values(disp);
-#ifdef DEBUG_TRACES
- std::cout << "filtration_with_alpha_values returns : " << the_objects.size() << " objects" << std::endl;
-#endif // DEBUG_TRACES
-
- Alpha_shape_3::size_type count_vertices = 0;
- Alpha_shape_3::size_type count_edges = 0;
- Alpha_shape_3::size_type count_facets = 0;
- Alpha_shape_3::size_type count_cells = 0;
-
- // Loop on objects vector
- Vertex_list vertex_list;
- ST simplex_tree;
- Alpha_shape_simplex_tree_map map_cgal_simplex_tree;
- std::vector<Alpha_value_type>::iterator the_alpha_value_iterator = the_alpha_values.begin();
- for (auto object_iterator : the_objects) {
- // Retrieve Alpha shape vertex list from object
- if (const Cell_handle *cell = CGAL::object_cast<Cell_handle>(&object_iterator)) {
- vertex_list = from_cell<Vertex_list, Cell_handle>(*cell);
- count_cells++;
- } else if (const Facet *facet = CGAL::object_cast<Facet>(&object_iterator)) {
- vertex_list = from_facet<Vertex_list, Facet>(*facet);
- count_facets++;
- } else if (const Edge_3 *edge = CGAL::object_cast<Edge_3>(&object_iterator)) {
- vertex_list = from_edge<Vertex_list, Edge_3>(*edge);
- count_edges++;
- } else if (const Vertex_handle *vertex = CGAL::object_cast<Vertex_handle>(&object_iterator)) {
- count_vertices++;
- vertex_list = from_vertex<Vertex_list, Vertex_handle>(*vertex);
- }
- // Construction of the vector of simplex_tree vertex from list of alpha_shapes vertex
- Simplex_tree_vector_vertex the_simplex;
- for (auto the_alpha_shape_vertex : vertex_list) {
- Alpha_shape_simplex_tree_map::iterator the_map_iterator = map_cgal_simplex_tree.find(the_alpha_shape_vertex);
- if (the_map_iterator == map_cgal_simplex_tree.end()) {
- // alpha shape not found
- Simplex_tree_vertex vertex = map_cgal_simplex_tree.size();
-#ifdef DEBUG_TRACES
- std::cout << "vertex [" << the_alpha_shape_vertex->point() << "] not found - insert " << vertex << std::endl;
-#endif // DEBUG_TRACES
- the_simplex.push_back(vertex);
- map_cgal_simplex_tree.emplace(the_alpha_shape_vertex, vertex);
- } else {
- // alpha shape found
- Simplex_tree_vertex vertex = the_map_iterator->second;
-#ifdef DEBUG_TRACES
- std::cout << "vertex [" << the_alpha_shape_vertex->point() << "] found in " << vertex << std::endl;
-#endif // DEBUG_TRACES
- the_simplex.push_back(vertex);
- }
- }
- // Construction of the simplex_tree
- Filtration_value filtr = /*std::sqrt*/ (*the_alpha_value_iterator);
-#ifdef DEBUG_TRACES
- std::cout << "filtration = " << filtr << std::endl;
-#endif // DEBUG_TRACES
- simplex_tree.insert_simplex(the_simplex, filtr);
- if (the_alpha_value_iterator != the_alpha_values.end())
- ++the_alpha_value_iterator;
- else
- std::cout << "This shall not happen" << std::endl;
- }
-
-#ifdef DEBUG_TRACES
- std::cout << "vertices \t\t" << count_vertices << std::endl;
- std::cout << "edges \t\t" << count_edges << std::endl;
- std::cout << "facets \t\t" << count_facets << std::endl;
- std::cout << "cells \t\t" << count_cells << std::endl;
-
- std::cout << "Information of the Simplex Tree: " << std::endl;
- std::cout << " Number of vertices = " << simplex_tree.num_vertices() << " ";
- std::cout << " Number of simplices = " << simplex_tree.num_simplices() << std::endl << std::endl;
- std::cout << " Dimension = " << simplex_tree.dimension() << " ";
-#endif // DEBUG_TRACES
-
-#ifdef DEBUG_TRACES
- std::cout << "Iterator on vertices: " << std::endl;
- for (auto vertex : simplex_tree.complex_vertex_range()) {
- std::cout << vertex << " ";
- }
-#endif // DEBUG_TRACES
-
- // Sort the simplices in the order of the filtration
- simplex_tree.initialize_filtration();
-
- std::cout << "Simplex_tree dim: " << simplex_tree.dimension() << std::endl;
- // Compute the persistence diagram of the complex
- Persistent_cohomology pcoh(simplex_tree, true);
- // initializes the coefficient field for homology
- pcoh.init_coefficients(coeff_field_characteristic);
-
- pcoh.compute_persistent_cohomology(min_persistence);
-
- // Output the diagram in filediag
- if (output_file_diag.empty()) {
- pcoh.output_diagram();
- } else {
- std::cout << "Result in file: " << output_file_diag << std::endl;
- std::ofstream out(output_file_diag);
- pcoh.output_diagram(out);
- out.close();
- }
-
- return 0;
-}
-
-void program_options(int argc, char *argv[], std::string &off_file_points, std::string &cuboid_file,
- std::string &output_file_diag, int &coeff_field_characteristic,
- Filtration_value &min_persistence) {
- namespace po = boost::program_options;
- po::options_description hidden("Hidden options");
- hidden.add_options()("input-file", po::value<std::string>(&off_file_points),
- "Name of file containing a point set. Format is one point per line: X1 ... Xd ")(
- "cuboid-file", po::value<std::string>(&cuboid_file),
- "Name of file describing the periodic domain. Format is: min_hx min_hy min_hz\nmax_hx max_hy max_hz");
-
- po::options_description visible("Allowed options", 100);
- visible.add_options()("help,h", "produce help message")(
- "output-file,o", po::value<std::string>(&output_file_diag)->default_value(std::string()),
- "Name of file in which the persistence diagram is written. Default print in std::cout")(
- "field-charac,p", po::value<int>(&coeff_field_characteristic)->default_value(11),
- "Characteristic p of the coefficient field Z/pZ for computing homology.")(
- "min-persistence,m", po::value<Filtration_value>(&min_persistence),
- "Minimal lifetime of homology feature to be recorded. Default is 0. Enter a negative value to see zero length "
- "intervals");
-
- po::positional_options_description pos;
- pos.add("input-file", 1);
- pos.add("cuboid-file", 2);
-
- po::options_description all;
- all.add(visible).add(hidden);
-
- po::variables_map vm;
- po::store(po::command_line_parser(argc, argv).options(all).positional(pos).run(), vm);
- po::notify(vm);
-
- if (vm.count("help") || !vm.count("input-file") || !vm.count("cuboid-file")) {
- std::cout << std::endl;
- std::cout << "Compute the persistent homology with coefficient field Z/pZ \n";
- std::cout << "of a periodic 3D Alpha complex defined on a set of input points.\n \n";
- std::cout << "The output diagram contains one bar per line, written with the convention: \n";
- std::cout << " p dim b d \n";
- std::cout << "where dim is the dimension of the homological feature,\n";
- std::cout << "b and d are respectively the birth and death of the feature and \n";
- std::cout << "p is the characteristic of the field Z/pZ used for homology coefficients." << std::endl << std::endl;
-
- std::cout << "Usage: " << argv[0] << " [options] input-file cuboid-file" << std::endl << std::endl;
- std::cout << visible << std::endl;
- exit(-1);
- }
-}
diff --git a/src/Alpha_complex/utilities/weighted_alpha_complex_3d_persistence.cpp b/src/Alpha_complex/utilities/weighted_alpha_complex_3d_persistence.cpp
deleted file mode 100644
index aa7ddee2..00000000
--- a/src/Alpha_complex/utilities/weighted_alpha_complex_3d_persistence.cpp
+++ /dev/null
@@ -1,316 +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) 2014 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 <http://www.gnu.org/licenses/>.
- */
-
-#include <boost/program_options.hpp>
-#include <boost/variant.hpp>
-
-#include <gudhi/Simplex_tree.h>
-#include <gudhi/Persistent_cohomology.h>
-#include <gudhi/Points_3D_off_io.h>
-
-#include <CGAL/config.h>
-#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
-#include <CGAL/Regular_triangulation_3.h>
-#include <CGAL/Alpha_shape_3.h>
-#include <CGAL/Alpha_shape_cell_base_3.h>
-#include <CGAL/Alpha_shape_vertex_base_3.h>
-#include <CGAL/iterator.h>
-
-// For CGAL < 4.11
-#if CGAL_VERSION_NR < 1041100000
-#include <CGAL/Regular_triangulation_euclidean_traits_3.h>
-#endif // CGAL_VERSION_NR < 1041100000
-
-#include <fstream>
-#include <cmath>
-#include <string>
-#include <tuple>
-#include <map>
-#include <utility>
-#include <vector>
-#include <cstdlib>
-
-#include "alpha_complex_3d_helper.h"
-
-// Alpha_shape_3 templates type definitions
-using Kernel = CGAL::Exact_predicates_inexact_constructions_kernel;
-
-// For CGAL < 4.11
-#if CGAL_VERSION_NR < 1041100000
-using Gt = CGAL::Regular_triangulation_euclidean_traits_3<Kernel>;
-using Vb = CGAL::Alpha_shape_vertex_base_3<Gt>;
-using Fb = CGAL::Alpha_shape_cell_base_3<Gt>;
-using Tds = CGAL::Triangulation_data_structure_3<Vb, Fb>;
-using Triangulation_3 = CGAL::Regular_triangulation_3<Gt, Tds>;
-
-// From file type definition
-using Point_3 = Gt::Bare_point;
-using Weighted_point_3 = Gt::Weighted_point;
-
-// For CGAL >= 4.11
-#else // CGAL_VERSION_NR < 1041100000
-using Rvb = CGAL::Regular_triangulation_vertex_base_3<Kernel>;
-using Vb = CGAL::Alpha_shape_vertex_base_3<Kernel, Rvb>;
-using Rcb = CGAL::Regular_triangulation_cell_base_3<Kernel>;
-using Cb = CGAL::Alpha_shape_cell_base_3<Kernel, Rcb>;
-using Tds = CGAL::Triangulation_data_structure_3<Vb, Cb>;
-using Triangulation_3 = CGAL::Regular_triangulation_3<Kernel, Tds>;
-
-// From file type definition
-using Point_3 = Triangulation_3::Bare_point;
-using Weighted_point_3 = Triangulation_3::Weighted_point;
-#endif // CGAL_VERSION_NR < 1041100000
-
-using Alpha_shape_3 = CGAL::Alpha_shape_3<Triangulation_3>;
-
-// filtration with alpha values needed type definition
-using Alpha_value_type = Alpha_shape_3::FT;
-using Object = CGAL::Object;
-using Dispatch =
- CGAL::Dispatch_output_iterator<CGAL::cpp11::tuple<Object, Alpha_value_type>,
- CGAL::cpp11::tuple<std::back_insert_iterator<std::vector<Object> >,
- std::back_insert_iterator<std::vector<Alpha_value_type> > > >;
-using Cell_handle = Alpha_shape_3::Cell_handle;
-using Facet = Alpha_shape_3::Facet;
-using Edge_3 = Alpha_shape_3::Edge;
-using Vertex_handle = Alpha_shape_3::Vertex_handle;
-using Vertex_list = std::vector<Alpha_shape_3::Vertex_handle>;
-
-// gudhi type definition
-using ST = Gudhi::Simplex_tree<Gudhi::Simplex_tree_options_fast_persistence>;
-using Filtration_value = ST::Filtration_value;
-using Simplex_tree_vertex = ST::Vertex_handle;
-using Alpha_shape_simplex_tree_map = std::map<Alpha_shape_3::Vertex_handle, Simplex_tree_vertex>;
-using Simplex_tree_vector_vertex = std::vector<Simplex_tree_vertex>;
-using Persistent_cohomology =
- Gudhi::persistent_cohomology::Persistent_cohomology<ST, Gudhi::persistent_cohomology::Field_Zp>;
-
-void program_options(int argc, char *argv[], std::string &off_file_points, std::string &weight_file,
- std::string &output_file_diag, int &coeff_field_characteristic, Filtration_value &min_persistence);
-
-int main(int argc, char **argv) {
- std::string off_file_points;
- std::string weight_file;
- std::string output_file_diag;
- int coeff_field_characteristic;
- Filtration_value min_persistence;
-
- program_options(argc, argv, off_file_points, weight_file, output_file_diag, coeff_field_characteristic,
- min_persistence);
-
- // Read the OFF file (input file name given as parameter) and triangulate points
- Gudhi::Points_3D_off_reader<Point_3> off_reader(off_file_points);
- // Check the read operation was correct
- if (!off_reader.is_valid()) {
- std::cerr << "Unable to read OFF file " << off_file_points << std::endl;
- exit(-1);
- }
-
- // Retrieve the points
- std::vector<Point_3> lp = off_reader.get_point_cloud();
-
- // Read weights information from file
- std::ifstream weights_ifstr(weight_file);
- std::vector<Weighted_point_3> wp;
- if (weights_ifstr.good()) {
- double weight = 0.0;
- std::size_t index = 0;
- wp.reserve(lp.size());
- // Attempt read the weight in a double format, return false if it fails
- while ((weights_ifstr >> weight) && (index < lp.size())) {
- wp.push_back(Weighted_point_3(lp[index], weight));
- index++;
- }
- if (index != lp.size()) {
- std::cerr << "Bad number of weights in file " << weight_file << std::endl;
- exit(-1);
- }
- } else {
- std::cerr << "Unable to read weights file " << weight_file << std::endl;
- exit(-1);
- }
-
- // alpha shape construction from points. CGAL has a strange behavior in REGULARIZED mode.
- Alpha_shape_3 as(wp.begin(), wp.end(), 0, Alpha_shape_3::GENERAL);
-#ifdef DEBUG_TRACES
- std::cout << "Alpha shape computed in GENERAL mode" << std::endl;
-#endif // DEBUG_TRACES
-
- // filtration with alpha values from alpha shape
- std::vector<Object> the_objects;
- std::vector<Alpha_value_type> the_alpha_values;
-
- Dispatch disp = CGAL::dispatch_output<Object, Alpha_value_type>(std::back_inserter(the_objects),
- std::back_inserter(the_alpha_values));
-
- as.filtration_with_alpha_values(disp);
-#ifdef DEBUG_TRACES
- std::cout << "filtration_with_alpha_values returns : " << the_objects.size() << " objects" << std::endl;
-#endif // DEBUG_TRACES
-
- Alpha_shape_3::size_type count_vertices = 0;
- Alpha_shape_3::size_type count_edges = 0;
- Alpha_shape_3::size_type count_facets = 0;
- Alpha_shape_3::size_type count_cells = 0;
-
- // Loop on objects vector
- Vertex_list vertex_list;
- ST simplex_tree;
- Alpha_shape_simplex_tree_map map_cgal_simplex_tree;
- std::vector<Alpha_value_type>::iterator the_alpha_value_iterator = the_alpha_values.begin();
- for (auto object_iterator : the_objects) {
- // Retrieve Alpha shape vertex list from object
- if (const Cell_handle *cell = CGAL::object_cast<Cell_handle>(&object_iterator)) {
- vertex_list = from_cell<Vertex_list, Cell_handle>(*cell);
- count_cells++;
- } else if (const Facet *facet = CGAL::object_cast<Facet>(&object_iterator)) {
- vertex_list = from_facet<Vertex_list, Facet>(*facet);
- count_facets++;
- } else if (const Edge_3 *edge = CGAL::object_cast<Edge_3>(&object_iterator)) {
- vertex_list = from_edge<Vertex_list, Edge_3>(*edge);
- count_edges++;
- } else if (const Vertex_handle *vertex = CGAL::object_cast<Vertex_handle>(&object_iterator)) {
- count_vertices++;
- vertex_list = from_vertex<Vertex_list, Vertex_handle>(*vertex);
- }
- // Construction of the vector of simplex_tree vertex from list of alpha_shapes vertex
- Simplex_tree_vector_vertex the_simplex;
- for (auto the_alpha_shape_vertex : vertex_list) {
- Alpha_shape_simplex_tree_map::iterator the_map_iterator = map_cgal_simplex_tree.find(the_alpha_shape_vertex);
- if (the_map_iterator == map_cgal_simplex_tree.end()) {
- // alpha shape not found
- Simplex_tree_vertex vertex = map_cgal_simplex_tree.size();
-#ifdef DEBUG_TRACES
- std::cout << "vertex [" << the_alpha_shape_vertex->point() << "] not found - insert " << vertex << std::endl;
-#endif // DEBUG_TRACES
- the_simplex.push_back(vertex);
- map_cgal_simplex_tree.emplace(the_alpha_shape_vertex, vertex);
- } else {
- // alpha shape found
- Simplex_tree_vertex vertex = the_map_iterator->second;
-#ifdef DEBUG_TRACES
- std::cout << "vertex [" << the_alpha_shape_vertex->point() << "] found in " << vertex << std::endl;
-#endif // DEBUG_TRACES
- the_simplex.push_back(vertex);
- }
- }
- // Construction of the simplex_tree
- Filtration_value filtr = /*std::sqrt*/ (*the_alpha_value_iterator);
-#ifdef DEBUG_TRACES
- std::cout << "filtration = " << filtr << std::endl;
-#endif // DEBUG_TRACES
- simplex_tree.insert_simplex(the_simplex, filtr);
- if (the_alpha_value_iterator != the_alpha_values.end())
- ++the_alpha_value_iterator;
- else
- std::cout << "This shall not happen" << std::endl;
- }
-
-#ifdef DEBUG_TRACES
- std::cout << "vertices \t\t" << count_vertices << std::endl;
- std::cout << "edges \t\t" << count_edges << std::endl;
- std::cout << "facets \t\t" << count_facets << std::endl;
- std::cout << "cells \t\t" << count_cells << std::endl;
-
- std::cout << "Information of the Simplex Tree: " << std::endl;
- std::cout << " Number of vertices = " << simplex_tree.num_vertices() << " ";
- std::cout << " Number of simplices = " << simplex_tree.num_simplices() << std::endl << std::endl;
- std::cout << " Dimension = " << simplex_tree.dimension() << " ";
-#endif // DEBUG_TRACES
-
-#ifdef DEBUG_TRACES
- std::cout << "Iterator on vertices: " << std::endl;
- for (auto vertex : simplex_tree.complex_vertex_range()) {
- std::cout << vertex << " ";
- }
-#endif // DEBUG_TRACES
-
- // Sort the simplices in the order of the filtration
- simplex_tree.initialize_filtration();
-
- std::cout << "Simplex_tree dim: " << simplex_tree.dimension() << std::endl;
- // Compute the persistence diagram of the complex
- Persistent_cohomology pcoh(simplex_tree, true);
- // initializes the coefficient field for homology
- pcoh.init_coefficients(coeff_field_characteristic);
-
- pcoh.compute_persistent_cohomology(min_persistence);
-
- // Output the diagram in filediag
- if (output_file_diag.empty()) {
- pcoh.output_diagram();
- } else {
- std::cout << "Result in file: " << output_file_diag << std::endl;
- std::ofstream out(output_file_diag);
- pcoh.output_diagram(out);
- out.close();
- }
-
- return 0;
-}
-
-void program_options(int argc, char *argv[], std::string &off_file_points, std::string &weight_file,
- std::string &output_file_diag, int &coeff_field_characteristic,
- Filtration_value &min_persistence) {
- namespace po = boost::program_options;
- po::options_description hidden("Hidden options");
- hidden.add_options()("input-file", po::value<std::string>(&off_file_points),
- "Name of file containing a point set. Format is one point per line: X1 ... Xd ")(
- "weight-file", po::value<std::string>(&weight_file),
- "Name of file containing a point weights. Format is one weigt per line: W1\n...\nWn ");
-
- po::options_description visible("Allowed options", 100);
- visible.add_options()("help,h", "produce help message")(
- "output-file,o", po::value<std::string>(&output_file_diag)->default_value(std::string()),
- "Name of file in which the persistence diagram is written. Default print in std::cout")(
- "field-charac,p", po::value<int>(&coeff_field_characteristic)->default_value(11),
- "Characteristic p of the coefficient field Z/pZ for computing homology.")(
- "min-persistence,m", po::value<Filtration_value>(&min_persistence),
- "Minimal lifetime of homology feature to be recorded. Default is 0. Enter a negative value to see zero length "
- "intervals");
-
- po::positional_options_description pos;
- pos.add("input-file", 1);
- pos.add("weight-file", 2);
-
- po::options_description all;
- all.add(visible).add(hidden);
-
- po::variables_map vm;
- po::store(po::command_line_parser(argc, argv).options(all).positional(pos).run(), vm);
- po::notify(vm);
-
- if (vm.count("help") || !vm.count("input-file") || !vm.count("weight-file")) {
- std::cout << std::endl;
- std::cout << "Compute the persistent homology with coefficient field Z/pZ \n";
- std::cout << "of a weighted 3D Alpha complex defined on a set of input points.\n \n";
- std::cout << "The output diagram contains one bar per line, written with the convention: \n";
- std::cout << " p dim b d \n";
- std::cout << "where dim is the dimension of the homological feature,\n";
- std::cout << "b and d are respectively the birth and death of the feature and \n";
- std::cout << "p is the characteristic of the field Z/pZ used for homology coefficients." << std::endl << std::endl;
-
- std::cout << "Usage: " << argv[0] << " [options] input-file weight-file" << std::endl << std::endl;
- std::cout << visible << std::endl;
- exit(-1);
- }
-}
diff --git a/src/Alpha_complex/utilities/weighted_periodic_alpha_complex_3d_persistence.cpp b/src/Alpha_complex/utilities/weighted_periodic_alpha_complex_3d_persistence.cpp
deleted file mode 100644
index d030c88c..00000000
--- a/src/Alpha_complex/utilities/weighted_periodic_alpha_complex_3d_persistence.cpp
+++ /dev/null
@@ -1,288 +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
- * Pawel Dlotko - 2017 - Swansea University, UK
- *
- * Copyright (C) 2014 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 <http://www.gnu.org/licenses/>.
- */
-
-#include <boost/variant.hpp>
-
-#include <gudhi/Simplex_tree.h>
-#include <gudhi/Persistent_cohomology.h>
-#include <gudhi/Points_3D_off_io.h>
-
-#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
-#include <CGAL/Periodic_3_regular_triangulation_traits_3.h>
-#include <CGAL/Periodic_3_regular_triangulation_3.h>
-#include <CGAL/Alpha_shape_3.h>
-#include <CGAL/Alpha_shape_cell_base_3.h>
-#include <CGAL/Alpha_shape_vertex_base_3.h>
-#include <CGAL/iterator.h>
-
-#include <fstream>
-#include <cmath>
-#include <string>
-#include <tuple>
-#include <map>
-#include <utility>
-#include <vector>
-#include <cstdlib>
-
-#include "alpha_complex_3d_helper.h"
-
-// Traits
-using Kernel = CGAL::Exact_predicates_inexact_constructions_kernel;
-using PK = CGAL::Periodic_3_regular_triangulation_traits_3<Kernel>;
-
-// Vertex type
-using DsVb = CGAL::Periodic_3_triangulation_ds_vertex_base_3<>;
-using Vb = CGAL::Regular_triangulation_vertex_base_3<PK, DsVb>;
-using AsVb = CGAL::Alpha_shape_vertex_base_3<PK, Vb>;
-// Cell type
-using DsCb = CGAL::Periodic_3_triangulation_ds_cell_base_3<>;
-using Cb = CGAL::Regular_triangulation_cell_base_3<PK, DsCb>;
-using AsCb = CGAL::Alpha_shape_cell_base_3<PK, Cb>;
-using Tds = CGAL::Triangulation_data_structure_3<AsVb, AsCb>;
-using P3RT3 = CGAL::Periodic_3_regular_triangulation_3<PK, Tds>;
-using Alpha_shape_3 = CGAL::Alpha_shape_3<P3RT3>;
-
-using Point_3 = P3RT3::Bare_point;
-using Weighted_point_3 = P3RT3::Weighted_point;
-
-// filtration with alpha values needed type definition
-using Alpha_value_type = Alpha_shape_3::FT;
-using Object = CGAL::Object;
-using Dispatch =
- CGAL::Dispatch_output_iterator<CGAL::cpp11::tuple<Object, Alpha_value_type>,
- CGAL::cpp11::tuple<std::back_insert_iterator<std::vector<Object> >,
- std::back_insert_iterator<std::vector<Alpha_value_type> > > >;
-using Cell_handle = Alpha_shape_3::Cell_handle;
-using Facet = Alpha_shape_3::Facet;
-using Edge_3 = Alpha_shape_3::Edge;
-using Vertex_handle = Alpha_shape_3::Vertex_handle;
-using Vertex_list = std::vector<Alpha_shape_3::Vertex_handle>;
-
-// gudhi type definition
-using ST = Gudhi::Simplex_tree<Gudhi::Simplex_tree_options_fast_persistence>;
-using Filtration_value = ST::Filtration_value;
-using Simplex_tree_vertex = ST::Vertex_handle;
-using Alpha_shape_simplex_tree_map = std::map<Alpha_shape_3::Vertex_handle, Simplex_tree_vertex>;
-using Simplex_tree_vector_vertex = std::vector<Simplex_tree_vertex>;
-using Persistent_cohomology =
- Gudhi::persistent_cohomology::Persistent_cohomology<ST, Gudhi::persistent_cohomology::Field_Zp>;
-
-void usage(const std::string& progName) {
- std::cerr << "Usage: " << progName << " path_to_the_OFF_file path_to_weight_file path_to_the_cuboid_file "
- "coeff_field_characteristic[integer > 0] min_persistence[float >= -1.0]\n";
- exit(-1);
-}
-
-int main(int argc, char* const argv[]) {
- // program args management
- if (argc != 6) {
- std::cerr << "Error: Number of arguments (" << argc << ") is not correct\n";
- usage(argv[0]);
- }
-
- int coeff_field_characteristic = atoi(argv[4]);
- Filtration_value min_persistence = strtof(argv[5], nullptr);
-
- // Read points from file
- std::string offInputFile(argv[1]);
- // Read the OFF file (input file name given as parameter) and triangulate points
- Gudhi::Points_3D_off_reader<Point_3> off_reader(offInputFile);
- // Check the read operation was correct
- if (!off_reader.is_valid()) {
- std::cerr << "Unable to read file " << offInputFile << std::endl;
- usage(argv[0]);
- }
-
- // Retrieve the points
- std::vector<Point_3> lp = off_reader.get_point_cloud();
-
- // Read iso_cuboid_3 information from file
- std::ifstream iso_cuboid_str(argv[3]);
- double x_min, y_min, z_min, x_max, y_max, z_max;
- if (iso_cuboid_str.is_open()) {
- if (!(iso_cuboid_str >> x_min >> y_min >> z_min >> x_max >> y_max >> z_max)) {
- std::cerr << argv[3] << " - Bad file format." << std::endl;
- usage(argv[0]);
- }
-
- } else {
- std::cerr << "Unable to read file " << argv[3] << std::endl;
- usage(argv[0]);
- }
- // Checking if the cuboid is the same in x,y and z direction. If not, CGAL will not process it.
- if ((x_max - x_min != y_max - y_min) || (x_max - x_min != z_max - z_min) || (z_max - z_min != y_max - y_min)) {
- std::cerr << "The size of the cuboid in every directions is not the same." << std::endl;
- exit(-1);
- }
-
- double maximal_possible_weight = 0.015625 * (x_max - x_min) * (x_max - x_min);
-
- // Read weights information from file
- std::ifstream weights_ifstr(argv[2]);
- std::vector<Weighted_point_3> wp;
- if (weights_ifstr.is_open()) {
- double weight = 0.0;
- std::size_t index = 0;
- wp.reserve(lp.size());
- // Attempt read the weight in a double format, return false if it fails
- while ((weights_ifstr >> weight) && (index < lp.size())) {
- if ((weight >= maximal_possible_weight) || (weight < 0)) {
- std::cerr << "At line " << (index + 1) << ", the weight (" << weight
- << ") is negative or more than or equal to maximal possible weight (" << maximal_possible_weight
- << ") = 1/64*cuboid length squared, which is not an acceptable input." << std::endl;
- exit(-1);
- }
-
- wp.push_back(Weighted_point_3(lp[index], weight));
- index++;
- }
- if (index != lp.size()) {
- std::cerr << "Bad number of weights in file " << argv[2] << std::endl;
- usage(argv[0]);
- }
- } else {
- std::cerr << "Unable to read file " << argv[2] << std::endl;
- usage(argv[0]);
- }
-
- // Define the periodic cube
- P3RT3 prt(PK::Iso_cuboid_3(x_min, y_min, z_min, x_max, y_max, z_max));
- // Heuristic for inserting large point sets (if pts is reasonably large)
- prt.insert(wp.begin(), wp.end(), true);
- // As prt won't be modified anymore switch to 1-sheeted cover if possible
- if (prt.is_triangulation_in_1_sheet()) {
- prt.convert_to_1_sheeted_covering();
- } else {
- std::cerr << "ERROR: we were not able to construct a triangulation within a single periodic domain." << std::endl;
- exit(-1);
- }
- std::cout << "Weighted Periodic Delaunay computed." << std::endl;
-
- // alpha shape construction from points. CGAL has a strange behavior in REGULARIZED mode. This is the default mode
- // Maybe need to set it to GENERAL mode
- Alpha_shape_3 as(prt, 0, Alpha_shape_3::GENERAL);
-
- // filtration with alpha values from alpha shape
- std::vector<Object> the_objects;
- std::vector<Alpha_value_type> the_alpha_values;
-
- Dispatch disp = CGAL::dispatch_output<Object, Alpha_value_type>(std::back_inserter(the_objects),
- std::back_inserter(the_alpha_values));
-
- as.filtration_with_alpha_values(disp);
-#ifdef DEBUG_TRACES
- std::cout << "filtration_with_alpha_values returns : " << the_objects.size() << " objects" << std::endl;
-#endif // DEBUG_TRACES
-
- Alpha_shape_3::size_type count_vertices = 0;
- Alpha_shape_3::size_type count_edges = 0;
- Alpha_shape_3::size_type count_facets = 0;
- Alpha_shape_3::size_type count_cells = 0;
-
- // Loop on objects vector
- Vertex_list vertex_list;
- ST simplex_tree;
- Alpha_shape_simplex_tree_map map_cgal_simplex_tree;
- std::vector<Alpha_value_type>::iterator the_alpha_value_iterator = the_alpha_values.begin();
- for (auto object_iterator : the_objects) {
- // Retrieve Alpha shape vertex list from object
- if (const Cell_handle* cell = CGAL::object_cast<Cell_handle>(&object_iterator)) {
- vertex_list = from_cell<Vertex_list, Cell_handle>(*cell);
- count_cells++;
- } else if (const Facet* facet = CGAL::object_cast<Facet>(&object_iterator)) {
- vertex_list = from_facet<Vertex_list, Facet>(*facet);
- count_facets++;
- } else if (const Edge_3* edge = CGAL::object_cast<Edge_3>(&object_iterator)) {
- vertex_list = from_edge<Vertex_list, Edge_3>(*edge);
- count_edges++;
- } else if (const Vertex_handle* vertex = CGAL::object_cast<Vertex_handle>(&object_iterator)) {
- count_vertices++;
- vertex_list = from_vertex<Vertex_list, Vertex_handle>(*vertex);
- }
- // Construction of the vector of simplex_tree vertex from list of alpha_shapes vertex
- Simplex_tree_vector_vertex the_simplex;
- for (auto the_alpha_shape_vertex : vertex_list) {
- Alpha_shape_simplex_tree_map::iterator the_map_iterator = map_cgal_simplex_tree.find(the_alpha_shape_vertex);
- if (the_map_iterator == map_cgal_simplex_tree.end()) {
- // alpha shape not found
- Simplex_tree_vertex vertex = map_cgal_simplex_tree.size();
-#ifdef DEBUG_TRACES
- std::cout << "vertex [" << the_alpha_shape_vertex->point() << "] not found - insert " << vertex << std::endl;
-#endif // DEBUG_TRACES
- the_simplex.push_back(vertex);
- map_cgal_simplex_tree.emplace(the_alpha_shape_vertex, vertex);
- } else {
- // alpha shape found
- Simplex_tree_vertex vertex = the_map_iterator->second;
-#ifdef DEBUG_TRACES
- std::cout << "vertex [" << the_alpha_shape_vertex->point() << "] found in " << vertex << std::endl;
-#endif // DEBUG_TRACES
- the_simplex.push_back(vertex);
- }
- }
- // Construction of the simplex_tree
- Filtration_value filtr = /*std::sqrt*/ (*the_alpha_value_iterator);
-#ifdef DEBUG_TRACES
- std::cout << "filtration = " << filtr << std::endl;
-#endif // DEBUG_TRACES
- simplex_tree.insert_simplex(the_simplex, filtr);
- if (the_alpha_value_iterator != the_alpha_values.end())
- ++the_alpha_value_iterator;
- else
- std::cout << "This shall not happen" << std::endl;
- }
-
-#ifdef DEBUG_TRACES
- std::cout << "vertices \t\t" << count_vertices << std::endl;
- std::cout << "edges \t\t" << count_edges << std::endl;
- std::cout << "facets \t\t" << count_facets << std::endl;
- std::cout << "cells \t\t" << count_cells << std::endl;
-
- std::cout << "Information of the Simplex Tree: " << std::endl;
- std::cout << " Number of vertices = " << simplex_tree.num_vertices() << " ";
- std::cout << " Number of simplices = " << simplex_tree.num_simplices() << std::endl << std::endl;
- std::cout << " Dimension = " << simplex_tree.dimension() << " ";
-#endif // DEBUG_TRACES
-
-#ifdef DEBUG_TRACES
- std::cout << "Iterator on vertices: " << std::endl;
- for (auto vertex : simplex_tree.complex_vertex_range()) {
- std::cout << vertex << " ";
- }
-#endif // DEBUG_TRACES
-
- // Sort the simplices in the order of the filtration
- simplex_tree.initialize_filtration();
-
- std::cout << "Simplex_tree dim: " << simplex_tree.dimension() << std::endl;
- // Compute the persistence diagram of the complex
- Persistent_cohomology pcoh(simplex_tree, true);
- // initializes the coefficient field for homology
- pcoh.init_coefficients(coeff_field_characteristic);
-
- pcoh.compute_persistent_cohomology(min_persistence);
-
- pcoh.output_diagram();
-
- return 0;
-}
diff --git a/src/common/doc/examples.h b/src/common/doc/examples.h
index 40f202c7..c19b3444 100644
--- a/src/common/doc/examples.h
+++ b/src/common/doc/examples.h
@@ -53,10 +53,7 @@
* @example Spatial_searching/example_spatial_searching.cpp
* @example Alpha_complex/alpha_complex_3d_persistence.cpp
* @example Alpha_complex/alpha_complex_persistence.cpp
- * @example Alpha_complex/weighted_periodic_alpha_complex_3d_persistence.cpp
- * @example Alpha_complex/weighted_alpha_complex_3d_persistence.cpp
- * @example Alpha_complex/periodic_alpha_complex_3d_persistence.cpp
- * @example Alpha_complex/exact_alpha_complex_3d_persistence.cpp
+ * @example Alpha_complex/Weighted_alpha_complex_3d_from_points.cpp
* @example Bottleneck_distance/bottleneck_distance.cpp
* @example Witness_complex/weak_witness_persistence.cpp
* @example Witness_complex/strong_witness_persistence.cpp
diff --git a/src/common/doc/installation.h b/src/common/doc/installation.h
index 12407c18..d36a216f 100644
--- a/src/common/doc/installation.h
+++ b/src/common/doc/installation.h
@@ -56,12 +56,6 @@ make doxygen
*
* The following examples/utilities require the <a target="_blank" href="http://www.cgal.org/">Computational Geometry Algorithms
* Library</a> (CGAL \cite cgal:eb-15b) and will not be built if CGAL is not installed:
- * \li <a href="_alpha_complex_2alpha_complex_3d_persistence_8cpp-example.html">
- * Alpha_complex/alpha_complex_3d_persistence.cpp</a>
- * \li <a href="_alpha_complex_2exact_alpha_complex_3d_persistence_8cpp-example.html">
- * Alpha_complex/exact_alpha_complex_3d_persistence.cpp</a>
- * \li <a href="_alpha_complex_2weighted_alpha_complex_3d_persistence_8cpp-example.html">
- * Alpha_complex/weighted_alpha_complex_3d_persistence.cpp</a>
* \li <a href="_simplex_tree_2example_alpha_shapes_3_simplex_tree_from_off_file_8cpp-example.html">
* Simplex_tree/example_alpha_shapes_3_simplex_tree_from_off_file.cpp</a>
*
@@ -84,8 +78,6 @@ make doxygen
* Alpha_complex/Alpha_complex_from_points.cpp</a>
* \li <a href="_alpha_complex_2alpha_complex_persistence_8cpp-example.html">
* Alpha_complex/alpha_complex_persistence.cpp</a>
- * \li <a href="_alpha_complex_2periodic_alpha_complex_3d_persistence_8cpp-example.html">
- * Alpha_complex/periodic_alpha_complex_3d_persistence.cpp</a>
* \li <a href="_persistent_cohomology_2custom_persistence_sort_8cpp-example.html">
* Persistent_cohomology/custom_persistence_sort.cpp</a>
*
@@ -119,6 +111,12 @@ make doxygen
* \li <a href="_tangential_complex_2example_with_perturb_8cpp-example.html">
* Tangential_complex/example_with_perturb.cpp</a>
*
+ * The following example requires CGAL version &ge; 4.11.0:
+ * \li <a href="_alpha_complex_2_weighted_alpha_complex_3d_from_points_8cpp-example.html">
+ * Alpha_complex/Weighted_alpha_complex_3d_from_points.cpp</a>
+ * \li <a href="_alpha_complex_2alpha_complex_3d_persistence_8cpp-example.html">
+ * Alpha_complex/alpha_complex_3d_persistence.cpp</a>
+ *
* \subsection eigen3 Eigen3
* The \ref alpha_complex data structure and few examples requires
* <a target="_blank" href="http://eigen.tuxfamily.org/">Eigen3</a> is a C++ template library for linear algebra:
@@ -132,8 +130,10 @@ make doxygen
* Alpha_complex/Alpha_complex_from_points.cpp</a>
* \li <a href="_alpha_complex_2alpha_complex_persistence_8cpp-example.html">
* Alpha_complex/alpha_complex_persistence.cpp</a>
- * \li <a href="_alpha_complex_2periodic_alpha_complex_3d_persistence_8cpp-example.html">
- * Alpha_complex/periodic_alpha_complex_3d_persistence.cpp</a>
+ * \li <a href="_alpha_complex_2alpha_complex_3d_persistence_8cpp-example.html">
+ * Alpha_complex/alpha_complex_3d_persistence.cpp</a>
+ * \li <a href="_alpha_complex_2_weighted_alpha_complex_3d_from_points_8cpp-example.html">
+ * Alpha_complex/Weighted_alpha_complex_3d_from_points.cpp</a>
* \li <a href="_bottleneck_distance_2alpha_rips_persistence_bottleneck_distance_8cpp-example.html">
* Bottleneck_distance/alpha_rips_persistence_bottleneck_distance.cpp.cpp</a>
* \li <a href="_persistent_cohomology_2custom_persistence_sort_8cpp-example.html">
@@ -179,12 +179,6 @@ make doxygen
* Alpha_complex/alpha_complex_3d_persistence.cpp</a>
* \li <a href="_alpha_complex_2alpha_complex_persistence_8cpp-example.html">
* Alpha_complex/alpha_complex_persistence.cpp</a>
- * \li <a href="_alpha_complex_2exact_alpha_complex_3d_persistence_8cpp-example.html">
- * Alpha_complex/exact_alpha_complex_3d_persistence.cpp</a>
- * \li <a href="_alpha_complex_2periodic_alpha_complex_3d_persistence_8cpp-example.html">
- * Alpha_complex/periodic_alpha_complex_3d_persistence.cpp</a>
- * \li <a href="_alpha_complex_2weighted_alpha_complex_3d_persistence_8cpp-example.html">
- * Alpha_complex/weighted_alpha_complex_3d_persistence.cpp</a>
* \li <a href="_bitmap_cubical_complex_2_bitmap_cubical_complex_8cpp-example.html">
* Bitmap_cubical_complex/cubical_complex_persistence.cpp</a>
* \li <a href="_bitmap_cubical_complex_2_bitmap_cubical_complex_periodic_boundary_conditions_8cpp-example.html">
@@ -223,10 +217,6 @@ make doxygen
* Persistent_cohomology/rips_multifield_persistence.cpp</a>
* \li <a href="_persistent_cohomology_2rips_persistence_step_by_step_8cpp-example.html">
* Persistent_cohomology/rips_persistence_step_by_step.cpp</a>
- * \li <a href="_persistent_cohomology_2exact_alpha_complex_3d_persistence_8cpp-example.html">
- * Persistent_cohomology/exact_alpha_complex_3d_persistence.cpp</a>
- * \li <a href="_persistent_cohomology_2weighted_alpha_complex_3d_persistence_8cpp-example.html">
- * Persistent_cohomology/weighted_alpha_complex_3d_persistence.cpp</a>
* \li <a href="_persistent_cohomology_2custom_persistence_sort_8cpp-example.html">
* Persistent_cohomology/custom_persistence_sort.cpp</a>
* \li <a href="_rips_complex_2example_one_skeleton_rips_from_points_8cpp-example.html">
diff --git a/src/common/doc/main_page.h b/src/common/doc/main_page.h
index db1e80ce..35b84d2e 100644
--- a/src/common/doc/main_page.h
+++ b/src/common/doc/main_page.h
@@ -29,7 +29,7 @@
<b>Author:</b> Vincent Rouvreau<br>
<b>Introduced in:</b> GUDHI 1.3.0<br>
<b>Copyright:</b> GPL v3<br>
- <b>Requires:</b> \ref cgal &ge; 4.7.0 and \ref eigen3
+ <b>Requires:</b> \ref cgal &ge; 4.11.0 and \ref eigen3
</td>
<td width="75%">
Alpha_complex is a simplicial complex constructed from the finite cells of a Delaunay Triangulation.<br>