summaryrefslogtreecommitdiff
path: root/src/Alpha_complex
diff options
context:
space:
mode:
authorvrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2018-11-23 09:06:04 +0000
committervrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2018-11-23 09:06:04 +0000
commit88a83fe20ce9100f2292c3945d26e4696fd2e7d2 (patch)
tree975293e6d6e128b45c446dce9b00eeefedea8e13 /src/Alpha_complex
parent0c44486d50e114fb6831ad050ee28dafe218cb97 (diff)
// We could use Epick + CGAL::Tag_true for not weighted nor periodic, but during benchmark, we found a bug
// https://github.com/CGAL/cgal/issues/3460 // This is the reason we only use Epick + CGAL::Tag_false, or Epeck // // FAST SAFE EXACT // Epick + CGAL::Tag_false Epeck Epeck git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/alpha_complex_3d_module_vincent@4012 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 88e844333b5bae8fcfd1104e493cdada1e4a4a3b
Diffstat (limited to 'src/Alpha_complex')
-rw-r--r--src/Alpha_complex/example/Alpha_complex_3d_from_points.cpp2
-rw-r--r--src/Alpha_complex/example/Weighted_alpha_complex_3d_from_points.cpp4
-rw-r--r--src/Alpha_complex/include/gudhi/Alpha_complex_3d.h22
-rw-r--r--src/Alpha_complex/test/Alpha_complex_3d_unit_test.cpp61
4 files changed, 43 insertions, 46 deletions
diff --git a/src/Alpha_complex/example/Alpha_complex_3d_from_points.cpp b/src/Alpha_complex/example/Alpha_complex_3d_from_points.cpp
index 3acebd2e..0e359a27 100644
--- a/src/Alpha_complex/example/Alpha_complex_3d_from_points.cpp
+++ b/src/Alpha_complex/example/Alpha_complex_3d_from_points.cpp
@@ -7,7 +7,7 @@
#include <vector>
#include <limits> // for numeric limits
-using Alpha_complex_3d = Gudhi::alpha_complex::Alpha_complex_3d<Gudhi::alpha_complex::complexity::EXACT, false, false>;
+using Alpha_complex_3d = Gudhi::alpha_complex::Alpha_complex_3d<Gudhi::alpha_complex::complexity::SAFE, false, false>;
using Point = Alpha_complex_3d::Point_3;
using Vector_of_points = std::vector<Point>;
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
index 734b4f37..ac11b68c 100644
--- a/src/Alpha_complex/example/Weighted_alpha_complex_3d_from_points.cpp
+++ b/src/Alpha_complex/example/Weighted_alpha_complex_3d_from_points.cpp
@@ -7,9 +7,9 @@
#include <vector>
#include <limits> // for numeric limits
-// Complexity = EXACT, weighted = true, periodic = false
+// Complexity = FAST, weighted = true, periodic = false
using Weighted_alpha_complex_3d =
- Gudhi::alpha_complex::Alpha_complex_3d<Gudhi::alpha_complex::complexity::EXACT, true, false>;
+ Gudhi::alpha_complex::Alpha_complex_3d<Gudhi::alpha_complex::complexity::SAFE, true, false>;
using Point = Weighted_alpha_complex_3d::Point_3;
using Weighted_point = Weighted_alpha_complex_3d::Weighted_point_3;
diff --git a/src/Alpha_complex/include/gudhi/Alpha_complex_3d.h b/src/Alpha_complex/include/gudhi/Alpha_complex_3d.h
index c33b9cf8..b5d4201d 100644
--- a/src/Alpha_complex/include/gudhi/Alpha_complex_3d.h
+++ b/src/Alpha_complex/include/gudhi/Alpha_complex_3d.h
@@ -155,16 +155,16 @@ class Alpha_complex_3d {
// Epeck = Exact_predicates_exact_constructions_kernel
// Exact_alpha_comparison_tag = exact version of CGAL Alpha_shape_3 and of its objects (Alpha_shape_vertex_base_3 and
// Alpha_shape_cell_base_3). Not available if weighted or periodic.
- // Can be CGAL::Tag_false or CGAL::Tag_true
+ // Can be CGAL::Tag_false or CGAL::Tag_true. Default is False.
// cf. https://doc.cgal.org/latest/Alpha_shapes_3/classCGAL_1_1Alpha__shape__3.html
//
+ // We could use Epick + CGAL::Tag_true for not weighted nor periodic, but during benchmark, we found a bug
+ // https://github.com/CGAL/cgal/issues/3460
+ // This is the reason we only use Epick + CGAL::Tag_false, or Epeck
//
- // FAST SAFE EXACT
- // not weighted and Epick + CGAL::Tag_false Epick + CGAL::Tag_true Epick + CGAL::Tag_true
- // not periodic
- //
- // otherwise Epick + CGAL::Tag_false Epeck Epeck
- using Predicates = typename std::conditional<((!Weighted && !Periodic) || (Complexity == complexity::FAST)),
+ // FAST SAFE EXACT
+ // Epick + CGAL::Tag_false Epeck Epeck
+ using Predicates = typename std::conditional<(Complexity == complexity::FAST),
CGAL::Exact_predicates_inexact_constructions_kernel,
CGAL::Exact_predicates_exact_constructions_kernel>::type;
@@ -188,15 +188,13 @@ class Alpha_complex_3d {
using Kernel = typename Kernel_3<Predicates, Weighted, Periodic>::Kernel;
- using Exact_alpha_comparison_tag = typename std::conditional<(Complexity == complexity::FAST), CGAL::Tag_false, CGAL::Tag_true>::type;
-
using TdsVb = typename std::conditional<Periodic, CGAL::Periodic_3_triangulation_ds_vertex_base_3<>,
CGAL::Triangulation_ds_vertex_base_3<>>::type;
using Tvb = typename std::conditional<Weighted, CGAL::Regular_triangulation_vertex_base_3<Kernel, TdsVb>,
CGAL::Triangulation_vertex_base_3<Kernel, TdsVb>>::type;
- using Vb = CGAL::Alpha_shape_vertex_base_3<Kernel, Tvb, Exact_alpha_comparison_tag>;
+ using Vb = CGAL::Alpha_shape_vertex_base_3<Kernel, Tvb>;
using TdsCb = typename std::conditional<Periodic, CGAL::Periodic_3_triangulation_ds_cell_base_3<>,
CGAL::Triangulation_ds_cell_base_3<>>::type;
@@ -204,7 +202,7 @@ class Alpha_complex_3d {
using Tcb = typename std::conditional<Weighted, CGAL::Regular_triangulation_cell_base_3<Kernel, TdsCb>,
CGAL::Triangulation_cell_base_3<Kernel, TdsCb>>::type;
- using Cb = CGAL::Alpha_shape_cell_base_3<Kernel, Tcb, Exact_alpha_comparison_tag>;
+ using Cb = CGAL::Alpha_shape_cell_base_3<Kernel, Tcb>;
using Tds = CGAL::Triangulation_data_structure_3<Vb, Cb>;
// The other way to do a conditional type. Here there 4 possibilities, cannot use std::conditional
@@ -247,7 +245,7 @@ public:
*
* The `Gudhi::alpha_complex::Alpha_complex_3d` is a wrapper on top of this class to ease the standard, weighted
* and/or periodic build of the Alpha complex 3d.*/
- using Alpha_shape_3 = CGAL::Alpha_shape_3<Dt, Exact_alpha_comparison_tag>;
+ using Alpha_shape_3 = CGAL::Alpha_shape_3<Dt>;
/** \brief The alpha values type.
* Must be compatible with double. */
diff --git a/src/Alpha_complex/test/Alpha_complex_3d_unit_test.cpp b/src/Alpha_complex/test/Alpha_complex_3d_unit_test.cpp
index c408dc75..ec905d5b 100644
--- a/src/Alpha_complex/test/Alpha_complex_3d_unit_test.cpp
+++ b/src/Alpha_complex/test/Alpha_complex_3d_unit_test.cpp
@@ -48,20 +48,27 @@ using Safe_alpha_complex_3d =
using Exact_alpha_complex_3d =
Gudhi::alpha_complex::Alpha_complex_3d<Gudhi::alpha_complex::complexity::EXACT, false, false>;
+template <typename Point>
+std::vector<Point> get_points() {
+ std::vector<Point> points;
+ points.push_back(Point(0.0, 0.0, 0.0));
+ points.push_back(Point(0.0, 0.0, 0.2));
+ points.push_back(Point(0.2, 0.0, 0.2));
+ points.push_back(Point(0.6, 0.6, 0.0));
+ points.push_back(Point(0.8, 0.8, 0.2));
+ points.push_back(Point(0.2, 0.8, 0.6));
+
+ return points;
+}
+
+
BOOST_AUTO_TEST_CASE(Alpha_complex_3d_from_points) {
// -----------------
// Fast version
// -----------------
std::cout << "Fast alpha complex 3d" << std::endl;
- std::vector<Fast_alpha_complex_3d::Point_3> points;
- points.push_back(Fast_alpha_complex_3d::Point_3(0.0, 0.0, 0.0));
- points.push_back(Fast_alpha_complex_3d::Point_3(0.0, 0.0, 0.2));
- points.push_back(Fast_alpha_complex_3d::Point_3(0.2, 0.0, 0.2));
- points.push_back(Fast_alpha_complex_3d::Point_3(0.6, 0.6, 0.0));
- points.push_back(Fast_alpha_complex_3d::Point_3(0.8, 0.8, 0.2));
- points.push_back(Fast_alpha_complex_3d::Point_3(0.2, 0.8, 0.6));
- Fast_alpha_complex_3d alpha_complex(points);
+ Fast_alpha_complex_3d alpha_complex(get_points<Fast_alpha_complex_3d::Point_3>());
Gudhi::Simplex_tree<> stree;
alpha_complex.create_complex(stree);
@@ -71,7 +78,7 @@ BOOST_AUTO_TEST_CASE(Alpha_complex_3d_from_points) {
// -----------------
std::cout << "Exact alpha complex 3d" << std::endl;
- Exact_alpha_complex_3d exact_alpha_complex(points);
+ Exact_alpha_complex_3d exact_alpha_complex(get_points<Exact_alpha_complex_3d::Point_3>());
Gudhi::Simplex_tree<> exact_stree;
exact_alpha_complex.create_complex(exact_stree);
@@ -79,13 +86,13 @@ BOOST_AUTO_TEST_CASE(Alpha_complex_3d_from_points) {
// ---------------------
// Compare both versions
// ---------------------
- std::cout << "Exact Alpha complex 3d is of dimension " << exact_stree.dimension() << " - Non exact is "
+ std::cout << "Exact Alpha complex 3d is of dimension " << exact_stree.dimension() << " - Fast 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 "
+ std::cout << "Exact Alpha complex 3d num_simplices " << exact_stree.num_simplices() << " - Fast 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 "
+ std::cout << "Exact Alpha complex 3d num_vertices " << exact_stree.num_vertices() << " - Fast is "
<< stree.num_vertices() << std::endl;
BOOST_CHECK(exact_stree.num_vertices() == stree.num_vertices());
@@ -93,19 +100,18 @@ BOOST_AUTO_TEST_CASE(Alpha_complex_3d_from_points) {
while (sh != stree.filtration_simplex_range().end()) {
std::vector<int> simplex;
std::vector<int> exact_simplex;
- std::cout << "Non-exact ( ";
+ std::cout << "Fast ( ";
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 << ") -> [" << stree.filtration(*sh) << "] ";
// Find it in the exact structure
auto sh_exact = exact_stree.find(simplex);
BOOST_CHECK(sh_exact != exact_stree.null_simplex());
+ std::cout << " versus [" << exact_stree.filtration(sh_exact) << "] " << std::endl;
// 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));
@@ -116,7 +122,7 @@ BOOST_AUTO_TEST_CASE(Alpha_complex_3d_from_points) {
// -----------------
std::cout << "Safe alpha complex 3d" << std::endl;
- Safe_alpha_complex_3d safe_alpha_complex(points);
+ Safe_alpha_complex_3d safe_alpha_complex(get_points<Safe_alpha_complex_3d::Point_3>());
Gudhi::Simplex_tree<> safe_stree;
safe_alpha_complex.create_complex(safe_stree);
@@ -124,13 +130,13 @@ BOOST_AUTO_TEST_CASE(Alpha_complex_3d_from_points) {
// ---------------------
// Compare both versions
// ---------------------
- std::cout << "Exact Alpha complex 3d is of dimension " << safe_stree.dimension() << " - Non exact is "
+ std::cout << "Safe Alpha complex 3d is of dimension " << safe_stree.dimension() << " - Fast is "
<< stree.dimension() << std::endl;
BOOST_CHECK(safe_stree.dimension() == stree.dimension());
- std::cout << "Exact Alpha complex 3d num_simplices " << safe_stree.num_simplices() << " - Non exact is "
+ std::cout << "Safe Alpha complex 3d num_simplices " << safe_stree.num_simplices() << " - Fast is "
<< stree.num_simplices() << std::endl;
BOOST_CHECK(safe_stree.num_simplices() == stree.num_simplices());
- std::cout << "Exact Alpha complex 3d num_vertices " << safe_stree.num_vertices() << " - Non exact is "
+ std::cout << "Safe Alpha complex 3d num_vertices " << safe_stree.num_vertices() << " - Fast is "
<< stree.num_vertices() << std::endl;
BOOST_CHECK(safe_stree.num_vertices() == stree.num_vertices());
@@ -138,27 +144,20 @@ BOOST_AUTO_TEST_CASE(Alpha_complex_3d_from_points) {
while (safe_sh != stree.filtration_simplex_range().end()) {
std::vector<int> simplex;
std::vector<int> exact_simplex;
-#ifdef DEBUG_TRACES
- std::cout << "Non-exact ( ";
-#endif
+ std::cout << "Fast ( ";
for (auto vertex : stree.simplex_vertex_range(*safe_sh)) {
simplex.push_back(vertex);
-#ifdef DEBUG_TRACES
std::cout << vertex << " ";
-#endif
}
-#ifdef DEBUG_TRACES
- std::cout << ") -> "
- << "[" << stree.filtration(*safe_sh) << "] ";
- std::cout << std::endl;
-#endif
+ std::cout << ") -> [" << stree.filtration(*safe_sh) << "] ";
// Find it in the exact structure
auto sh_exact = safe_stree.find(simplex);
BOOST_CHECK(sh_exact != safe_stree.null_simplex());
+ std::cout << " versus [" << safe_stree.filtration(sh_exact) << "] " << std::endl;
// Exact and non-exact version is not exactly the same due to float comparison
- GUDHI_TEST_FLOAT_EQUALITY_CHECK(safe_stree.filtration(sh_exact), stree.filtration(*safe_sh));
+ GUDHI_TEST_FLOAT_EQUALITY_CHECK(safe_stree.filtration(sh_exact), stree.filtration(*safe_sh), 1e-15);
++safe_sh;
}