summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2018-07-31 14:33:49 +0000
committervrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2018-07-31 14:33:49 +0000
commitc89ae478ea5d6685c862533fac1aea973e9cda02 (patch)
tree8557a50f16155e082cc8b76ffd1831a5a3969604
parentd5b5de5aa50c2fdc73d00bbdcf295caf44237a34 (diff)
Add unitary tests and documentation
Fix debug exception mechanism git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/alpha_complex_3d_module_vincent@3712 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 43f66f3843981ab9cd74c117c2b1c6bb9b94810b
-rw-r--r--src/Alpha_complex/doc/Intro_alpha_complex.h23
-rw-r--r--src/Alpha_complex/example/CMakeLists.txt10
-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.h10
-rw-r--r--src/Alpha_complex/test/Alpha_complex_3d_unit_test.cpp (renamed from src/Alpha_complex/example/traits_test.cpp)373
-rw-r--r--src/Alpha_complex/test/CMakeLists.txt7
-rw-r--r--src/Alpha_complex/utilities/alpha_complex_3d_persistence.cpp29
-rw-r--r--src/Alpha_complex/utilities/alphacomplex.md44
9 files changed, 507 insertions, 91 deletions
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 af4bfd74..4a1cd26d 100644
--- a/src/Alpha_complex/example/CMakeLists.txt
+++ b/src/Alpha_complex/example/CMakeLists.txt
@@ -30,4 +30,14 @@ if(CGAL_FOUND)
${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>)
+
+ 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
index f37c0816..15acd7bd 100644
--- a/src/Alpha_complex/include/gudhi/Alpha_complex_3d.h
+++ b/src/Alpha_complex/include/gudhi/Alpha_complex_3d.h
@@ -216,8 +216,8 @@ public:
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) ||
+ 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."));
@@ -295,8 +295,8 @@ public:
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) ||
+ 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."));
@@ -312,7 +312,7 @@ public:
#endif
while ((index < weights.size()) && (index < points.size())) {
- GUDHI_CHECK((weights[index] < maximal_possible_weight) || (weights[index] >= 0),
+ 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."));
diff --git a/src/Alpha_complex/example/traits_test.cpp b/src/Alpha_complex/test/Alpha_complex_3d_unit_test.cpp
index 1dd062de..7873deca 100644
--- a/src/Alpha_complex/example/traits_test.cpp
+++ b/src/Alpha_complex/test/Alpha_complex_3d_unit_test.cpp
@@ -1,24 +1,55 @@
-#include <gudhi/Alpha_complex_3d.h>
-#include <gudhi/Simplex_tree.h>
+/* 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 <iostream>
+#include <cmath> // float comparison
+#include <limits>
#include <string>
#include <vector>
-#include <limits> // for numeric limits
#include <random>
-void usage(int nbArgs, char * const progName) {
- std::cerr << "Error: Number of arguments (" << nbArgs << ") is not correct\n";
- std::cerr << "Usage: " << progName << " [alpha_square_max_value]\n";
- std::cerr << " i.e.: " << progName << " 60.0\n";
- exit(-1); // ----- >>
-}
+#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>
-int main(int argc, char **argv) {
- //if ((argc != 1) && (argc != 2)) usage(argc, (argv[0] - 1));
+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;
- using Alpha_shapes_3d = Gudhi::alpha_complex::Alpha_shapes_3d;
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));
@@ -32,21 +63,78 @@ int main(int argc, char **argv) {
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;
- std::vector<Exact_alpha_shapes_3d::Point_3> e_points;
- e_points.push_back(Exact_alpha_shapes_3d::Point_3(0.0, 0.0, 0.0));
- e_points.push_back(Exact_alpha_shapes_3d::Point_3(0.0, 0.0, 0.2));
- e_points.push_back(Exact_alpha_shapes_3d::Point_3(0.2, 0.0, 0.2));
- e_points.push_back(Exact_alpha_shapes_3d::Point_3(0.6, 0.6, 0.0));
- e_points.push_back(Exact_alpha_shapes_3d::Point_3(0.8, 0.8, 0.2));
- e_points.push_back(Exact_alpha_shapes_3d::Point_3(0.2, 0.8, 0.6));
- Gudhi::alpha_complex::Alpha_complex_3d<Exact_alpha_shapes_3d> exact_alpha_complex(e_points);
+ Gudhi::alpha_complex::Alpha_complex_3d<Exact_alpha_shapes_3d> exact_alpha_complex(points);
- Gudhi::Simplex_tree<Gudhi::Simplex_tree_options_fast_persistence> exact_stree;
+ 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;
@@ -57,15 +145,44 @@ int main(int argc, char **argv) {
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;
- using Periodic_alpha_shapes_3d = Gudhi::alpha_complex::Periodic_alpha_shapes_3d;
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));
@@ -201,8 +318,19 @@ int main(int argc, char **argv) {
Gudhi::Simplex_tree<> p_stree;
periodic_alpha_complex.create_complex(p_stree);
- std::cout << "Weighted periodic alpha complex 3d" << std::endl;
- using Weighted_periodic_alpha_shapes_3d = Gudhi::alpha_complex::Weighted_periodic_alpha_shapes_3d;
+ 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));
@@ -339,16 +467,197 @@ int main(int argc, char **argv) {
for (std::size_t i = 0; i < wp_points.size(); ++i) {
double value = dist(mt);
- std::cout << value << std::endl;
p_weights.push_back(value);
}
- Gudhi::alpha_complex::Alpha_complex_3d<Weighted_periodic_alpha_shapes_3d>
- weighted_periodic_alpha_complex(wp_points, p_weights,
- 0., 0., 0.,
- 1., 1., 1.);
+ 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);
- return 0;
+ 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/alpha_complex_3d_persistence.cpp b/src/Alpha_complex/utilities/alpha_complex_3d_persistence.cpp
index 00ede9ce..536de444 100644
--- a/src/Alpha_complex/utilities/alpha_complex_3d_persistence.cpp
+++ b/src/Alpha_complex/utilities/alpha_complex_3d_persistence.cpp
@@ -45,12 +45,13 @@ using Persistent_cohomology =
Gudhi::persistent_cohomology::Persistent_cohomology<Simplex_tree, Gudhi::persistent_cohomology::Field_Zp>;
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, int &coeff_field_characteristic,
- Filtration_value &min_persistence);
+ 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) {
- return alpha_complex.create_complex(simplex_tree);
+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) {
@@ -87,6 +88,7 @@ int main(int argc, char **argv) {
std::string weight_file;
std::string cuboid_file;
std::string output_file_diag;
+ Filtration_value alpha_square_max_value = 0.;
int coeff_field_characteristic = 0;
Filtration_value min_persistence = 0.;
bool exact_version = false;
@@ -94,7 +96,7 @@ int main(int argc, char **argv) {
bool periodic_version = false;
program_options(argc, argv, off_file_points, exact_version, weight_file, cuboid_file, output_file_diag,
- coeff_field_characteristic, min_persistence);
+ 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<Alpha_complex_3d::Point_3> off_reader(off_file_points);
@@ -131,25 +133,25 @@ int main(int argc, char **argv) {
exit(-1);
} else {
Exact_alpha_complex_3d alpha_complex(off_reader.get_point_cloud());
- create_complex(alpha_complex, simplex_tree);
+ create_complex(alpha_complex, simplex_tree, alpha_square_max_value);
}
} 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);
+ 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);
+ 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);
+ create_complex(alpha_complex, simplex_tree, alpha_square_max_value);
} else {
Alpha_complex_3d alpha_complex(off_reader.get_point_cloud());
- create_complex(alpha_complex, simplex_tree);
+ create_complex(alpha_complex, simplex_tree, alpha_square_max_value);
}
}
}
@@ -179,8 +181,8 @@ int main(int argc, char **argv) {
}
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, int &coeff_field_characteristic,
- Filtration_value &min_persistence) {
+ 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");
hidden.add_options()("input-file", po::value<std::string>(&off_file_points),
@@ -196,6 +198,9 @@ void program_options(int argc, char *argv[], std::string &off_file_points, bool&
"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),
diff --git a/src/Alpha_complex/utilities/alphacomplex.md b/src/Alpha_complex/utilities/alphacomplex.md
index 7ae5f913..7fc6cc0c 100644
--- a/src/Alpha_complex/utilities/alphacomplex.md
+++ b/src/Alpha_complex/utilities/alphacomplex.md
@@ -94,6 +94,8 @@ where `<input OFF file>` is the path to the input point cloud in
* `-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
@@ -120,45 +122,3 @@ N.B.:
[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.
-
-
-
-
-
-
-
-
-## 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.