summaryrefslogtreecommitdiff
path: root/src/Tangential_complex
diff options
context:
space:
mode:
Diffstat (limited to 'src/Tangential_complex')
-rw-r--r--src/Tangential_complex/benchmark/XML_exporter.h2
-rw-r--r--src/Tangential_complex/benchmark/benchmark_tc.cpp3
-rw-r--r--src/Tangential_complex/doc/Intro_tangential_complex.h4
-rw-r--r--src/Tangential_complex/example/CMakeLists.txt2
-rw-r--r--src/Tangential_complex/example/example_basic.cpp4
-rw-r--r--src/Tangential_complex/example/example_with_perturb.cpp1
-rw-r--r--src/Tangential_complex/include/gudhi/Tangential_complex.h39
-rw-r--r--src/Tangential_complex/test/CMakeLists.txt6
-rw-r--r--src/Tangential_complex/test/test_tangential_complex.cpp11
9 files changed, 43 insertions, 29 deletions
diff --git a/src/Tangential_complex/benchmark/XML_exporter.h b/src/Tangential_complex/benchmark/XML_exporter.h
index 16b62eb6..38fe049f 100644
--- a/src/Tangential_complex/benchmark/XML_exporter.h
+++ b/src/Tangential_complex/benchmark/XML_exporter.h
@@ -157,7 +157,7 @@ class Streaming_XML_exporter {
m_xml_fstream << " </" << m_element_name << ">" << std::endl;
// Save current pointer position
- std::ofstream::streampos pos = m_xml_fstream.tellp();
+ auto pos = m_xml_fstream.tellp();
// Close the XML file (temporarily) so that the XML file is always correct
m_xml_fstream << "</" << m_list_name << ">" << std::endl;
// Restore the pointer position so that the next "add_element" will overwrite
diff --git a/src/Tangential_complex/benchmark/benchmark_tc.cpp b/src/Tangential_complex/benchmark/benchmark_tc.cpp
index e3b2a04f..8e7c72ff 100644
--- a/src/Tangential_complex/benchmark/benchmark_tc.cpp
+++ b/src/Tangential_complex/benchmark/benchmark_tc.cpp
@@ -33,6 +33,7 @@ const std::size_t ONLY_LOAD_THE_FIRST_N_POINTS = 20000000;
#include <gudhi/sparsify_point_set.h>
#include <gudhi/random_point_generators.h>
#include <gudhi/Tangential_complex/utilities.h>
+#include <gudhi/Simplex_tree.h>
#include <CGAL/assertions_behaviour.h>
#include <CGAL/Epick_d.h>
@@ -704,7 +705,7 @@ int main() {
points = Gudhi::generate_points_on_torus_d<Kernel>(
num_points,
intrinsic_dim,
- param1 == "Y", // uniform
+ (param1 == "Y") ? "grid" : "random", // grid or random sample type
std::atof(param2.c_str())); // radius_noise_percentage
} else if (input == "generate_klein_bottle_3D") {
points = Gudhi::generate_points_on_klein_bottle_3D<Kernel>(
diff --git a/src/Tangential_complex/doc/Intro_tangential_complex.h b/src/Tangential_complex/doc/Intro_tangential_complex.h
index ce277185..cb8c6122 100644
--- a/src/Tangential_complex/doc/Intro_tangential_complex.h
+++ b/src/Tangential_complex/doc/Intro_tangential_complex.h
@@ -88,7 +88,7 @@ This example builds the Tangential complex of point set.
Note that the dimension of the kernel here is dynamic, which is slower, but more flexible:
the intrinsic and ambient dimensions does not have to be known at compile-time.
-\include Tangential_complex/example_basic.cpp
+\include example_basic.cpp
\section example_with_perturb Example with perturbation
@@ -97,7 +97,7 @@ by perturbing the positions of points involved in inconsistent simplices.
Note that the dimension of the kernel here is static, which is the best choice when the
dimensions are known at compile-time.
-\include Tangential_complex/example_with_perturb.cpp
+\include example_with_perturb.cpp
*/
/** @} */ // end defgroup tangential_complex
diff --git a/src/Tangential_complex/example/CMakeLists.txt b/src/Tangential_complex/example/CMakeLists.txt
index cb1486a4..b66b5f39 100644
--- a/src/Tangential_complex/example/CMakeLists.txt
+++ b/src/Tangential_complex/example/CMakeLists.txt
@@ -15,6 +15,4 @@ if(NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0)
add_test(NAME Tangential_complex_example_with_perturb
COMMAND $<TARGET_FILE:Tangential_complex_example_with_perturb>)
- install(TARGETS Tangential_complex_example_basic DESTINATION bin)
- install(TARGETS Tangential_complex_example_with_perturb DESTINATION bin)
endif(NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0)
diff --git a/src/Tangential_complex/example/example_basic.cpp b/src/Tangential_complex/example/example_basic.cpp
index ab35edf0..c50b9b8c 100644
--- a/src/Tangential_complex/example/example_basic.cpp
+++ b/src/Tangential_complex/example/example_basic.cpp
@@ -1,7 +1,6 @@
#include <gudhi/Tangential_complex.h>
#include <gudhi/sparsify_point_set.h>
-//#include <gudhi/Fake_simplex_tree.h>
-
+#include <gudhi/Simplex_tree.h>
#include <CGAL/Epick_d.h>
#include <CGAL/Random.h>
@@ -39,7 +38,6 @@ int main(void) {
// Export the TC into a Simplex_tree
Gudhi::Simplex_tree<> stree;
- //Gudhi::Fake_simplex_tree stree;
tc.create_complex(stree);
// Display stats about inconsistencies
diff --git a/src/Tangential_complex/example/example_with_perturb.cpp b/src/Tangential_complex/example/example_with_perturb.cpp
index d0d877ea..e70e2980 100644
--- a/src/Tangential_complex/example/example_with_perturb.cpp
+++ b/src/Tangential_complex/example/example_with_perturb.cpp
@@ -1,5 +1,6 @@
#include <gudhi/Tangential_complex.h>
#include <gudhi/sparsify_point_set.h>
+#include <gudhi/Simplex_tree.h>
#include <CGAL/Epick_d.h>
#include <CGAL/Random.h>
diff --git a/src/Tangential_complex/include/gudhi/Tangential_complex.h b/src/Tangential_complex/include/gudhi/Tangential_complex.h
index f59476b1..ab203ca5 100644
--- a/src/Tangential_complex/include/gudhi/Tangential_complex.h
+++ b/src/Tangential_complex/include/gudhi/Tangential_complex.h
@@ -36,7 +36,6 @@
#include <Eigen/Eigen>
#include <Eigen/src/Core/util/Macros.h> // for EIGEN_VERSION_AT_LEAST
-#include <boost/optional.hpp>
#include <boost/iterator/transform_iterator.hpp>
#include <boost/range/adaptor/transformed.hpp>
#include <boost/range/counting_range.hpp>
@@ -56,22 +55,24 @@
#include <cmath> // for std::sqrt
#include <string>
#include <cstddef> // for std::size_t
+#include <optional>
+#include <numeric> // for std::iota
#ifdef GUDHI_USE_TBB
#include <tbb/parallel_for.h>
#include <tbb/combinable.h>
-#include <tbb/mutex.h>
+#include <mutex>
#endif
// #define GUDHI_TC_EXPORT_NORMALS // Only for 3D surfaces (k=2, d=3)
// Make compilation fail - required for external projects - https://github.com/GUDHI/gudhi-devel/issues/10
#if CGAL_VERSION_NR < 1041101000
-# error Alpha_complex_3d is only available for CGAL >= 4.11
+# error Tangential_complex is only available for CGAL >= 4.11
#endif
#if !EIGEN_VERSION_AT_LEAST(3,1,0)
-# error Alpha_complex_3d is only available for Eigen3 >= 3.1.0 installed with CGAL
+# error Tangential_complex is only available for Eigen3 >= 3.1.0 installed with CGAL
#endif
namespace sps = Gudhi::spatial_searching;
@@ -147,7 +148,7 @@ class Tangential_complex {
typedef typename Tr_traits::Vector_d Tr_vector;
#if defined(GUDHI_USE_TBB)
- typedef tbb::mutex Mutex_for_perturb;
+ typedef std::mutex Mutex_for_perturb;
typedef Vector Translation_for_perturb;
typedef std::vector<Atomic_wrapper<FT> > Weights;
#else
@@ -345,10 +346,11 @@ class Tangential_complex {
m_stars.resize(m_points.size());
m_squared_star_spheres_radii_incl_margin.resize(m_points.size(), FT(-1));
#ifdef GUDHI_TC_PERTURB_POSITION
- if (m_points.empty())
+ if (m_points.empty()) {
m_translations.clear();
- else
+ } else {
m_translations.resize(m_points.size(), m_k.construct_vector_d_object()(m_ambient_dim));
+ }
#if defined(GUDHI_USE_TBB)
delete[] m_p_perturb_mutexes;
m_p_perturb_mutexes = new Mutex_for_perturb[m_points.size()];
@@ -623,6 +625,11 @@ class Tangential_complex {
int max_dim = -1;
+ // Ordered vertices to be inserted first by the create_complex method to avoid quadratic complexity.
+ std::vector<typename Simplex_tree_::Vertex_handle> vertices(m_points.size());
+ std::iota(vertices.begin(), vertices.end(), 0);
+ tree.insert_batch_vertices(vertices);
+
// For each triangulation
for (std::size_t idx = 0; idx < m_points.size(); ++idx) {
// For each cell of the star
@@ -954,7 +961,11 @@ class Tangential_complex {
// Triangulation's traits functor & objects
typename Tr_traits::Compute_weight_d point_weight = local_tr_traits.compute_weight_d_object();
+#if CGAL_VERSION_NR < 1050200000
typename Tr_traits::Power_center_d power_center = local_tr_traits.power_center_d_object();
+#else
+ typename Tr_traits::Construct_power_sphere_d power_center = local_tr_traits.construct_power_sphere_d_object();
+#endif
//***************************************************
// Build a minimal triangulation in the tangent space
@@ -990,7 +1001,7 @@ class Tangential_complex {
// circumspheres of the star of "center_vertex"
// If th the m_max_squared_edge_length is set the maximal radius of the "star sphere"
// is at most square root of m_max_squared_edge_length
- boost::optional<FT> squared_star_sphere_radius_plus_margin = m_max_squared_edge_length;
+ std::optional<FT> squared_star_sphere_radius_plus_margin = m_max_squared_edge_length;
// Insert points until we find a point which is outside "star sphere"
for (auto nn_it = ins_range.begin(); nn_it != ins_range.end(); ++nn_it) {
@@ -1032,7 +1043,7 @@ class Tangential_complex {
// Let's recompute squared_star_sphere_radius_plus_margin
if (triangulation.current_dimension() >= tangent_space_dim) {
- squared_star_sphere_radius_plus_margin = boost::none;
+ squared_star_sphere_radius_plus_margin = std::nullopt;
// Get the incident cells and look for the biggest circumsphere
std::vector<Tr_full_cell_handle> incident_cells;
triangulation.incident_full_cells(center_vertex, std::back_inserter(incident_cells));
@@ -1040,7 +1051,7 @@ class Tangential_complex {
cit != incident_cells.end(); ++cit) {
Tr_full_cell_handle cell = *cit;
if (triangulation.is_infinite(cell)) {
- squared_star_sphere_radius_plus_margin = boost::none;
+ squared_star_sphere_radius_plus_margin = std::nullopt;
break;
} else {
// Note that this uses the perturbed point since it uses
@@ -1100,7 +1111,11 @@ class Tangential_complex {
std::size_t closest_pt_index = updated_pts_ds.k_nearest_neighbors(center_point, 1, false).begin()->first;
typename K::Construct_weighted_point_d k_constr_wp = m_k.construct_weighted_point_d_object();
+#if CGAL_VERSION_NR < 1050200000
typename K::Power_distance_d k_power_dist = m_k.power_distance_d_object();
+#else
+ typename K::Compute_power_product_d k_power_dist = m_k.compute_power_product_d_object();
+#endif
// Construct a weighted point equivalent to the star sphere
Weighted_point star_sphere = k_constr_wp(compute_perturbed_point(i), m_squared_star_spheres_radii_incl_margin[i]);
@@ -1144,7 +1159,7 @@ class Tangential_complex {
#ifdef GUDHI_TC_VERY_VERBOSE
std::cerr << "Inserted " << num_inserted_points << " points / " << num_attempts_to_insert_points
- << " attemps to compute the star\n";
+ << " attempts to compute the star\n";
#endif
update_star(i);
@@ -2022,7 +2037,7 @@ class Tangential_complex {
// and their center vertex
Stars_container m_stars;
std::vector<FT> m_squared_star_spheres_radii_incl_margin;
- boost::optional<FT> m_max_squared_edge_length;
+ std::optional<FT> m_max_squared_edge_length;
#ifdef GUDHI_TC_USE_ANOTHER_POINT_SET_FOR_TANGENT_SPACE_ESTIM
Points m_points_for_tse;
diff --git a/src/Tangential_complex/test/CMakeLists.txt b/src/Tangential_complex/test/CMakeLists.txt
index ae17a286..2207d67c 100644
--- a/src/Tangential_complex/test/CMakeLists.txt
+++ b/src/Tangential_complex/test/CMakeLists.txt
@@ -1,13 +1,13 @@
project(Tangential_complex_tests)
if(NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0)
- include(GUDHI_test_coverage)
+ include(GUDHI_boost_test)
add_executable( Tangential_complex_test_TC test_tangential_complex.cpp )
- target_link_libraries(Tangential_complex_test_TC ${CGAL_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
+ target_link_libraries(Tangential_complex_test_TC ${CGAL_LIBRARY})
if (TBB_FOUND)
target_link_libraries(Tangential_complex_test_TC ${TBB_LIBRARIES})
endif()
- gudhi_add_coverage_test(Tangential_complex_test_TC)
+ gudhi_add_boost_test(Tangential_complex_test_TC)
endif(NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0)
diff --git a/src/Tangential_complex/test/test_tangential_complex.cpp b/src/Tangential_complex/test/test_tangential_complex.cpp
index 46caec54..a24b9ae2 100644
--- a/src/Tangential_complex/test/test_tangential_complex.cpp
+++ b/src/Tangential_complex/test/test_tangential_complex.cpp
@@ -14,6 +14,7 @@
#include <gudhi/Tangential_complex.h>
#include <gudhi/sparsify_point_set.h>
+#include <gudhi/Simplex_tree.h>
#include <CGAL/Epick_d.h>
#include <CGAL/Random.h>
@@ -76,14 +77,14 @@ BOOST_AUTO_TEST_CASE(test_mini_tangential) {
points.push_back(Point(point.size(), point.begin(), point.end()));
point = {1.0, 1.0};
points.push_back(Point(point.size(), point.begin(), point.end()));
- std::cout << "points = " << points.size() << std::endl;
+ std::clog << "points = " << points.size() << std::endl;
Kernel k;
// Compute the TC
TC tc(points, INTRINSIC_DIM, k);
tc.compute_tangential_complex();
TC::Num_inconsistencies num_inc = tc.number_of_inconsistent_simplices();
- std::cout << "TC vertices = " << tc.number_of_vertices() << " - simplices = " << num_inc.num_simplices <<
+ std::clog << "TC vertices = " << tc.number_of_vertices() << " - simplices = " << num_inc.num_simplices <<
" - inc simplices = " << num_inc.num_inconsistent_simplices <<
" - inc stars = " << num_inc.num_inconsistent_stars << std::endl;
@@ -95,7 +96,7 @@ BOOST_AUTO_TEST_CASE(test_mini_tangential) {
// Export the TC into a Simplex_tree
Gudhi::Simplex_tree<> stree;
tc.create_complex(stree);
- std::cout << "ST vertices = " << stree.num_vertices() << " - simplices = " << stree.num_simplices() << std::endl;
+ std::clog << "ST vertices = " << stree.num_vertices() << " - simplices = " << stree.num_simplices() << std::endl;
BOOST_CHECK(stree.num_vertices() == 4);
BOOST_CHECK(stree.num_simplices() == 6);
@@ -109,7 +110,7 @@ BOOST_AUTO_TEST_CASE(test_mini_tangential) {
// Export the TC into a Simplex_tree
tc.create_complex(stree);
- std::cout << "ST vertices = " << stree.num_vertices() << " - simplices = " << stree.num_simplices() << std::endl;
+ std::clog << "ST vertices = " << stree.num_vertices() << " - simplices = " << stree.num_simplices() << std::endl;
BOOST_CHECK(stree.num_vertices() == 4);
BOOST_CHECK(stree.num_simplices() == 6);
@@ -139,7 +140,7 @@ BOOST_AUTO_TEST_CASE(test_basic_example_throw) {
// Compute the TC
TC tc(points, INTRINSIC_DIM, k);
tc.set_max_squared_edge_length(0.01);
- std::cout << "test_basic_example_throw - set_max_squared_edge_length(0.01) to make GUDHI_CHECK fail" << std::endl;
+ std::clog << "test_basic_example_throw - set_max_squared_edge_length(0.01) to make GUDHI_CHECK fail" << std::endl;
BOOST_CHECK_THROW(tc.compute_tangential_complex(), std::invalid_argument);
}