From 004dac98fde448065a1697ea696a67153ccdb77e Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Wed, 30 Nov 2016 21:39:44 +0000 Subject: Add tan_test for test purpose git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/tangential_test@1807 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 85200e0b013cc119aead9556e97db877b3421064 --- src/Tangential_complex/example/CMakeLists.txt | 6 +++ src/Tangential_complex/example/tan_test.cpp | 54 ++++++++++++++++++++++ .../include/gudhi/Tangential_complex/config.h | 3 +- 3 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 src/Tangential_complex/example/tan_test.cpp (limited to 'src') diff --git a/src/Tangential_complex/example/CMakeLists.txt b/src/Tangential_complex/example/CMakeLists.txt index a75ccd5b..76ba0a32 100644 --- a/src/Tangential_complex/example/CMakeLists.txt +++ b/src/Tangential_complex/example/CMakeLists.txt @@ -8,9 +8,12 @@ if(CGAL_FOUND) target_link_libraries(Tangential_complex_example_basic ${CGAL_LIBRARY} ${Boost_DATE_TIME_LIBRARY}) add_executable( Tangential_complex_example_with_perturb example_with_perturb.cpp ) target_link_libraries(Tangential_complex_example_with_perturb ${CGAL_LIBRARY} ${Boost_DATE_TIME_LIBRARY}) + add_executable( tan_test tan_test.cpp ) + target_link_libraries(tan_test ${CGAL_LIBRARY} ${Boost_DATE_TIME_LIBRARY}) if (TBB_FOUND) target_link_libraries(Tangential_complex_example_basic ${TBB_LIBRARIES}) target_link_libraries(Tangential_complex_example_with_perturb ${TBB_LIBRARIES}) + target_link_libraries(tan_test ${TBB_LIBRARIES}) endif(TBB_FOUND) add_test(Tangential_complex_example_basic @@ -18,6 +21,9 @@ if(CGAL_FOUND) add_test(Tangential_complex_example_with_perturb ${CMAKE_CURRENT_BINARY_DIR}/Tangential_complex_example_with_perturb) + + add_test(tan_test + ${CMAKE_CURRENT_BINARY_DIR}/tan_test) endif(EIGEN3_FOUND) endif(NOT CGAL_VERSION VERSION_LESS 4.8.0) endif(CGAL_FOUND) diff --git a/src/Tangential_complex/example/tan_test.cpp b/src/Tangential_complex/example/tan_test.cpp new file mode 100644 index 00000000..afb9f13c --- /dev/null +++ b/src/Tangential_complex/example/tan_test.cpp @@ -0,0 +1,54 @@ +#include +#include + +#include +#include + +#include +#include + +namespace tc = Gudhi::tangential_complex; + +typedef CGAL::Epick_d Kernel; +typedef Kernel::FT FT; +typedef Kernel::Point_d Point; +typedef Kernel::Vector_d Vector; +typedef tc::Tangential_complex< +Kernel, CGAL::Dynamic_dimension_tag, +CGAL::Parallel_tag> TC; + +int main(void) { + const int INTRINSIC_DIM = 1; + + // Generate points on a 2-sphere + std::vector points; + // [[0, 0], [1, 0], [0, 1], [1, 1]] + std::vector point = {0.0, 0.0}; + points.push_back(Point(point.size(), point.begin(), point.end())); + point = {1.0, 0.0}; + points.push_back(Point(point.size(), point.begin(), point.end())); + point = {0.0, 1.0}; + 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())); + + Kernel k; + for (int i = 0; i < 100; i++) { + + // 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 << + " - inconsistencies = " << num_inc.num_inconsistent_simplices << std::endl; + + tc.fix_inconsistencies_using_perturbation(10.0, 60.0); + // 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; + + } + + return 0; +} diff --git a/src/Tangential_complex/include/gudhi/Tangential_complex/config.h b/src/Tangential_complex/include/gudhi/Tangential_complex/config.h index 98a1b14f..ffefcd6b 100644 --- a/src/Tangential_complex/include/gudhi/Tangential_complex/config.h +++ b/src/Tangential_complex/include/gudhi/Tangential_complex/config.h @@ -26,8 +26,7 @@ #include // ========================= Debugging & profiling ============================= -#define GUDHI_TC_PROFILING -#define DEBUG_TRACES +// #define GUDHI_TC_PROFILING // #define GUDHI_TC_VERY_VERBOSE // #define GUDHI_TC_PERFORM_EXTRA_CHECKS // #define GUDHI_TC_SHOW_DETAILED_STATS_FOR_INCONSISTENCIES -- cgit v1.2.3