From c5ccdfae66f8e3a33bec20a310df134d3e1ab4bf Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 22 Jun 2018 15:50:51 +0000 Subject: Compiles run and tests for Alpha_3d, exact, weighted, periodic and weighted periodic git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/alpha_complex_3d_module_vincent@3627 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: e24d7de108d3e77eaf6319a8165a7c65bec57884 --- src/Alpha_complex/example/traits_test.cpp | 170 ++++++++++++++++++++- src/Alpha_complex/include/gudhi/Alpha_complex_3d.h | 43 +++--- .../include/gudhi/Alpha_complex_3d_options.h | 30 +++- .../periodic_alpha_complex_3d_persistence.cpp | 2 +- 4 files changed, 219 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/Alpha_complex/example/traits_test.cpp b/src/Alpha_complex/example/traits_test.cpp index 3be62ad3..1dd062de 100644 --- a/src/Alpha_complex/example/traits_test.cpp +++ b/src/Alpha_complex/example/traits_test.cpp @@ -5,6 +5,7 @@ #include #include #include // for numeric limits +#include void usage(int nbArgs, char * const progName) { std::cerr << "Error: Number of arguments (" << nbArgs << ") is not correct\n"; @@ -31,6 +32,21 @@ int main(int argc, char **argv) { Gudhi::Simplex_tree<> stree; alpha_complex.create_complex(stree); + std::cout << "Exact alpha complex 3d" << std::endl; + using Exact_alpha_shapes_3d = Gudhi::alpha_complex::Exact_alpha_shapes_3d; + std::vector 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_complex(e_points); + + Gudhi::Simplex_tree exact_stree; + exact_alpha_complex.create_complex(exact_stree); + std::cout << "Weighted alpha complex 3d" << std::endl; using Weighted_alpha_shapes_3d = Gudhi::alpha_complex::Weighted_alpha_shapes_3d; std::vector w_points; @@ -51,6 +67,7 @@ int main(int argc, char **argv) { std::cout << "Periodic alpha complex 3d" << std::endl; using Periodic_alpha_shapes_3d = Gudhi::alpha_complex::Periodic_alpha_shapes_3d; std::vector 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)); @@ -131,8 +148,7 @@ int main(int argc, char **argv) { 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.0, 0.0)); - 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.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)); @@ -177,22 +193,162 @@ int main(int argc, char **argv) { 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)); - //p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.8, 0.8)); - Gudhi::alpha_complex::Alpha_complex_3d periodic_alpha_complex(points, + Gudhi::alpha_complex::Alpha_complex_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 << "Weighted periodic alpha complex 3d" << std::endl; using Weighted_periodic_alpha_shapes_3d = Gudhi::alpha_complex::Weighted_periodic_alpha_shapes_3d; std::vector wp_points; - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.1, 0.2, 0.3)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.5, 0.4)); + 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 p_weights; + + std::random_device rd; + std::mt19937 mt(rd()); + // Weights must be in range [0, <1/64] + std::uniform_real_distribution dist(0.0, 0.0156245); + + 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_complex(points, weights, + 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; } diff --git a/src/Alpha_complex/include/gudhi/Alpha_complex_3d.h b/src/Alpha_complex/include/gudhi/Alpha_complex_3d.h index c8bc9c8e..ff6eb3e6 100644 --- a/src/Alpha_complex/include/gudhi/Alpha_complex_3d.h +++ b/src/Alpha_complex/include/gudhi/Alpha_complex_3d.h @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -44,6 +45,12 @@ #include #include // 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 { @@ -87,7 +94,7 @@ public: static_assert(!AlphaComplex3dOptions::periodic, "This constructor is not available for periodic versions of Alpha_complex_3d"); - alpha_shape_3_ptr_ = std::unique_ptr(new Alpha_shape_3(points.begin(), points.end(), 0, + alpha_shape_3_ptr_ = std::unique_ptr(new Alpha_shape_3(std::begin(points), std::end(points), 0, Alpha_shape_3::GENERAL)); Dispatch dispatcher = CGAL::dispatch_output(std::back_inserter(objects_), std::back_inserter(alpha_values_)); @@ -149,11 +156,13 @@ public: * * The type InputPointRange must be a range for which std::begin and * std::end return input iterators on a Kernel::Point_d. +* +* @exception std::invalid_argument In case the number of simplices is more than Simplex_key type numeric limit. */ template Alpha_complex_3d(const InputPointRange& points, - double x_min, double y_min, double z_min, - double x_max, double y_max, double z_max) { + 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, @@ -171,15 +180,10 @@ public: // 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 - // GUDHI_CHECK(pdt.is_triangulation_in_1_sheet(), - // std::invalid_argument("Uable to construct a triangulation within a single periodic domain.")); - 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); + if (!pdt.is_triangulation_in_1_sheet()) { + throw std::invalid_argument("Unable to construct a triangulation within a single periodic domain."); } - std::cout << "Periodic Delaunay computed." << std::endl; + 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 @@ -232,7 +236,7 @@ public: std::size_t index = 0; weighted_points_3.reserve(points.size()); 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.")); @@ -247,9 +251,9 @@ public: // 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 - GUDHI_CHECK(pdt.is_triangulation_in_1_sheet(), - std::invalid_argument("Unable to construct a triangulation within a single periodic domain.")); - + 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 @@ -369,11 +373,16 @@ public: } } // Construction of the simplex_tree - Filtration_value filtr = /*std::sqrt*/ (*the_alpha_value_iterator); + //Alpha_value_type filtr; + Filtration_value filtr = + AlphaComplex3dOptions::template value_from_iterator::iterator> + (the_alpha_value_iterator); + //Filtration_value filtr = CGAL::to_double(the_alpha_value_iterator->exact()); #ifdef DEBUG_TRACES std::cout << "filtration = " << filtr << std::endl; #endif // DEBUG_TRACES - complex.insert_simplex(the_simplex, filtr); + //complex.insert_simplex(the_simplex, static_cast(filtr)); GUDHI_CHECK(the_alpha_value_iterator != alpha_values_.end(), "CGAL provided more simplices than values"); ++the_alpha_value_iterator; } diff --git a/src/Alpha_complex/include/gudhi/Alpha_complex_3d_options.h b/src/Alpha_complex/include/gudhi/Alpha_complex_3d_options.h index 3b1981ca..32911a84 100644 --- a/src/Alpha_complex/include/gudhi/Alpha_complex_3d_options.h +++ b/src/Alpha_complex/include/gudhi/Alpha_complex_3d_options.h @@ -54,6 +54,11 @@ public: static const bool weighted = false; static const bool periodic = false; + + template + static Filtration_value value_from_iterator(const Alpha_value_iterator avi){ + return /*std::sqrt*/ *avi; + } }; class Exact_alpha_shapes_3d { @@ -72,6 +77,12 @@ public: static const bool weighted = false; static const bool periodic = false; + static const bool exact = true; + + template + static Filtration_value value_from_iterator(const Alpha_value_iterator avi){ + return /*std::sqrt*/ CGAL::to_double(avi->exact()); + } }; class Weighted_alpha_shapes_3d { @@ -92,6 +103,12 @@ public: static const bool weighted = true; static const bool periodic = false; + static const bool exact = false; + + template + static Filtration_value value_from_iterator(const Alpha_value_iterator avi){ + return /*std::sqrt*/ *avi; + } }; class Periodic_alpha_shapes_3d { @@ -117,6 +134,12 @@ public: static const bool weighted = false; static const bool periodic = true; + static const bool exact = false; + + template + static Filtration_value value_from_iterator(const Alpha_value_iterator avi){ + return /*std::sqrt*/ *avi; + } }; class Weighted_periodic_alpha_shapes_3d { @@ -136,11 +159,16 @@ public: using Alpha_shape_3 = CGAL::Alpha_shape_3; using Point_3 = Periodic_delaunay_triangulation_3::Bare_point; using Weighted_point_3 = Periodic_delaunay_triangulation_3::Weighted_point; - using Alpha_value_type = Alpha_shape_3::FT; using Iso_cuboid_3 = Periodic_kernel::Iso_cuboid_3; static const bool weighted = true; static const bool periodic = true; + static const bool exact = false; + + template + static Filtration_value value_from_iterator(const Alpha_value_iterator avi){ + return /*std::sqrt*/ *avi; + } }; } // namespace alpha_complex diff --git a/src/Alpha_complex/utilities/periodic_alpha_complex_3d_persistence.cpp b/src/Alpha_complex/utilities/periodic_alpha_complex_3d_persistence.cpp index 11010701..42f3ddcb 100644 --- a/src/Alpha_complex/utilities/periodic_alpha_complex_3d_persistence.cpp +++ b/src/Alpha_complex/utilities/periodic_alpha_complex_3d_persistence.cpp @@ -101,7 +101,7 @@ int main(int argc, char **argv) { // Read the OFF file (input file name given as parameter) and triangulate points Gudhi::Points_3D_off_reader off_reader(off_file_points); // Check the read operation was correct - if (!off_reader.is_valid()) { + if (off_reader.is_valid()) { std::cerr << "Unable to read OFF file " << off_file_points << std::endl; exit(-1); } -- cgit v1.2.3