summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt100
-rw-r--r--data/points/generator/CMakeLists.txt16
-rw-r--r--data/points/tore3D_1307.txt1307
-rw-r--r--src/Bottleneck/test/CMakeLists.txt4
-rw-r--r--src/CMakeLists.txt62
-rw-r--r--src/Contraction/example/Garland_heckbert.cpp17
-rw-r--r--src/Contraction/example/Rips_contraction.cpp4
-rw-r--r--src/Contraction/include/gudhi/Edge_contraction.h4
-rw-r--r--src/Contraction/include/gudhi/Skeleton_blocker_contractor.h11
-rw-r--r--src/GudhUI/CMakeLists.txt20
-rw-r--r--src/GudhUI/model/Model.h6
-rw-r--r--src/GudhUI/utils/Is_manifold.h2
-rw-r--r--src/GudhUI/utils/K_nearest_builder.h10
-rw-r--r--src/GudhUI/view/Viewer_instructor.cpp2
-rw-r--r--src/GudhUI/view/Viewer_instructor.h4
-rw-r--r--src/Hasse_complex/include/gudhi/Hasse_complex.h44
-rw-r--r--src/Persistent_cohomology/concept/FilteredComplex.h6
-rw-r--r--src/Persistent_cohomology/example/CMakeLists.txt9
-rw-r--r--src/Persistent_cohomology/example/alpha_shapes_persistence.cpp7
-rw-r--r--src/Persistent_cohomology/example/parallel_rips_persistence.cpp180
-rw-r--r--src/Persistent_cohomology/example/performance_rips_persistence.cpp2
-rw-r--r--src/Persistent_cohomology/example/persistence_from_file.cpp2
-rw-r--r--src/Persistent_cohomology/example/plain_homology.cpp4
-rw-r--r--src/Persistent_cohomology/example/rips_multifield_persistence.cpp5
-rw-r--r--src/Persistent_cohomology/example/rips_persistence.cpp5
-rw-r--r--src/Persistent_cohomology/include/gudhi/Persistent_cohomology.h35
-rw-r--r--src/Persistent_cohomology/include/gudhi/Persistent_cohomology/Multi_field.h3
-rw-r--r--src/Persistent_cohomology/include/gudhi/Persistent_cohomology/Persistent_cohomology_column.h1
-rw-r--r--src/Persistent_cohomology/test/CMakeLists.txt4
-rw-r--r--src/Simplex_tree/concept/SimplexTreeOptions.h2
-rw-r--r--src/Simplex_tree/example/CMakeLists.txt10
-rw-r--r--src/Simplex_tree/example/simplex_tree_from_alpha_shapes_3.cpp5
-rw-r--r--src/Simplex_tree/include/gudhi/Simplex_tree.h72
-rw-r--r--src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_iterators.h81
-rw-r--r--src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_siblings.h2
-rw-r--r--src/Simplex_tree/test/CMakeLists.txt4
-rw-r--r--src/Simplex_tree/test/simplex_tree_unit_test.cpp135
-rw-r--r--src/Skeleton_blocker/example/Skeleton_blocker_from_simplices.cpp29
-rw-r--r--src/Skeleton_blocker/example/Skeleton_blocker_iteration.cpp7
-rw-r--r--src/Skeleton_blocker/example/Skeleton_blocker_link.cpp12
-rw-r--r--src/Skeleton_blocker/include/gudhi/Skeleton_blocker.h33
-rw-r--r--src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_complex_visitor.h10
-rw-r--r--src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_link_superior.h6
-rw-r--r--src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_off_io.h8
-rw-r--r--src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_simplex.h4
-rw-r--r--src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_sub_complex.h24
-rw-r--r--src/Skeleton_blocker/include/gudhi/Skeleton_blocker/internal/Trie.h34
-rw-r--r--src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_blockers_iterators.h4
-rw-r--r--src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_simplices_iterators.h109
-rw-r--r--src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_triangles_iterators.h18
-rw-r--r--src/Skeleton_blocker/include/gudhi/Skeleton_blocker_complex.h225
-rw-r--r--src/Skeleton_blocker/include/gudhi/Skeleton_blocker_geometric_complex.h10
-rw-r--r--src/Skeleton_blocker/include/gudhi/Skeleton_blocker_link_complex.h53
-rw-r--r--src/Skeleton_blocker/include/gudhi/Skeleton_blocker_simplifiable_complex.h104
-rw-r--r--src/Skeleton_blocker/test/CMakeLists.txt4
-rw-r--r--src/Skeleton_blocker/test/TestGeometricComplex.cpp154
-rw-r--r--src/Skeleton_blocker/test/TestSimplifiable.cpp620
-rw-r--r--src/Skeleton_blocker/test/TestSkeletonBlockerComplex.cpp1652
-rw-r--r--src/cmake/modules/FindTBB.cmake433
-rw-r--r--src/cmake/modules/UseTBB.cmake6
-rw-r--r--src/common/doc/main_page.h17
-rw-r--r--src/common/include/gudhi/allocator.h55
62 files changed, 4079 insertions, 1739 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e4ad73af..5d2f932c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -7,48 +7,70 @@ configure_file(GUDHIVersion.cmake.in "${PROJECT_BINARY_DIR}/GUDHIVersion.cmake"
find_package(Boost REQUIRED COMPONENTS system filesystem unit_test_framework chrono timer program_options thread REQUIRED)
-set(CMAKE_PREFIX_PATH "${CMAKE_SOURCE_DIR}/src/cmake/modules/")
-set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/src/cmake/modules/")
-message("CMAKE_PREFIX_PATH = ${CMAKE_PREFIX_PATH}")
-message("CMAKE_MODULE_PATH = ${CMAKE_MODULE_PATH}")
-
-enable_testing()
-
-if(MSVC)
- # Turn off some VC++ warnings
- SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4267 /wd4668 /wd4311 /wd4800 /wd4820 /wd4503 /wd4244 /wd4345 /wd4996 /wd4396 /wd4018")
-else()
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -std=c++11 -Wall -Wpedantic -Wsign-compare")
- set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -ggdb -O0")
- set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
-endif()
-
-set(Boost_USE_STATIC_LIBS ON)
-set(Boost_USE_MULTITHREADED ON)
-set(Boost_USE_STATIC_RUNTIME OFF)
-
-find_package(GMP)
-if(GMP_FOUND)
- find_package(GMPXX)
-endif()
-
-find_package(CGAL)
-
-# Required programs for unitary tests purpose
-FIND_PROGRAM( GCOVR_PATH gcovr )
-if (GCOVR_PATH)
- message("gcovr found in ${GCOVR_PATH}")
-endif()
-# Required programs for unitary tests purpose
-FIND_PROGRAM( GPROF_PATH gprof )
-if (GPROF_PATH)
- message("gprof found in ${GPROF_PATH}")
-endif()
-
-
if(NOT Boost_FOUND)
message(FATAL_ERROR "NOTICE: This demo requires Boost and will not be compiled.")
else()
+
+ set(CMAKE_PREFIX_PATH "${CMAKE_SOURCE_DIR}/src/cmake/modules/")
+ set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/src/cmake/modules/")
+ message("CMAKE_PREFIX_PATH = ${CMAKE_PREFIX_PATH}")
+ message("CMAKE_MODULE_PATH = ${CMAKE_MODULE_PATH}")
+
+ enable_testing()
+
+ find_package(GMP)
+ if(GMP_FOUND)
+ INCLUDE_DIRECTORIES(${GMP_INCLUDE_DIR})
+ find_package(GMPXX)
+ if(GMPXX_FOUND)
+ INCLUDE_DIRECTORIES(${GMPXX_INCLUDE_DIR})
+ endif()
+ endif()
+
+ # In CMakeLists.txt, when include(${CGAL_USE_FILE}), CMAKE_CXX_FLAGS are overwritten.
+ # cf. http://doc.cgal.org/latest/Manual/installation.html#title40
+ # A workaround is to include(${CGAL_USE_FILE}) before adding "-std=c++11".
+ # A fix would be to use https://cmake.org/cmake/help/v3.1/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.html
+ # or even better https://cmake.org/cmake/help/v3.1/variable/CMAKE_CXX_STANDARD.html
+ # but it implies to use cmake version 3.1 at least.
+ find_package(CGAL)
+ if(CGAL_FOUND)
+ include( ${CGAL_USE_FILE} )
+ endif()
+
+ if(MSVC)
+ # Turn off some VC++ warnings
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4267 /wd4668 /wd4311 /wd4800 /wd4820 /wd4503 /wd4244 /wd4345 /wd4996 /wd4396 /wd4018")
+ else()
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wpedantic -Wsign-compare")
+ endif()
+
+ if(CMAKE_BUILD_TYPE MATCHES Debug)
+ message("++ Debug compilation flags are: ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG}")
+ else()
+ message("++ Release compilation flags are: ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE}")
+ endif()
+
+ set(Boost_USE_STATIC_LIBS ON)
+ set(Boost_USE_MULTITHREADED ON)
+ set(Boost_USE_STATIC_RUNTIME OFF)
+
+ # Find TBB package for parallel sort - not mandatory, just optional.
+ set(TBB_FIND_QUIETLY ON)
+ find_package(TBB)
+
+ # Required programs for unitary tests purpose
+ FIND_PROGRAM( GCOVR_PATH gcovr )
+ if (GCOVR_PATH)
+ message("gcovr found in ${GCOVR_PATH}")
+ endif()
+ # Required programs for unitary tests purpose
+ FIND_PROGRAM( GPROF_PATH gprof )
+ if (GPROF_PATH)
+ message("gprof found in ${GPROF_PATH}")
+ endif()
+
+
# BOOST ISSUE result_of vs C++11
add_definitions(-DBOOST_RESULT_OF_USE_DECLTYPE)
# BOOST ISSUE with Libraries name resolution under Windows
diff --git a/data/points/generator/CMakeLists.txt b/data/points/generator/CMakeLists.txt
index 26b44446..c01a380d 100644
--- a/data/points/generator/CMakeLists.txt
+++ b/data/points/generator/CMakeLists.txt
@@ -5,22 +5,6 @@ if(CGAL_FOUND)
if (NOT CGAL_VERSION VERSION_LESS 4.6.0)
message(STATUS "CGAL version: ${CGAL_VERSION}.")
- include( ${CGAL_USE_FILE} )
- # In CMakeLists.txt, when include(${CGAL_USE_FILE}), CXX_FLAGS are overwritten.
- # cf. http://doc.cgal.org/latest/Manual/installation.html#title40
- # A workaround is to add "-std=c++11" again.
- # A fix would be to use https://cmake.org/cmake/help/v3.1/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.html
- # or even better https://cmake.org/cmake/help/v3.1/variable/CMAKE_CXX_STANDARD.html
- # but it implies to use cmake version 3.1 at least.
- if(NOT MSVC)
- include(CheckCXXCompilerFlag)
- CHECK_CXX_COMPILER_FLAG(-std=c++11 COMPILER_SUPPORTS_CXX11)
- if(COMPILER_SUPPORTS_CXX11)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
- endif()
- endif()
- # - End of workaround
-
find_package(Eigen3 3.1.0)
if (EIGEN3_FOUND)
include( ${EIGEN3_USE_FILE} )
diff --git a/data/points/tore3D_1307.txt b/data/points/tore3D_1307.txt
new file mode 100644
index 00000000..7a1b9e60
--- /dev/null
+++ b/data/points/tore3D_1307.txt
@@ -0,0 +1,1307 @@
+-1.081352 -0.451815 0.237511
+-1.062873 -0.492063 -0.246058
+-0.490280 -0.890039 0.299674
+-1.094597 -0.620156 0.153419
+-0.517128 -1.189962 -0.039580
+1.152877 0.300175 -0.231559
+0.502337 1.174528 0.114471
+-0.299269 -1.235308 -0.128350
+0.559591 1.172809 -0.019004
+0.184193 -0.676264 -0.024016
+-0.888412 0.748820 -0.252659
+-0.859062 -0.581840 0.297612
+0.293395 -1.216582 -0.163670
+0.393949 -1.126922 -0.228892
+0.441284 -1.075139 -0.252409
+-0.658443 0.286084 0.102036
+-0.770782 -0.787327 -0.282279
+-0.406644 1.191333 -0.151820
+0.421148 0.751386 0.266188
+-0.337991 -1.233999 0.109125
+-0.576506 0.405645 -0.054051
+0.359474 0.613240 0.079974
+-0.455484 -0.568690 -0.127880
+0.702136 -0.235409 -0.150928
+0.091056 -0.696011 0.037399
+-0.064213 -1.043207 -0.296606
+-0.066480 -0.708601 -0.083866
+-0.866010 -0.584473 -0.296793
+0.476020 0.521113 0.058829
+0.470937 0.518518 -0.020041
+0.436955 0.578033 0.118941
+0.510216 0.479447 0.010043
+0.552069 0.434267 -0.037525
+0.570514 0.483559 0.162698
+0.520778 0.488742 0.091457
+0.007764 -1.064538 0.292870
+-0.050586 -1.121647 0.273674
+0.055839 -1.248122 0.166563
+-0.032797 -1.208186 0.215517
+-0.111026 -1.277187 0.102083
+-0.108199 -1.228175 0.189078
+-0.130166 -1.089441 0.283875
+-0.152281 -0.988000 0.299890
+-0.257364 -1.167207 0.227592
+-0.171612 -1.165220 0.241502
+-1.162998 0.381345 -0.199780
+-1.118806 0.446593 -0.219113
+-0.969520 0.369639 -0.297369
+-1.015149 0.442441 -0.279944
+-0.945706 0.502039 -0.291395
+-0.907852 0.668109 -0.271495
+-0.989109 0.583976 -0.260348
+-1.151615 0.505514 -0.153644
+-1.207510 0.471993 -0.044521
+-1.104315 0.650680 -0.102654
+-1.092710 0.584417 -0.180772
+-0.520165 0.523045 0.145339
+-0.908993 0.242970 0.293971
+-0.810558 0.265720 0.261300
+-0.897194 0.450947 0.299838
+-0.801677 0.368615 0.275680
+-0.618631 0.339910 -0.058175
+-0.745800 0.194272 0.193649
+-0.764778 0.089444 0.192796
+-0.677218 0.179465 -0.017122
+-0.951381 0.107469 -0.296882
+-1.044006 0.122763 -0.295486
+-1.130206 0.327437 -0.242377
+-1.039272 0.319024 -0.286828
+-1.006740 0.250370 -0.297517
+-1.074288 0.196042 -0.285418
+-1.179201 0.271080 -0.214486
+-1.159801 0.205309 -0.241580
+-1.262356 0.149537 -0.128957
+-1.209803 0.141532 -0.206239
+-1.103598 0.056448 -0.281019
+-1.069017 -0.026030 -0.291850
+-1.230492 -0.003439 -0.192273
+-1.186921 0.066026 -0.233374
+-1.239215 0.383964 -0.040221
+-1.221544 0.353027 -0.127998
+-1.231122 0.282629 -0.144722
+-1.265581 0.224586 -0.093610
+-1.278661 0.235723 -0.002121
+-1.258566 0.316739 0.036060
+-1.142814 0.618337 0.016377
+-1.186973 0.519848 0.048538
+-1.002081 0.324515 0.294944
+-0.998092 0.428671 0.287072
+-1.081725 0.504658 0.228721
+-1.161877 0.464839 0.162892
+-1.228669 0.307236 0.137309
+-1.223687 0.221595 0.175255
+-1.094190 0.299505 0.267834
+-1.172804 0.362343 0.194898
+-1.287785 0.080944 -0.076717
+-1.278902 0.004250 -0.110779
+-1.296965 0.086769 0.015989
+-1.290442 0.014796 0.076047
+-1.257240 0.161846 0.135908
+-1.285433 0.163110 0.051651
+-0.886853 0.152690 -0.282767
+-0.904457 0.223940 -0.291991
+-0.853657 0.340015 -0.288701
+-0.662561 0.323217 -0.144815
+-0.688153 0.235729 -0.124945
+-0.746102 0.209917 -0.198615
+-0.825513 0.260841 -0.268220
+-0.814460 0.106161 -0.241124
+-0.751881 0.125125 -0.182955
+-0.694463 0.087754 -0.002227
+-0.718096 0.030274 0.104055
+-0.725588 -0.037936 -0.124016
+-0.715162 0.057103 -0.100962
+-0.589244 0.833226 -0.299481
+-0.698686 0.797210 -0.293987
+-0.724145 0.963727 -0.218762
+-0.772661 0.863564 -0.254443
+-0.952389 0.746095 -0.214405
+-1.037783 0.734366 -0.127409
+-0.906947 0.888998 -0.130794
+-0.879694 0.826349 -0.216987
+-0.708976 0.691352 -0.299681
+-0.795825 0.632666 -0.299354
+-1.094557 0.205733 0.277474
+-1.166956 0.180982 0.239452
+-1.235100 0.093251 0.182145
+-1.252852 0.020112 0.161546
+-1.122616 0.045423 0.273322
+-1.176019 0.104304 0.239683
+-0.831534 0.028847 -0.248610
+-0.784800 -0.051320 -0.210683
+-0.970175 -0.039735 -0.298404
+-0.915801 0.031759 -0.287960
+-1.017315 0.133847 0.298781
+-1.040809 0.053958 0.296991
+-0.850253 0.061846 0.261250
+-0.922621 0.144598 0.292551
+-1.205576 -0.083392 -0.215756
+-1.127676 -0.097664 -0.269488
+-1.218875 -0.228370 -0.179640
+-1.241479 -0.151333 -0.164511
+-1.281008 -0.141697 -0.081100
+-1.282725 -0.207501 -0.019002
+-1.295404 -0.061623 0.045226
+-1.294057 -0.065990 -0.051164
+-1.266583 -0.280977 -0.040054
+-1.240056 -0.292948 -0.121946
+-1.272968 -0.133906 0.108272
+-1.274739 -0.205619 0.072097
+-1.254749 -0.331515 0.036391
+-1.230958 -0.414312 0.026169
+-1.188467 -0.290913 0.199876
+-1.247215 -0.280317 0.111825
+-0.714306 -0.076055 0.102946
+-0.722893 -0.247937 0.185450
+-0.755066 -0.146639 0.191478
+-0.892565 -0.032108 0.280205
+-0.993747 -0.023773 0.299917
+-0.848739 -0.126278 0.264223
+-1.137674 -0.030533 0.266157
+-1.209182 -0.047928 0.214183
+-1.221441 -0.129173 0.194550
+-1.160987 -0.202671 0.240867
+-1.069850 -0.172552 0.288004
+-1.063790 -0.080596 0.292372
+-1.158039 -0.249717 -0.236406
+-1.100040 -0.186683 -0.276695
+-1.150286 -0.337789 -0.224600
+-1.074319 -0.379918 -0.265438
+-1.211559 -0.436746 -0.083952
+-1.207229 -0.363808 -0.148360
+-0.931978 -0.130288 -0.293972
+-0.829416 -0.140227 -0.254308
+-0.987281 -0.311755 -0.297765
+-1.005930 -0.209775 -0.298601
+-0.521727 0.765192 -0.290775
+-1.148019 -0.386210 0.212818
+-1.190078 -0.459193 0.118044
+-1.158436 -0.559820 0.087646
+-1.167821 -0.516767 -0.114878
+-1.096278 -0.674600 -0.086267
+-1.155066 -0.591214 -0.036592
+-0.771608 1.005459 -0.135935
+-0.852825 0.959308 -0.097955
+-0.814246 1.007568 0.052984
+-0.869887 0.966193 -0.005886
+-0.965682 0.863491 -0.052417
+-1.028122 0.791500 -0.038978
+-0.927269 0.875414 0.119585
+-0.930881 0.906369 0.024163
+-0.566961 0.990224 0.264677
+-0.534303 1.091724 0.208631
+-0.718230 1.074222 -0.067833
+-0.745807 1.063247 0.028303
+-0.691291 1.076225 0.109998
+-0.602869 1.125480 0.115647
+-0.618246 1.129229 -0.085232
+-0.561684 1.171822 0.013519
+-0.450125 1.218907 0.016890
+-0.427083 1.134526 0.212045
+-0.271294 1.244331 0.122793
+-0.387285 1.213311 0.122658
+-1.094776 0.667045 0.101590
+-1.058368 0.607909 0.203007
+-0.978607 0.795203 0.147752
+-1.045755 0.757303 0.071993
+-0.801245 0.978278 0.141861
+-0.848741 0.906595 0.177594
+-0.668853 0.960921 0.246697
+-0.722169 1.011591 0.176481
+-0.480102 0.515515 0.050987
+-0.713545 -0.254054 -0.176596
+-0.686648 -0.346332 -0.191457
+-0.878900 -0.326981 -0.293245
+-0.797228 -0.236768 -0.248167
+-0.935677 0.734226 0.232423
+-0.967497 0.636933 0.254631
+-0.888477 0.555640 0.296089
+-0.791078 0.572816 0.298952
+-0.705808 0.865927 0.276371
+-0.802219 0.847107 0.249569
+-0.839916 0.754886 0.270695
+-0.771240 0.672138 0.299109
+-0.613878 0.599194 0.264134
+-0.530763 0.595344 0.221167
+-0.640168 0.780483 0.299749
+-0.673841 0.682444 0.297213
+-1.049085 -0.401913 0.273442
+-1.018454 -0.506904 0.266417
+-0.767742 -0.615905 0.299286
+-0.927725 -0.790117 0.205312
+-0.963772 -0.701033 0.230404
+-0.397985 0.701026 -0.229017
+-0.429407 0.774740 -0.277375
+-0.243658 0.752702 -0.215316
+-0.314726 0.693460 -0.182081
+-0.309573 0.643825 -0.091955
+-0.232485 0.661107 -0.021837
+-0.406312 0.572607 0.034624
+-0.391149 0.590737 -0.071491
+-0.551266 -0.809351 0.299338
+-0.687239 -0.975305 0.229314
+-0.536247 0.795816 0.297073
+-0.376939 0.918504 0.299808
+-0.494239 0.903007 0.298412
+-0.347646 0.634621 0.116610
+-0.251386 0.667185 0.087247
+-0.585533 -0.668753 0.278789
+-0.515444 -0.720691 0.277880
+-0.584628 -0.577694 0.241249
+-0.675393 -0.440771 0.228850
+-0.671482 -0.539889 0.265697
+-0.853291 -0.420036 -0.295950
+-0.751319 -0.421284 -0.266151
+-0.730875 -0.506183 -0.278896
+-0.790705 -0.568691 -0.299425
+-1.040254 -0.658033 -0.191569
+-0.916951 -0.512416 -0.295830
+-0.810410 -0.638033 -0.298556
+-0.748693 -0.696571 -0.299261
+-0.953502 -0.699942 -0.237685
+-0.889123 -0.651913 -0.282308
+0.962416 0.841972 -0.111265
+0.913452 0.821515 -0.194271
+0.810323 0.959205 -0.157265
+0.825787 0.882616 -0.215781
+0.654429 0.921109 -0.270355
+0.740022 0.854310 -0.270155
+0.617250 0.707515 -0.293668
+0.729631 0.755312 -0.295664
+0.929579 0.731572 -0.237493
+1.025178 0.659435 -0.204964
+0.815022 0.609543 -0.299435
+0.829173 0.699676 -0.287674
+-0.954822 -0.852912 0.106773
+-0.920233 -0.786312 -0.213849
+-0.888107 -0.920442 -0.110019
+-0.950851 -0.845548 -0.125402
+-0.204577 1.197671 0.209135
+-0.047190 1.054470 0.294865
+-0.140538 0.995875 0.299919
+-0.183526 0.717846 0.151647
+-0.028992 0.841029 0.254906
+-0.131597 0.885679 0.281198
+-0.893964 -0.927064 0.084480
+-0.872584 -0.962902 -0.015965
+-0.757646 -1.003637 0.153780
+-0.825670 -0.941871 0.162142
+-0.562879 1.104166 -0.180672
+-0.545627 0.937180 -0.287941
+-0.612412 1.007909 -0.240620
+-0.617710 -0.377137 -0.116819
+-0.280120 -0.643123 0.027697
+-0.362574 -0.598874 0.004105
+-0.641128 -0.520733 -0.244197
+-0.583385 -0.459863 -0.154090
+-0.508969 -0.499792 -0.087955
+-0.217732 1.280782 0.020568
+-0.044103 1.290446 -0.071942
+-0.103040 1.295146 0.019918
+-0.092171 1.215808 0.204421
+-0.026018 1.151911 0.258433
+0.071646 1.277176 0.109400
+-0.042088 1.275636 0.116383
+-0.428680 0.956160 -0.296166
+-0.365528 1.061240 -0.273915
+-0.271612 0.843132 -0.277322
+-0.375317 0.857960 -0.293228
+-0.200079 0.918983 -0.294116
+-0.178178 1.215719 -0.194119
+-0.075228 1.249002 -0.163810
+-0.051371 1.064720 -0.292426
+-0.749268 -1.055549 0.055744
+-0.800770 -1.021747 -0.030796
+-0.810673 -0.939807 -0.178594
+-0.676875 -1.042950 -0.174886
+-0.764002 -1.010285 -0.137011
+-0.607360 -0.978326 -0.258591
+-0.639279 -0.869686 -0.289246
+-0.099286 0.882593 -0.278219
+-0.026016 0.952109 -0.296002
+-0.075059 0.785864 -0.213491
+0.022346 0.754006 -0.172106
+-0.147283 0.691698 -0.065795
+-0.152610 0.736776 -0.169325
+-0.378927 -1.218959 -0.116129
+-0.460774 -1.212046 -0.046903
+-0.673535 -1.110549 0.021351
+-0.641230 -1.110616 -0.100066
+-0.552196 -1.145175 -0.127541
+-0.478087 -1.206587 0.038229
+-0.426464 -1.201374 0.120116
+-0.602509 -1.137404 0.087065
+-0.542556 -1.180242 0.029905
+-0.562520 -1.097531 0.188483
+-0.460930 -1.132398 0.201171
+-0.595745 -1.009843 0.245200
+0.018426 -0.699933 0.003927
+-0.220857 -0.669403 -0.053967
+-0.136855 -0.687966 -0.029266
+-0.039762 -0.737462 -0.147506
+0.013375 -0.765153 -0.187063
+-0.161318 -0.763629 -0.204449
+-0.102092 -0.735829 -0.155003
+-0.501991 -1.011704 -0.270374
+-0.385708 -1.151435 -0.209805
+-0.481519 -1.109550 -0.214688
+-0.084473 -0.912505 0.287939
+-0.009384 -0.954155 0.296280
+-0.235834 -0.958771 0.299674
+-0.264772 -0.680387 0.130846
+-0.343569 -0.823271 0.280057
+-0.251071 -0.852290 0.278391
+-0.090018 -0.814576 0.239527
+-0.013113 -0.763248 0.184274
+-0.028831 -0.712816 0.088689
+-0.115013 -0.698739 0.069244
+-0.182891 -0.715992 0.147883
+-0.173557 -0.786385 0.228326
+-0.299909 -1.096421 -0.266587
+-0.140175 -1.059353 -0.292189
+-0.198818 -1.124595 -0.263882
+-0.182305 -1.281469 0.057550
+-0.312375 -1.255560 -0.061168
+-0.156831 -1.204198 -0.209697
+-0.040651 -1.198621 -0.224542
+-0.154841 -1.287160 -0.046290
+-0.219968 -1.256120 -0.119186
+-0.065222 0.696920 -0.002844
+0.026516 0.706518 -0.064130
+-0.007319 0.755929 0.174347
+-0.083290 0.717101 0.112792
+0.027699 1.128169 -0.270914
+0.014769 1.214505 -0.209679
+0.061354 1.289607 -0.072153
+0.123107 1.293828 0.011937
+0.194987 1.222109 -0.182960
+0.095568 1.249916 -0.160038
+0.005081 -1.109260 -0.279505
+-0.126805 -0.982559 -0.299961
+-0.185024 -0.908465 -0.290877
+-0.134344 -0.830990 -0.254870
+-0.030626 -0.832050 -0.249210
+0.009648 -0.910269 -0.286484
+-0.050433 -0.969471 -0.298845
+0.041177 1.007630 0.300057
+0.054442 0.902242 0.284235
+0.113508 1.077381 0.288041
+0.208155 1.053604 0.290424
+0.129841 1.227050 0.187522
+0.075815 1.162148 0.250734
+0.240147 1.215023 0.181620
+0.279879 1.132062 0.249544
+0.457600 1.159578 0.170861
+0.382487 1.106421 0.246255
+0.483023 0.975561 0.286352
+0.398800 1.001107 0.289444
+0.230786 0.939193 0.298007
+0.153231 0.861608 0.272702
+0.326097 0.914284 0.298337
+0.300457 1.251699 0.085600
+0.426068 1.218448 0.073121
+0.274212 1.248636 -0.111198
+0.236083 1.278119 -0.004401
+-0.058656 -1.291853 -0.064397
+0.007691 -1.257719 -0.154006
+0.059179 -1.292552 0.059443
+-0.033167 -1.297935 0.031239
+0.524254 -1.172829 -0.093831
+0.680024 -1.036405 -0.180477
+0.588607 -1.019811 -0.241688
+0.688092 -0.861809 -0.281993
+0.588081 -0.921022 -0.285347
+0.545699 -0.717525 -0.283527
+0.104077 -1.060046 -0.293005
+0.103169 -0.939224 -0.294890
+0.190046 -0.865922 -0.277689
+0.358496 -1.182321 -0.186063
+0.195163 -1.103773 -0.274883
+0.139164 -1.291090 -0.027577
+0.114294 -1.259480 -0.141230
+0.201509 -1.200514 -0.206958
+0.365868 -1.225732 -0.110196
+0.438981 -1.219682 -0.045834
+0.240009 -1.277322 -0.010875
+0.293495 -1.253573 -0.086921
+0.275945 -0.973380 0.299654
+0.057305 -0.799652 0.224755
+0.052788 -0.894999 0.281478
+0.122150 -0.936773 0.294861
+0.128478 1.083846 -0.285647
+0.211785 1.139038 -0.254607
+0.308977 0.989490 -0.297975
+0.307056 1.090644 -0.268967
+0.381529 1.208847 -0.134663
+0.472080 1.207292 -0.045157
+0.487524 1.067336 -0.244599
+0.395848 1.131245 -0.224775
+0.384004 0.927480 -0.300089
+0.476426 0.961494 -0.290944
+0.554536 0.885807 -0.296415
+0.528181 0.772403 -0.292877
+0.099619 0.801283 -0.229813
+0.072511 0.906825 -0.285850
+0.145019 0.974900 -0.299572
+0.234103 0.933480 -0.297689
+0.356271 0.829250 -0.283622
+0.423502 0.747092 -0.264788
+0.202947 0.768384 -0.218615
+0.262419 0.835079 -0.272805
+0.288495 -1.255384 0.083645
+0.402270 -1.228877 0.063658
+0.232743 -1.215498 0.182993
+0.284587 -1.141892 0.242286
+0.235422 -1.056762 0.288326
+0.148416 -1.038004 0.295980
+0.093182 -1.108653 0.277987
+0.127978 -1.204079 0.213226
+0.247820 0.694114 -0.144552
+0.279902 0.717162 0.192782
+0.175906 0.762650 0.206597
+0.096975 0.728765 0.141098
+0.554793 1.119556 0.166533
+0.557149 1.031838 0.245398
+0.707704 0.981963 0.214120
+0.621770 0.975174 0.255932
+0.499888 0.883087 0.299571
+0.633511 0.819251 0.297640
+0.585835 0.888221 0.292755
+0.382817 -1.129194 0.230101
+0.450111 -1.177304 0.148434
+0.554877 -1.062688 0.224601
+0.547087 -1.134743 0.149614
+0.616089 -1.141655 -0.038338
+0.690686 -1.084182 -0.091947
+0.713191 -1.060448 0.112490
+0.626418 -1.127788 0.075791
+0.622131 -1.005820 0.238017
+0.704955 -1.003844 0.196622
+0.372015 -0.868978 0.294789
+0.353677 -0.965625 0.298543
+0.409685 -1.040978 0.275379
+0.488880 -1.017382 0.270835
+0.592248 -0.930935 0.281773
+0.636318 -0.857503 0.292346
+0.454105 -0.849356 0.297671
+0.509796 -0.931635 0.293481
+0.100362 -0.733003 -0.149052
+0.106011 -0.694022 -0.035885
+0.186966 -0.762933 -0.209494
+0.264656 -0.648763 -0.020676
+0.171153 -0.682499 0.048323
+0.644979 1.109511 0.098613
+0.723575 1.042383 0.133371
+0.643327 1.129261 -0.012966
+0.731125 1.066529 -0.063191
+0.735769 1.021555 -0.151593
+0.661112 1.016580 -0.211551
+0.577174 1.089469 -0.188525
+0.569973 1.153206 -0.089037
+0.496925 0.607536 0.209207
+0.582530 0.553639 0.226988
+0.600442 0.730008 0.294883
+0.499216 0.692742 0.261996
+0.497070 -0.760675 0.285834
+0.595361 -0.774001 0.299140
+0.462269 -0.669636 0.235124
+0.543659 -0.590459 0.226011
+0.366772 -0.666334 0.180901
+0.462710 -0.543362 -0.089479
+0.541941 -0.471227 -0.103146
+0.518095 -0.634633 -0.239425
+0.443382 -0.612238 -0.173940
+0.770376 0.902477 0.234897
+0.728863 0.828294 0.281473
+0.682704 0.684132 0.298120
+0.677508 0.589203 0.282142
+0.867906 0.716179 0.272504
+0.765689 0.743942 0.292183
+0.791940 -1.024801 0.052917
+0.774972 -1.039592 -0.044206
+0.763018 -0.975194 -0.182386
+0.773694 -0.897213 -0.236617
+0.904634 -0.917168 -0.082862
+0.822859 -0.981979 -0.104505
+0.700611 -0.764893 -0.297920
+0.632368 -0.707732 -0.295909
+0.585191 -0.575751 -0.240822
+0.595841 -0.488753 -0.193600
+0.717391 -0.584984 -0.290581
+0.647996 -0.619303 -0.281588
+0.613023 0.606343 -0.266521
+0.711991 0.567597 -0.286250
+0.576003 0.461515 -0.146199
+0.542279 0.550486 -0.195749
+0.800811 1.023281 -0.019748
+0.804401 1.009700 0.073645
+0.920616 0.910473 -0.056411
+0.852528 0.967320 -0.079500
+0.646476 -0.611121 0.278777
+0.665480 -0.711019 0.298794
+0.726785 -0.852133 0.275179
+0.769212 -0.921322 0.223643
+0.854869 -0.722552 0.275257
+0.754953 -0.761594 0.291154
+0.929233 -0.848637 -0.152528
+0.859708 -0.837695 -0.223687
+0.784008 -0.718281 -0.293370
+0.783025 -0.630882 -0.299905
+0.926067 -0.692431 -0.256085
+0.860366 -0.753068 -0.263737
+0.863227 0.882869 0.186969
+0.925960 0.787953 0.208249
+0.939989 0.895718 0.032622
+0.876337 0.936474 0.101820
+0.872470 -0.946356 0.086184
+0.939219 -0.897996 0.014703
+0.921253 -0.791732 0.209547
+0.861473 -0.893730 0.178149
+1.011950 -0.754854 0.145024
+1.015580 -0.807465 0.037848
+0.742315 -0.551148 0.290009
+0.858941 -0.609519 0.294990
+0.934448 -0.430807 0.298546
+0.954522 -0.543808 0.283316
+1.154398 -0.594227 0.030710
+1.146413 -0.433385 0.197503
+1.161911 0.448906 0.172005
+0.882196 0.608502 0.291139
+0.774028 0.543762 0.294907
+0.958682 0.438441 0.295091
+0.976412 0.550518 0.274661
+1.029955 0.785386 -0.052364
+1.008879 0.815541 0.040295
+1.014120 0.759855 0.136049
+0.676848 -0.179346 -0.010685
+0.690110 -0.190866 -0.097051
+0.669004 -0.306090 -0.142069
+0.724850 -0.173534 -0.158843
+0.744120 -0.102561 -0.167415
+0.808341 -0.257098 -0.258833
+0.748255 -0.224531 -0.205765
+0.742118 0.090151 -0.161946
+0.676606 0.180382 0.011167
+0.655121 -0.254165 0.040569
+0.625228 -0.321331 -0.041687
+0.573020 -0.403162 -0.021541
+0.735876 -0.441472 0.264158
+0.831858 -0.387813 0.288421
+0.684045 -0.281952 0.149830
+0.660509 -0.387710 0.187547
+0.858557 0.392168 0.294688
+0.768042 0.439061 0.277044
+0.612020 0.413813 0.147531
+0.591019 0.379264 0.035168
+0.627978 0.309341 0.001827
+0.662612 0.251153 0.072768
+0.701323 0.280691 0.174432
+0.687070 0.380323 0.210031
+1.118092 -0.651290 -0.059560
+1.055819 -0.750298 -0.053264
+1.001667 -0.771773 -0.141811
+0.995520 -0.699458 -0.207720
+1.108977 -0.585948 -0.159087
+1.038365 -0.615304 -0.217255
+0.917814 -0.606493 -0.282803
+0.845411 -0.577835 -0.299133
+0.987525 -0.557775 -0.268346
+0.889943 0.542554 -0.297015
+1.222820 0.415983 0.069436
+1.217593 0.305147 -0.156870
+1.144438 -0.478794 -0.179068
+1.208277 -0.427621 -0.102134
+1.235958 -0.306822 -0.122413
+1.215422 -0.406665 0.102329
+1.206357 -0.483060 0.010549
+1.185614 -0.245192 -0.213354
+0.871611 -0.192130 -0.280159
+0.818725 -0.097645 -0.243261
+1.025984 -0.096418 -0.298406
+0.980099 -0.197894 -0.299969
+0.863848 -0.413479 -0.297150
+0.817636 -0.496759 -0.296888
+0.733302 -0.504268 -0.279179
+0.674549 -0.446113 -0.231166
+0.705405 -0.364418 -0.218107
+0.799773 -0.342705 -0.270286
+1.122262 0.352151 0.242808
+1.021343 0.354050 0.288929
+0.860115 0.286518 0.285114
+0.777918 0.224508 0.231974
+0.959504 0.261832 0.299707
+0.762268 -0.219779 0.217501
+0.839147 -0.280112 0.276984
+1.001574 -0.341729 0.294266
+1.105292 -0.335866 0.256625
+0.980311 -0.132138 0.299837
+0.940644 -0.246220 0.298701
+1.165480 0.233322 -0.232930
+0.656768 0.422261 -0.204497
+0.726403 0.481505 -0.270911
+0.832377 0.463625 -0.296040
+0.863536 0.370322 -0.293756
+0.962370 0.164539 -0.298955
+1.016050 0.073361 -0.299309
+0.963117 -0.010756 -0.297558
+0.859511 -0.010374 -0.264817
+0.814212 0.075072 -0.238101
+0.858030 0.158883 -0.271600
+1.115317 0.045633 -0.276695
+1.185542 0.113619 -0.231393
+1.195818 -0.124843 -0.221636
+1.120924 -0.063365 -0.273934
+0.782512 0.114529 0.215037
+0.775154 -0.108192 0.206922
+1.164754 0.237906 0.233001
+1.094081 -0.111437 0.282761
+1.154254 -0.216724 0.243831
+1.233599 0.006519 0.188448
+1.143764 0.000654 0.263208
+1.265412 -0.086944 0.134226
+1.236869 -0.198568 0.161288
+1.256210 -0.286906 0.080777
+1.275136 -0.241531 -0.032615
+1.259630 -0.062482 -0.147524
+1.256014 0.059308 -0.153941
+1.296757 -0.052817 0.036629
+1.290030 -0.119559 -0.050287
+0.709465 -0.047610 -0.080018
+0.693844 -0.095693 0.017962
+0.723811 -0.052492 0.122263
+0.725727 0.056212 0.127028
+0.694529 0.095815 0.027164
+0.708872 0.042114 -0.076576
+1.270438 0.246598 -0.058191
+1.259910 0.298051 0.055014
+1.242345 0.212671 0.148578
+1.266931 0.099039 0.129284
+1.296990 0.060790 0.031381
+1.287049 0.123373 -0.063715
+0.789145 0.216251 -0.238613
+0.728162 0.172093 -0.163104
+0.682332 0.208230 -0.088440
+0.656445 0.285993 -0.096871
+0.687970 0.335464 -0.186786
+0.780751 0.303558 -0.252109
+0.135508 -0.782976 0.218312
+0.169909 -0.866128 0.275945
+0.243915 -0.884224 0.288209
+0.302182 -0.818153 0.271380
+0.287490 -0.731087 0.209549
+0.192495 -0.720849 0.159476
+0.370903 -1.033939 -0.283443
+0.277237 -1.023820 -0.293778
+0.273185 -0.916310 -0.296699
+-0.796540 -0.878001 0.235911
+-0.708436 -0.889039 0.267125
+-0.646483 -0.815647 0.297459
+-0.667236 -0.730681 0.299898
+-0.759885 -0.717053 0.296493
+-0.834289 -0.799007 0.256798
+-0.612888 0.534769 -0.234888
+-0.617458 0.636376 -0.277816
+-0.538548 0.680382 -0.269273
+-0.465081 0.646712 -0.220646
+-0.464578 0.578950 -0.153904
+-0.542161 0.512962 -0.160492
+-0.649026 0.356285 0.149854
+-0.592371 0.407559 0.104765
+-0.579940 0.472056 0.162251
+-0.635487 0.515446 0.238547
+-0.711330 0.492828 0.267841
+-0.714295 0.398239 0.237973
+-0.685261 0.484037 -0.253085
+-0.701891 0.392885 -0.227738
+-0.790928 0.394196 -0.276596
+-0.834396 0.477478 -0.297499
+-0.768501 0.533539 -0.293094
+-0.762294 -0.319516 0.245107
+-0.835549 -0.341110 0.284045
+-0.821897 -0.425285 0.290792
+-0.745804 -0.402675 0.258445
+0.370568 -0.661759 -0.177739
+0.350364 -0.725302 -0.228616
+0.269312 -0.716197 -0.186586
+0.296292 -0.662405 -0.121866
+-0.389697 -0.594860 -0.081527
+-0.394159 -0.631719 -0.157238
+-0.468058 -0.614941 -0.196464
+1.054329 0.592118 0.215565
+1.118434 0.550900 0.170789
+1.119161 0.626165 0.101492
+1.065042 0.672237 0.150358
+1.202716 0.412027 -0.127709
+1.155164 0.478490 -0.165348
+1.212313 0.466093 -0.026041
+1.057486 -0.660840 0.170278
+1.114889 -0.610178 0.129444
+1.103640 -0.536177 0.196273
+1.038992 -0.580559 0.232303
+0.302600 0.659550 0.122060
+0.285892 0.642011 0.041481
+0.346889 0.607680 -0.000538
+0.413031 -0.929655 -0.299561
+0.356975 -0.871187 -0.294306
+0.397431 -0.787875 -0.276079
+0.491573 -0.790195 -0.292010
+0.503099 -0.880806 -0.299861
+-0.230347 1.037901 0.293338
+-0.252574 1.115751 0.263669
+-0.346938 1.086762 0.265383
+-0.325746 1.006858 0.294464
+-0.983754 -0.314178 0.298579
+-0.900572 -0.294456 0.295570
+-0.909603 -0.206607 0.292661
+-0.994319 -0.224547 0.299606
+-0.565330 0.413696 0.020050
+-0.547525 0.461399 -0.098082
+-0.527867 0.460442 -0.019763
+-0.280076 1.262025 -0.066755
+-0.261959 1.232560 -0.149640
+-0.386260 1.232627 -0.069757
+-0.259011 -1.259173 0.092090
+-0.281130 -1.219505 0.163988
+-0.312092 -1.260466 0.031755
+-0.583252 -0.403921 0.074423
+-0.608341 -0.345944 -0.011131
+-0.647202 -0.269335 0.026117
+-0.662918 -0.289520 0.116611
+-0.630989 -0.380907 0.144753
+0.441252 0.822211 0.292631
+0.361679 0.821086 0.282074
+0.339515 0.749680 0.242679
+-0.310323 -1.101878 0.262833
+-0.301766 -1.024790 0.292255
+-0.383030 -1.016220 0.287557
+-0.392581 -1.088534 0.255606
+-1.010324 -0.812112 -0.047781
+-1.008865 -0.815856 0.039056
+-1.058848 -0.746022 0.054108
+-1.065420 -0.742579 -0.029529
+-0.395237 1.137124 -0.220310
+-0.471595 1.140205 -0.188323
+-0.338405 1.194313 -0.178527
+-0.699800 -0.109455 -0.070765
+-0.689467 -0.120599 0.010743
+-0.671033 -0.199956 -0.014290
+-0.688217 -0.191421 -0.092680
+0.408102 0.663417 -0.203096
+0.466253 0.585630 -0.163718
+0.441485 0.557009 -0.079492
+0.377190 0.599405 -0.069782
+0.341626 0.653908 -0.145644
+-0.523619 -0.644705 -0.247708
+-0.511240 -0.750521 -0.285482
+-0.596144 -0.773469 -0.299212
+-0.656851 -0.683275 -0.295784
+-0.612259 -0.606882 -0.266568
+-0.473594 0.725633 0.268886
+-0.475706 0.654965 0.231692
+-0.393511 0.666313 0.197441
+-0.386707 0.728519 0.243539
+-0.226713 0.769971 0.226267
+-0.213057 0.836123 0.266821
+-0.309151 0.845991 0.283220
+-0.317285 0.776245 0.252873
+-0.213294 1.021565 -0.296975
+-0.267976 1.076045 -0.279727
+-0.196093 1.141235 -0.255162
+-0.146277 1.086413 -0.284270
+-0.839221 -0.808840 -0.250598
+-0.718594 -0.852266 -0.277379
+-0.786471 -0.873174 -0.243957
+0.503781 -0.508397 0.096169
+0.540943 -0.516324 0.162880
+0.590295 -0.440457 0.143772
+0.556546 -0.438798 0.070722
+1.084562 0.281819 -0.274968
+1.002617 0.250258 -0.298497
+0.963113 0.338957 -0.299498
+1.037546 0.369298 -0.282492
+-0.532627 -0.474451 0.087948
+-0.518299 -0.543742 0.167953
+-0.443480 -0.591791 0.149136
+-0.424565 -0.565344 0.064974
+-0.489497 -0.501100 0.020071
+-0.326613 -0.988326 -0.297219
+-0.423097 -0.944084 -0.297997
+-0.432796 -0.826832 -0.292235
+-0.345999 -0.809039 -0.274921
+-0.279305 -0.905123 -0.295123
+0.515979 -1.070956 -0.233456
+0.487322 -1.130354 -0.191475
+-0.925013 -0.626671 0.276302
+-0.865072 -0.495252 0.300282
+-0.935223 -0.536835 0.289813
+-0.694036 0.225684 0.130812
+-0.667444 0.225671 0.053514
+-0.638271 0.289192 0.023586
+-1.071978 -0.687841 0.123612
+-1.033204 -0.671857 0.189812
+-1.059406 -0.587136 0.213413
+-1.108029 -0.518786 -0.200463
+-1.005976 -0.519367 -0.269572
+-1.051147 -0.573816 -0.226187
+-0.256151 -0.689419 -0.141839
+-0.237598 -0.737223 -0.197979
+-0.317606 -0.741037 -0.229220
+-0.332805 -0.682788 -0.179335
+-0.434458 -0.956063 0.295992
+-0.418513 -0.880376 0.299329
+-0.520850 -0.950210 0.288273
+-0.406629 -0.654765 0.193769
+-0.435712 -0.703126 0.245543
+-0.365948 -0.743199 0.246380
+-0.335779 -0.691988 0.191801
+0.845940 -0.044368 0.258445
+0.920449 -0.047701 0.289810
+0.924185 0.051448 0.290867
+0.850188 0.054180 0.261087
+1.002923 0.179360 0.299276
+0.988118 0.102835 0.300023
+1.085193 0.084243 0.286641
+1.098530 0.165028 0.278701
+1.096941 0.491263 -0.222004
+1.047839 0.454144 -0.264349
+0.986637 0.533674 -0.274259
+1.038420 0.573741 -0.235162
+0.345377 -0.609810 0.022919
+0.373212 -0.611043 0.096142
+0.439669 -0.553656 0.065038
+0.418793 -0.561034 -0.005764
+0.197046 0.678459 -0.061239
+0.214682 0.666422 0.011519
+0.131791 0.691916 0.050055
+0.108886 0.692463 -0.025146
+0.959843 -0.396427 -0.297619
+1.020302 -0.294707 -0.293721
+1.106118 -0.311297 -0.260537
+1.092619 -0.419161 -0.247120
+1.008918 -0.464677 -0.278913
+1.149537 0.561453 -0.109365
+1.091539 0.650928 -0.129086
+1.087481 0.700464 -0.061449
+1.136442 0.630776 0.011438
+1.174761 0.553075 -0.030822
+1.133565 0.623716 -0.062652
+1.038339 -0.377038 -0.281436
+0.162973 0.680410 -0.005997
+0.392771 -0.583099 0.044769
+1.046037 0.514975 -0.250228
+1.042142 0.131698 0.296308
+0.887198 0.005667 0.278026
+-0.385225 -0.697638 0.220953
+-0.287247 -0.712424 -0.190682
+-0.361292 -0.892823 -0.298239
+-0.480323 -0.532860 0.101348
+1.021875 0.310137 -0.291827
+0.547213 -0.474621 0.119170
+-0.208484 1.085819 -0.281035
+-0.265340 0.807132 0.259915
+-0.432875 0.692462 0.237538
+-0.579202 -0.687890 -0.282278
+0.408028 0.608769 -0.136862
+-0.685228 -0.154704 -0.040935
+-1.038974 -0.782102 0.003329
+-0.345953 -1.058978 0.277886
+-0.622988 -0.336168 0.068561
+-0.333663 1.228897 -0.124423
+-0.946411 -0.259107 0.299701
+-0.288648 1.060153 0.283369
+0.435763 -0.849970 -0.296752
+1.080817 -0.600194 0.185898
+1.187064 0.491222 -0.095295
+1.092250 0.614291 0.162193
+0.321060 -0.689488 -0.180002
+-0.790436 -0.372131 0.272004
+-0.750981 0.453802 -0.274045
+-0.641491 0.433991 0.198160
+-0.538569 0.594090 -0.225269
+-0.738466 -0.806338 0.284981
+0.335689 -0.955376 -0.300047
+0.219879 -0.794505 0.243485
+0.714547 0.251899 -0.176459
+1.284759 0.177475 0.041395
+0.701976 -0.000094 0.025814
+1.293667 0.001496 -0.060971
+1.283623 -0.167662 0.057339
+1.196388 -0.100567 0.222714
+1.188741 0.115287 0.227322
+0.781304 0.003527 0.205291
+1.197613 -0.005335 -0.224563
+0.910174 0.076370 -0.287542
+0.754686 0.394175 -0.260221
+1.080500 0.163865 -0.284556
+1.049075 -0.230342 0.290757
+0.863443 -0.156463 0.273149
+0.886441 0.162727 0.283041
+1.065795 0.255608 0.284282
+0.765245 -0.425605 -0.272580
+0.919351 -0.101886 -0.290301
+1.097663 -0.188737 -0.276717
+1.248133 -0.364149 -0.011244
+1.170256 -0.364441 -0.197203
+1.243852 0.364273 -0.044454
+1.133731 0.378613 -0.226953
+0.950037 0.445355 -0.295828
+0.913630 -0.503915 -0.296384
+1.066848 -0.520520 -0.234196
+1.061512 -0.683630 -0.143390
+0.640481 0.333956 0.111468
+0.770423 0.333989 0.252824
+0.745613 -0.331928 0.237063
+0.616144 -0.353610 0.078030
+0.697696 0.128961 -0.076097
+0.656083 0.245281 -0.019514
+0.782450 0.143255 -0.219342
+0.783315 -0.174863 -0.224851
+0.735358 -0.287864 -0.213594
+0.663794 -0.246043 -0.068058
+0.700057 -0.130073 -0.084843
+1.078931 0.719457 0.042099
+0.872559 0.497771 0.299897
+1.064970 0.471428 0.248964
+1.174830 0.533671 0.073146
+1.165577 -0.517894 0.117455
+1.046029 -0.459347 0.263552
+0.843475 -0.495601 0.299050
+1.087216 -0.700345 0.058688
+0.947530 -0.855401 0.116531
+0.946399 0.851423 0.121924
+0.854614 -0.665396 -0.288293
+0.933853 -0.771911 -0.211684
+0.821348 -0.826783 0.249217
+0.755945 -0.660166 0.299903
+0.870917 0.964023 0.010052
+0.630665 0.511276 -0.234018
+0.656377 -0.532049 -0.256787
+0.711577 -0.672076 -0.299239
+0.847823 -0.914921 -0.168488
+0.858428 -0.976098 -0.011968
+0.778314 0.647835 0.299678
+0.825945 0.814106 0.254337
+0.520044 -0.550086 -0.175867
+0.499485 -0.490291 0.002695
+0.454858 -0.586310 0.153266
+0.564152 -0.681757 0.276917
+0.587484 0.639916 0.269631
+0.659302 1.089643 -0.122970
+0.729996 1.073118 0.036291
+0.280777 -0.661310 0.102565
+0.196742 -0.690763 -0.102394
+0.545238 -0.849572 0.299153
+0.430846 -0.945793 0.297467
+0.678016 -0.933021 0.256883
+0.706615 -1.090987 0.012267
+0.631560 -1.075420 0.170197
+0.474461 -1.102604 0.223018
+0.524459 0.792483 0.295663
+0.677042 0.903799 0.271064
+0.638259 1.051658 0.190681
+0.209779 0.689675 0.109820
+0.290751 0.642813 -0.056385
+0.186576 -1.136193 0.258473
+0.342557 -1.203144 0.163966
+0.317527 0.737031 -0.225710
+0.167898 0.865240 -0.275581
+0.452548 0.850725 -0.297566
+0.484132 1.156008 -0.161150
+0.395626 1.031177 -0.280414
+0.222405 1.037605 -0.292985
+0.106590 -0.851849 0.264438
+0.198043 -0.961127 0.299476
+0.309138 -0.900195 0.296481
+0.341555 -1.253686 -0.018260
+0.213467 -1.260160 -0.111836
+0.296387 -1.130088 -0.247429
+0.192045 -0.986292 -0.299564
+0.288130 -0.801942 -0.261039
+0.446086 -0.702796 -0.248639
+0.595047 -0.807409 -0.299158
+0.680988 -0.956747 -0.244088
+0.592480 -1.104059 -0.159214
+0.433448 -1.183813 -0.148564
+0.039850 -1.294161 -0.053755
+0.349873 1.251193 -0.025144
+0.263298 0.817737 0.264375
+0.415561 0.897538 0.299856
+0.477293 1.073650 0.243567
+0.351666 1.193906 0.172983
+0.176656 1.151739 0.250687
+0.134091 0.972600 0.299294
+-0.087780 -0.904717 -0.286028
+0.020739 -1.006647 -0.299486
+0.166393 1.275452 -0.089359
+0.113207 1.179685 -0.236258
+0.025541 0.705468 0.058925
+-0.103112 -1.258094 -0.143523
+-0.243233 -1.276510 -0.006395
+-0.220601 -1.012859 -0.297423
+-0.096562 -1.128849 -0.269241
+-0.097820 -0.741547 0.162203
+-0.269248 -0.752295 0.222120
+-0.335014 -0.930542 0.299118
+-0.014468 -0.848928 0.259489
+-0.399618 -1.054522 -0.271504
+-0.075808 -0.774613 -0.202316
+-0.166639 -0.709791 -0.127486
+-0.064692 -0.696862 0.003664
+0.022457 -0.717398 -0.100987
+-0.483929 -1.037551 0.262555
+-0.516662 -1.164995 0.118062
+-0.596990 -1.153686 -0.024490
+-0.466923 -1.177271 -0.135536
+-0.392522 -1.238452 0.011467
+-0.062508 0.720967 -0.116611
+0.000283 0.841427 -0.254475
+-0.527635 -0.881717 -0.298495
+-0.715712 -0.946184 -0.233992
+-0.725448 -1.071146 -0.062676
+-0.085621 1.167435 -0.246122
+-0.124362 0.990962 -0.299777
+-0.306633 0.961511 -0.298678
+0.019507 1.228251 0.194642
+0.010721 1.299333 0.020677
+-0.164692 1.274488 -0.090192
+-0.542117 -0.550397 -0.195481
+-0.354184 -0.629887 0.113838
+-0.314622 -0.639677 -0.086426
+-0.418548 -0.705238 -0.239834
+-0.555494 -0.429030 -0.027770
+-0.485255 1.054094 -0.252320
+-0.824014 -0.994260 0.072133
+-0.120315 0.783749 0.216169
+-0.043365 0.945925 0.294151
+-0.140639 1.115889 0.272260
+-0.868483 -0.866283 -0.195326
+-0.949294 -0.887371 -0.012285
+0.934768 0.629323 -0.271342
+0.716838 0.657872 -0.297925
+0.637481 0.815215 -0.298063
+0.741681 0.945776 -0.220741
+0.886355 0.900773 -0.141404
+1.011776 0.749745 -0.150310
+-0.849358 -0.722809 -0.276476
+-0.963078 -0.604729 -0.266292
+-0.820903 -0.503451 -0.296998
+-0.715608 -0.600052 -0.291700
+-0.591372 -0.476112 0.178584
+-0.496234 -0.631264 0.225554
+-0.295122 0.706965 0.187750
+-0.417277 0.810449 0.286567
+-0.758337 -0.941245 0.215972
+-0.606537 -0.905749 0.285800
+-0.592261 -0.747008 0.295486
+-0.319623 0.622724 0.011634
+-0.336120 0.766622 -0.251861
+-0.230614 0.690614 -0.126746
+-1.011110 -0.762588 0.137434
+-0.866564 -0.696891 0.277708
+-0.768817 -0.504952 0.288830
+-0.926781 -0.414174 0.298443
+-0.566321 0.687500 0.279264
+-0.740593 0.769341 0.291323
+-0.869486 0.657424 0.286230
+-0.773690 -0.332442 -0.254055
+-0.654199 -0.281884 -0.082753
+-0.477093 0.522429 -0.063321
+-0.761076 0.932961 0.219033
+-1.023409 0.705858 0.176122
+-0.316669 1.171607 0.208738
+-0.333856 1.255383 0.022199
+-0.498825 1.182537 -0.097484
+-0.662063 1.118218 0.018235
+-0.634137 1.050324 0.194884
+-0.444113 1.021245 0.276952
+-0.989021 0.836556 0.046266
+-0.871789 0.945475 0.088068
+-0.800765 1.019591 -0.041067
+-1.111179 -0.593964 -0.148119
+-1.113799 -0.663495 0.041517
+-1.113335 -0.501697 0.201047
+-0.470258 0.711833 -0.261737
+-0.901328 -0.227061 -0.291633
+-1.150844 -0.434771 -0.191904
+-1.082069 -0.281890 -0.275609
+-1.146876 -0.112645 0.258782
+-0.965621 -0.122543 0.298437
+-0.815534 -0.235538 0.258090
+-0.688630 -0.187247 0.089101
+-1.218876 -0.364691 0.125998
+-1.234556 -0.209229 0.162613
+-1.243078 -0.358125 -0.056401
+-1.291799 -0.135678 0.012645
+-1.179781 -0.165963 -0.231119
+-1.262744 -0.217687 -0.104573
+-0.948766 0.054904 0.296129
+-0.871901 -0.050292 -0.272258
+-1.193823 0.030164 0.228481
+-1.103530 0.121596 0.278886
+-0.695327 0.585352 -0.285173
+-0.969277 0.814429 -0.138299
+-0.823344 0.923277 -0.183927
+-0.660499 0.902212 -0.274850
+-0.614177 0.735157 -0.296825
+-0.700365 -0.021777 -0.009941
+-0.763507 0.038492 -0.185001
+-0.744164 0.304834 -0.225524
+-0.815437 0.181977 -0.250976
+-1.277097 0.090381 0.105103
+-1.298741 0.010112 -0.018292
+-1.170109 0.266349 0.223723
+-1.093022 0.400462 0.251565
+-1.134482 0.568923 0.133131
+-1.257375 0.301626 -0.061501
+-1.263764 0.237232 0.091195
+-1.157995 -0.013609 -0.253936
+-1.249421 0.073709 -0.162266
+-1.224630 0.213093 -0.174756
+-1.102260 0.263601 -0.269010
+-0.978337 0.179315 -0.300004
+-1.009465 0.043444 -0.300077
+-0.702293 0.143041 0.097832
+-0.652204 0.262211 -0.041095
+-0.799087 0.471327 0.290908
+-0.901325 0.345953 0.298035
+-0.827719 0.162785 0.255674
+-0.573771 0.537543 0.210402
+-0.608195 0.352016 0.040296
+-0.539532 0.459420 0.071839
+-1.161672 0.562918 -0.071742
+-1.022200 0.663911 -0.205014
+-0.873140 0.565987 -0.297309
+-0.899071 0.420435 -0.299924
+-1.077667 0.384472 -0.263383
+-1.194517 0.427458 -0.132809
+-0.221954 -1.074123 0.283686
+-0.197812 -1.236929 0.161346
+-0.027199 -1.269649 0.131024
+0.033153 -1.167080 0.248574
+-0.071734 -1.020248 0.299181
+0.553785 0.441919 0.070900
+0.509938 0.535755 0.148952
+0.415637 0.563573 0.011890
+0.504684 0.506203 -0.092321
+-0.100478 -1.165557 0.247145
+-1.059598 0.514116 -0.241154
+-0.716764 0.297246 0.199604
+-1.134249 0.133226 -0.264320
+-1.223679 0.409124 0.075771
+-1.286767 0.157405 -0.040141
+-0.931157 0.296156 -0.299125
+-0.703442 0.148197 -0.105304
+-1.190109 0.324692 -0.187302
+-0.816138 0.749402 -0.280168
+-1.215038 0.153564 0.197816
+-0.876619 0.088736 -0.275358
+-1.006467 0.225050 0.298517
+-1.262985 -0.073425 -0.140711
+-1.271486 -0.262955 0.033891
+-0.783521 -0.029131 0.207660
+-1.071746 -0.007821 0.291655
+-1.199206 -0.295942 -0.186709
+-1.264506 -0.056967 0.136794
+-1.034512 -0.114702 -0.297369
+-1.199315 -0.501852 0.000603
+-0.911068 0.920378 -0.055649
+-0.499617 1.172257 0.120120
+-1.088676 0.709305 -0.014877
+-0.758306 1.032974 0.104410
+-0.614517 0.425404 -0.161404
+-0.739086 -0.145185 -0.170103
+-0.699324 0.587635 0.287443
+-0.987609 0.533904 0.273485
+-0.993118 -0.606965 0.251690
+-1.087055 -0.285907 0.272603
+-0.388057 0.637913 -0.159614
+-0.604151 0.883993 0.291897
+-0.446252 0.589326 0.147701
+-0.671295 -0.638783 0.291060
+0.832245 0.794109 -0.260058
+-1.016082 -0.753739 -0.139099
+-0.894835 0.824646 0.207504
+-0.247091 0.930871 0.297818
+-0.880746 -0.870640 0.179956
+-0.672892 1.055080 -0.163345
+-0.692494 -0.344178 0.196723
+-0.437475 -0.548657 -0.031920
+-0.972922 -0.422594 -0.293486
+-0.156200 1.264978 0.120963
+-0.481776 0.854096 -0.299669
+-0.288375 1.159083 -0.228295
+-0.831926 -0.977799 -0.098569
+-0.685803 -0.773099 -0.298065
+-0.172297 0.816041 -0.249909
+-0.662959 -0.434336 -0.216522
+-0.669757 -1.066680 0.150107
+-0.580343 -1.074976 -0.202341
+-0.164271 -0.881216 0.281444
+-0.280485 -1.197167 -0.193463
+-0.157734 0.686583 0.046142
+0.010477 1.266321 -0.139080
+-0.197007 -0.676013 0.049491
+0.031927 1.093881 0.285191
+-0.241454 -0.811989 -0.258068
+0.305172 1.026459 0.291551
+0.185417 1.269667 0.099601
+-0.109657 -1.295002 0.016156
+-0.354647 -1.170912 0.199913
+0.482117 -0.991245 -0.281734
+0.296864 1.182822 -0.204655
+0.308390 0.901747 -0.296522
+0.164858 -1.271650 0.100107
+0.129654 0.719653 -0.133167
+0.550309 0.952475 0.283317
+0.522361 -1.187875 0.038151
+0.554652 -0.992806 0.267233
+0.066576 -1.001324 0.299941
+0.084642 -0.823150 -0.243917
+0.078487 -0.720663 0.119464
+0.546613 1.173373 0.054810
+0.048774 1.020560 -0.299526
+0.572081 0.994658 -0.261348
+0.086106 -1.178953 -0.236369
+0.389068 0.664193 0.190664
+0.324206 -1.056296 0.281174
+0.387759 -0.759751 0.261106
+0.368951 -0.608104 -0.081707
+0.682709 0.762105 0.299490
+0.750020 -1.029661 -0.123713
+0.585383 -0.652051 -0.272713
+0.507029 0.656832 -0.246647
+0.790019 1.012750 -0.096791
+0.676726 -0.791754 0.297507
+0.780244 -0.808226 -0.272429
+0.072286 0.802450 0.228718
+-0.445675 -0.791086 0.284580
+0.794911 0.966254 0.162237
+0.791395 -0.982968 0.146609
+0.966902 -0.670928 0.241519
+0.979615 0.675052 0.231564
+0.630714 -0.501266 0.228137
+0.664544 0.483615 0.240031
+0.975127 -0.635308 -0.251803
+1.103024 0.571856 -0.176418
+1.168994 -0.543437 -0.080376
+0.907130 -0.302976 -0.296636
+0.931345 0.345940 0.300500
+0.909958 -0.338604 0.298790
+0.889916 0.259396 -0.290507
+0.611543 0.370879 -0.094045
+0.619942 -0.394671 -0.138017
+0.978067 0.854318 -0.032130
+0.983555 -0.839775 -0.064698
+1.050455 -0.009957 -0.296278
+1.019182 -0.004924 0.298903
+1.252915 -0.184549 -0.138450
+0.778990 -0.558492 -0.297438
+0.761885 -0.007291 -0.182637
+0.795919 0.534301 -0.297579
+1.242510 0.182706 -0.157288
+1.196213 -0.316951 0.183497
+0.703267 -0.168386 0.112542
+0.710297 0.170562 0.129136
+1.207701 0.332450 0.162218
+1.279836 0.005212 0.106332
diff --git a/src/Bottleneck/test/CMakeLists.txt b/src/Bottleneck/test/CMakeLists.txt
index 3dfd80cd..ad63c080 100644
--- a/src/Bottleneck/test/CMakeLists.txt
+++ b/src/Bottleneck/test/CMakeLists.txt
@@ -4,14 +4,10 @@ project(GUDHIBottleneckUT)
if (GCOVR_PATH)
# for gcovr to make coverage reports - Corbera Jenkins plugin
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
- set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage")
- set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fprofile-arcs -ftest-coverage")
endif()
if (GPROF_PATH)
# for gprof to make coverage reports - Jenkins
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg")
- set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -pg")
- set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -pg")
endif()
add_executable ( BottleneckUT bottleneck_unit_test.cpp )
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 2ef89f84..8c64b6a2 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -9,29 +9,51 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules/")
find_package(Boost REQUIRED COMPONENTS system filesystem program_options chrono timer REQUIRED)
-if (NOT CMAKE_BUILD_TYPE)
- set(CMAKE_BUILD_TYPE "Release")
-endif()
-if(MSVC)
- SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4267 /wd4668 /wd4311 /wd4800 /wd4820 /wd4503 /wd4244 /wd4345 /wd4996 /wd4396 /wd4018")
-else()
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
-endif()
-
-set(Boost_USE_STATIC_LIBS ON)
-set(Boost_USE_MULTITHREADED ON)
-set(Boost_USE_STATIC_RUNTIME OFF)
-
-find_package(GMP)
-if(GMP_FOUND)
- find_package(GMPXX)
-endif()
-
-find_package(CGAL)
-
if(NOT Boost_FOUND)
message(FATAL_ERROR "NOTICE: This demo requires Boost and will not be compiled.")
else()
+
+ find_package(GMP)
+ if(GMP_FOUND)
+ INCLUDE_DIRECTORIES(${GMP_INCLUDE_DIR})
+ find_package(GMPXX)
+ if(GMPXX_FOUND)
+ INCLUDE_DIRECTORIES(${GMPXX_INCLUDE_DIR})
+ endif()
+ endif()
+
+ # In CMakeLists.txt, when include(${CGAL_USE_FILE}), CMAKE_CXX_FLAGS are overwritten.
+ # cf. http://doc.cgal.org/latest/Manual/installation.html#title40
+ # A workaround is to include(${CGAL_USE_FILE}) before adding "-std=c++11".
+ # A fix would be to use https://cmake.org/cmake/help/v3.1/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.html
+ # or even better https://cmake.org/cmake/help/v3.1/variable/CMAKE_CXX_STANDARD.html
+ # but it implies to use cmake version 3.1 at least.
+ find_package(CGAL)
+ if(CGAL_FOUND)
+ include( ${CGAL_USE_FILE} )
+ endif()
+
+ if(MSVC)
+ # Turn off some VC++ warnings
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4267 /wd4668 /wd4311 /wd4800 /wd4820 /wd4503 /wd4244 /wd4345 /wd4996 /wd4396 /wd4018")
+ else()
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wpedantic -Wsign-compare")
+ endif()
+
+ if(CMAKE_BUILD_TYPE MATCHES Debug)
+ message("++ Debug compilation flags are: ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG}")
+ else()
+ message("++ Release compilation flags are: ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE}")
+ endif()
+
+ set(Boost_USE_STATIC_LIBS ON)
+ set(Boost_USE_MULTITHREADED ON)
+ set(Boost_USE_STATIC_RUNTIME OFF)
+
+ # Find TBB package for parallel sort - not mandatory, just optional.
+ set(TBB_FIND_QUIETLY ON)
+ find_package(TBB)
+
# BOOST ISSUE result_of vs C++11
add_definitions(-DBOOST_RESULT_OF_USE_DECLTYPE)
# BOOST ISSUE with Libraries name resolution under Windows
diff --git a/src/Contraction/example/Garland_heckbert.cpp b/src/Contraction/example/Garland_heckbert.cpp
index 70f29b6a..b545a066 100644
--- a/src/Contraction/example/Garland_heckbert.cpp
+++ b/src/Contraction/example/Garland_heckbert.cpp
@@ -145,12 +145,13 @@ class GH_visitor : public Gudhi::contraction::Contraction_visitor<EdgeProfile> {
int main(int argc, char *argv[]) {
if (argc != 4) {
- std::cerr << "Usage " << argv[0] << " input.off output.off N to load the file input.off, contract N edges and save "
- << "the result to output.off.\n";
+ std::cerr << "Usage " << argv[0] <<
+ " input.off output.off N to load the file input.off, contract N edges and save the result to output.off.\n";
return EXIT_FAILURE;
}
Complex complex;
+ typedef Complex::Vertex_handle Vertex_handle;
// load the points
Skeleton_blocker_off_reader<Complex> off_reader(argv[1], complex);
@@ -159,8 +160,12 @@ int main(int argc, char *argv[]) {
return EXIT_FAILURE;
}
- std::cout << "Load complex with " << complex.num_vertices() << " vertices" << std::endl;
+ if (!complex.empty() && !(complex.point(Vertex_handle(0)).dimension() == 3)) {
+ std::cerr << "Only points of dimension 3 are supported." << std::endl;
+ return EXIT_FAILURE;
+ }
+ std::cout << "Load complex with " << complex.num_vertices() << " vertices" << std::endl;
int num_contractions = atoi(argv[3]);
@@ -178,7 +183,7 @@ int main(int argc, char *argv[]) {
std::cout << "Final complex has " <<
complex.num_vertices() << " vertices, " <<
- complex.num_edges() << " edges and" <<
+ complex.num_edges() << " edges and " <<
complex.num_triangles() << " triangles." << std::endl;
// write simplified complex
@@ -187,6 +192,8 @@ int main(int argc, char *argv[]) {
return EXIT_SUCCESS;
}
+#endif // GARLAND_HECKBERT_H_
+
+
-#endif // GARLAND_HECKBERT_H_
diff --git a/src/Contraction/example/Rips_contraction.cpp b/src/Contraction/example/Rips_contraction.cpp
index d21246ed..f80cc2dc 100644
--- a/src/Contraction/example/Rips_contraction.cpp
+++ b/src/Contraction/example/Rips_contraction.cpp
@@ -49,7 +49,7 @@ void build_rips(ComplexType& complex, double offset) {
for (auto p = vertices.begin(); p != vertices.end(); ++p)
for (auto q = p; ++q != vertices.end(); /**/) {
if (squared_dist(complex.point(*p), complex.point(*q)) < 4 * offset * offset)
- complex.add_edge(*p, *q);
+ complex.add_edge_without_blockers(*p, *q);
}
}
@@ -87,7 +87,7 @@ int main(int argc, char *argv[]) {
contractor.contract_edges();
std::cout << "Counting final number of simplices \n";
- unsigned num_simplices = std::distance(complex.simplex_range().begin(), complex.simplex_range().end());
+ unsigned num_simplices = std::distance(complex.complex_simplex_range().begin(), complex.complex_simplex_range().end());
std::cout << "Final complex has " <<
complex.num_vertices() << " vertices, " <<
diff --git a/src/Contraction/include/gudhi/Edge_contraction.h b/src/Contraction/include/gudhi/Edge_contraction.h
index 349bb7d8..ee3e3de1 100644
--- a/src/Contraction/include/gudhi/Edge_contraction.h
+++ b/src/Contraction/include/gudhi/Edge_contraction.h
@@ -158,7 +158,7 @@ void build_rips(ComplexType& complex, double offset){
for (auto p = vertices.begin(); p != vertices.end(); ++p)
for (auto q = p; ++q != vertices.end(); )
if (eucl_distance(complex.point(*p), complex.point(*q)) < 2 * offset)
- complex.add_edge(*p,*q);
+ complex.add_edge_without_blockers(*p,*q);
}
int main (int argc, char *argv[])
@@ -194,7 +194,7 @@ int main (int argc, char *argv[])
contractor.contract_edges();
std::cout << "Counting final number of simplices \n";
- unsigned num_simplices = std::distance(complex.simplex_range().begin(),complex.simplex_range().end());
+ unsigned num_simplices = std::distance(complex.star_simplex_range().begin(),complex.star_simplex_range().end());
std::cout << "Final complex has "<<
complex.num_vertices()<<" vertices, "<<
diff --git a/src/Contraction/include/gudhi/Skeleton_blocker_contractor.h b/src/Contraction/include/gudhi/Skeleton_blocker_contractor.h
index 2759b540..d6350a2c 100644
--- a/src/Contraction/include/gudhi/Skeleton_blocker_contractor.h
+++ b/src/Contraction/include/gudhi/Skeleton_blocker_contractor.h
@@ -107,13 +107,8 @@ typename GeometricSimplifiableComplex::Vertex_handle> {
public:
typedef typename GeometricSimplifiableComplex::Graph_vertex Graph_vertex;
typedef typename GeometricSimplifiableComplex::Vertex_handle Vertex_handle;
- typedef typename GeometricSimplifiableComplex::Simplex_handle Simplex_handle;
- typedef typename GeometricSimplifiableComplex::Simplex_handle_iterator Simplex_handle_iterator;
-
-
-
+ typedef typename GeometricSimplifiableComplex::Simplex Simplex;
typedef typename GeometricSimplifiableComplex::Root_vertex_handle Root_vertex_handle;
-
typedef typename GeometricSimplifiableComplex::Graph_edge Graph_edge;
typedef typename GeometricSimplifiableComplex::Edge_handle Edge_handle;
typedef typename GeometricSimplifiableComplex::Point Point;
@@ -535,14 +530,14 @@ typename GeometricSimplifiableComplex::Vertex_handle> {
* All the edges that passes through the blocker may be edge-contractible
* again and are thus reinserted in the heap.
*/
- void on_delete_blocker(const Simplex_handle * blocker) override {
+ void on_delete_blocker(const Simplex * blocker) override {
// we go for all pairs xy that belongs to the blocker
// note that such pairs xy are necessarily edges of the complex
// by definition of a blocker
// todo uniqument utile pour la link condition
// laisser a l'utilisateur ? booleen update_heap_on_removed_blocker?
- Simplex_handle blocker_copy(*blocker);
+ Simplex blocker_copy(*blocker);
for (auto x = blocker_copy.begin(); x != blocker_copy.end(); ++x) {
for (auto y = x; ++y != blocker_copy.end();) {
auto edge_descr(complex_[std::make_pair(*x, *y)]);
diff --git a/src/GudhUI/CMakeLists.txt b/src/GudhUI/CMakeLists.txt
index 71f4fd1a..1ee43d91 100644
--- a/src/GudhUI/CMakeLists.txt
+++ b/src/GudhUI/CMakeLists.txt
@@ -1,7 +1,6 @@
cmake_minimum_required(VERSION 2.8)
project(GudhUI)
-find_package(CGAL COMPONENTS Qt4)
find_package(Qt4)
find_package(QGLViewer)
find_package(OpenGL)
@@ -14,27 +13,8 @@ if ( CGAL_FOUND AND QT4_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND )
SET(Boost_USE_STATIC_LIBS ON)
SET(Boost_USE_MULTITHREAD OFF)
- INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
- LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
-
include(${QT_USE_FILE})
- include(${CGAL_USE_FILE})
- # In CMakeLists.txt, when include(${CGAL_USE_FILE}), CXX_FLAGS are overwritten.
- # cf. http://doc.cgal.org/latest/Manual/installation.html#title40
- # A workaround is to add "-std=c++11" again.
- # A fix would be to use https://cmake.org/cmake/help/v3.1/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.html
- # or even better https://cmake.org/cmake/help/v3.1/variable/CMAKE_CXX_STANDARD.html
- # but it implies to use cmake version 3.1 at least.
- if(NOT MSVC)
- include(CheckCXXCompilerFlag)
- CHECK_CXX_COMPILER_FLAG(-std=c++11 COMPILER_SUPPORTS_CXX11)
- if(COMPILER_SUPPORTS_CXX11)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
- endif()
- endif()
- # - End of workaround
-
include_directories (${QGLVIEWER_INCLUDE_DIR})
include_directories(.)
diff --git a/src/GudhUI/model/Model.h b/src/GudhUI/model/Model.h
index d78cbad9..07a67a0c 100644
--- a/src/GudhUI/model/Model.h
+++ b/src/GudhUI/model/Model.h
@@ -249,7 +249,7 @@ class Model {
int euler = 0;
int dimension = 0;
Clock clock;
- for (const auto &s : complex_.simplex_range()) {
+ for (const auto &s : complex_.complex_simplex_range()) {
num_simplices++;
dimension = (std::max)(s.dimension(), dimension);
if (s.dimension() % 2 == 0)
@@ -281,7 +281,7 @@ class Model {
unsigned num_simplices = 0;
int euler = 0;
int dimension = 0;
- for (const auto &s : complex_.simplex_range()) {
+ for (const auto &s : complex_.complex_simplex_range()) {
num_simplices++;
dimension = (std::max)(s.dimension(), dimension);
if (s.dimension() % 2 == 0)
@@ -328,7 +328,7 @@ class Model {
void save_complex_in_file_for_chomp() {
std::ofstream file;
file.open("chomp.sim");
- for (const auto &s : complex_.simplex_range()) {
+ for (const auto &s : complex_.complex_simplex_range()) {
bool first = true;
file << "(";
for (auto x : s) {
diff --git a/src/GudhUI/utils/Is_manifold.h b/src/GudhUI/utils/Is_manifold.h
index b6b19ee0..0640ea47 100644
--- a/src/GudhUI/utils/Is_manifold.h
+++ b/src/GudhUI/utils/Is_manifold.h
@@ -69,7 +69,7 @@ template<typename SkBlComplex> class Is_manifold {
private:
unsigned local_dimension(Vertex_handle v) {
unsigned dim = 0;
- for (const auto& s : input_complex_.simplex_range(v))
+ for (const auto& s : input_complex_.star_simplex_range(v))
dim = (std::max)(dim, (unsigned) s.dimension());
return dim;
}
diff --git a/src/GudhUI/utils/K_nearest_builder.h b/src/GudhUI/utils/K_nearest_builder.h
index cab24b7c..7be0a4f4 100644
--- a/src/GudhUI/utils/K_nearest_builder.h
+++ b/src/GudhUI/utils/K_nearest_builder.h
@@ -29,12 +29,10 @@
#include <CGAL/Search_traits_d.h>
#include <CGAL/Search_traits_adapter.h>
#include <CGAL/property_map.h>
-#include <boost/iterator/iterator_facade.hpp>
-#include <boost/iterator/zip_iterator.hpp>
#include <unordered_map>
-#include <tuple>
#include <list>
+#include <utility>
#include "utils/UI_utils.h"
#include "model/Complex_typedefs.h"
@@ -43,9 +41,9 @@ template<typename SkBlComplex> class K_nearest_builder {
private:
typedef Geometry_trait Kernel;
typedef Point Point_d;
- typedef boost::tuple<Point_d, unsigned> Point_d_with_id;
+ typedef std::pair<Point_d, unsigned> Point_d_with_id;
typedef CGAL::Search_traits_d<Kernel> Traits_base;
- typedef CGAL::Search_traits_adapter<Point_d_with_id, CGAL::Nth_of_tuple_property_map<0, Point_d_with_id>,
+ typedef CGAL::Search_traits_adapter<Point_d_with_id, CGAL::First_of_pair_property_map<Point_d_with_id>,
Traits_base> Traits;
typedef CGAL::Orthogonal_k_neighbor_search<Traits> Neighbor_search;
typedef Neighbor_search::Tree Tree;
@@ -81,7 +79,7 @@ template<typename SkBlComplex> class K_nearest_builder {
for (auto p : complex_.vertex_range()) {
Neighbor_search search(tree, complex_.point(p), k + 1);
for (auto it = ++search.begin(); it != search.end(); ++it) {
- Vertex_handle q(boost::get<1>(it->first));
+ Vertex_handle q(std::get<1>(it->first));
if (p != q && complex_.contains_vertex(p) && complex_.contains_vertex(q))
complex_.add_edge(p, q);
}
diff --git a/src/GudhUI/view/Viewer_instructor.cpp b/src/GudhUI/view/Viewer_instructor.cpp
index 4446d209..1ddd4d8b 100644
--- a/src/GudhUI/view/Viewer_instructor.cpp
+++ b/src/GudhUI/view/Viewer_instructor.cpp
@@ -159,7 +159,7 @@ void Viewer_instructor::set_color_edge(Edge_handle eh) {
viewer_->set_color(Color(view_params_.light_edges, view_params_.light_edges, view_params_.light_edges));
}
-void Viewer_instructor::set_color_triangle(const Simplex_handle& triangle) {
+void Viewer_instructor::set_color_triangle(const Simplex& triangle) {
viewer_->set_color(Color(view_params_.light_triangles, view_params_.light_triangles, view_params_.light_triangles));
}
diff --git a/src/GudhUI/view/Viewer_instructor.h b/src/GudhUI/view/Viewer_instructor.h
index 31a1d273..82c8e346 100644
--- a/src/GudhUI/view/Viewer_instructor.h
+++ b/src/GudhUI/view/Viewer_instructor.h
@@ -52,7 +52,7 @@ class Viewer_instructor : public QWidget {
typedef Complex::Point Point;
typedef Complex::Vertex_handle Vertex_handle;
typedef Complex::Edge_handle Edge_handle;
- typedef Complex::Simplex_handle Simplex_handle;
+ typedef Complex::Simplex Simplex;
Viewer* viewer_;
View_parameter view_params_;
@@ -98,7 +98,7 @@ class Viewer_instructor : public QWidget {
void set_color_vertex(Vertex_handle vh);
void set_color_edge(Edge_handle eh);
- void set_color_triangle(const Simplex_handle& triangle);
+ void set_color_triangle(const Simplex& triangle);
private:
/**
diff --git a/src/Hasse_complex/include/gudhi/Hasse_complex.h b/src/Hasse_complex/include/gudhi/Hasse_complex.h
index 67079687..8b06b771 100644
--- a/src/Hasse_complex/include/gudhi/Hasse_complex.h
+++ b/src/Hasse_complex/include/gudhi/Hasse_complex.h
@@ -23,12 +23,18 @@
#ifndef HASSE_COMPLEX_H_
#define HASSE_COMPLEX_H_
+#include <gudhi/allocator.h>
+
#include <boost/iterator/counting_iterator.hpp>
#include <algorithm>
#include <utility> // for pair
#include <vector>
+#ifdef GUDHI_USE_TBB
+#include <tbb/parallel_for.h>
+#endif
+
namespace Gudhi {
template < class HasseCpx >
@@ -38,8 +44,7 @@ struct Hasse_simplex {
template< class Complex_ds >
Hasse_simplex(Complex_ds & cpx
, typename Complex_ds::Simplex_handle sh)
- : key_(cpx.key(sh))
- , filtration_(cpx.filtration(sh))
+ : filtration_(cpx.filtration(sh))
, boundary_() {
boundary_.reserve(cpx.dimension(sh) + 1);
for (auto b_sh : cpx.boundary_simplex_range(sh)) {
@@ -49,7 +54,7 @@ struct Hasse_simplex {
Hasse_simplex(typename HasseCpx::Simplex_key key
, typename HasseCpx::Filtration_value fil
- , std::vector<typename HasseCpx::Simplex_handle> boundary)
+ , std::vector<typename HasseCpx::Simplex_handle> const& boundary)
: key_(key)
, filtration_(fil)
, boundary_(boundary) { }
@@ -97,20 +102,24 @@ class Hasse_complex {
template < class Complex_ds >
Hasse_complex(Complex_ds & cpx)
- : complex_()
+ : complex_(cpx.num_simplices())
, vertices_()
, threshold_(cpx.filtration())
, num_vertices_()
, dim_max_(cpx.dimension()) {
- complex_.reserve(cpx.num_simplices());
- int idx = 0;
- for (auto cpx_sh : cpx.filtration_simplex_range()) {
- complex_.push_back(Hasse_simp(cpx, cpx_sh));
- if (dimension(idx) == 0) {
+ int size = complex_.size();
+#ifdef GUDHI_USE_TBB
+ tbb::parallel_for(0, size, [&](int idx){new (&complex_[idx]) Hasse_simp(cpx, cpx.simplex(idx));});
+ for (int idx=0; idx < size; ++idx)
+ if (complex_[idx].boundary_.empty())
+ vertices_.push_back(idx);
+#else
+ for (int idx=0; idx < size; ++idx) {
+ new (&complex_[idx]) Hasse_simp(cpx, cpx.simplex(idx));
+ if (complex_[idx].boundary_.empty())
vertices_.push_back(idx);
- }
- ++idx;
}
+#endif
}
Hasse_complex()
@@ -187,14 +196,15 @@ class Hasse_complex {
}
void initialize_filtration() {
+ // Setting the keys is done by pcoh, Simplex_tree doesn't do it either.
+#if 0
Simplex_key key = 0;
- for (auto & h_simp : complex_) {
- h_simp.key_ = key;
- ++key;
- }
+ for (auto & h_simp : complex_)
+ h_simp.key_ = key++;
+#endif
}
- std::vector< Hasse_simp > complex_;
+ std::vector< Hasse_simp, Gudhi::no_init_allocator<Hasse_simp> > complex_;
std::vector<Simplex_handle> vertices_;
Filtration_value threshold_;
size_t num_vertices_;
@@ -218,7 +228,7 @@ std::istream& operator>>(std::istream & is
// read all simplices in the file as a list of vertices
while (read_hasse_simplex(is, boundary, fil)) {
// insert every simplex in the simplex tree
- hcpx.complex_.push_back(Hasse_simplex< Hasse_complex<T1, T2, T3> >(key, fil, boundary));
+ hcpx.complex_.emplace_back(key, fil, boundary);
if (max_dim < hcpx.dimension(key)) {
max_dim = hcpx.dimension(key);
diff --git a/src/Persistent_cohomology/concept/FilteredComplex.h b/src/Persistent_cohomology/concept/FilteredComplex.h
index 1834903b..e124d524 100644
--- a/src/Persistent_cohomology/concept/FilteredComplex.h
+++ b/src/Persistent_cohomology/concept/FilteredComplex.h
@@ -65,9 +65,9 @@ struct FilteredComplex
Simplex_key key ( Simplex_handle sh );
/** \brief Returns the simplex associated to a key.
*
- * If key is different from null_key(), there must be a unique
- * simplex having this key. */
- Simplex_handle simplex ( Simplex_key key );
+ * If key is different from null_key(), returns the simplex that
+ * has index idx in the filtration. */
+ Simplex_handle simplex ( Simplex_key idx );
/** \brief Assign a key to a simplex. */
void assign_key(Simplex_handle sh, Simplex_key key);
diff --git a/src/Persistent_cohomology/example/CMakeLists.txt b/src/Persistent_cohomology/example/CMakeLists.txt
index 50d10025..95506631 100644
--- a/src/Persistent_cohomology/example/CMakeLists.txt
+++ b/src/Persistent_cohomology/example/CMakeLists.txt
@@ -16,7 +16,12 @@ add_test(persistence_from_simple_simplex_tree ${CMAKE_CURRENT_BINARY_DIR}/persis
add_executable(rips_persistence rips_persistence.cpp)
target_link_libraries(rips_persistence ${Boost_SYSTEM_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY})
-add_test(rips_persistence_3 ${CMAKE_CURRENT_BINARY_DIR}/rips_persistence ${CMAKE_SOURCE_DIR}/data/points/Kl.txt -r 0.25 -d 3 -p 3 -m 100)
+add_test(rips_persistence_3 ${CMAKE_CURRENT_BINARY_DIR}/rips_persistence ${CMAKE_SOURCE_DIR}/data/points/Kl.txt -r 0.2 -d 3 -p 3 -m 100)
+
+add_executable(parallel_rips_persistence parallel_rips_persistence.cpp)
+target_link_libraries(parallel_rips_persistence ${Boost_SYSTEM_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY})
+
+add_test(parallel_rips_persistence_3 ${CMAKE_CURRENT_BINARY_DIR}/parallel_rips_persistence ${CMAKE_SOURCE_DIR}/data/points/tore3D_1307.txt -r 0.3 -d 3 -p 3 -m 100)
add_executable(persistence_from_file persistence_from_file.cpp)
target_link_libraries(persistence_from_file ${Boost_SYSTEM_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY})
@@ -29,7 +34,7 @@ if(GMPXX_FOUND AND GMP_FOUND)
add_executable(rips_multifield_persistence rips_multifield_persistence.cpp )
target_link_libraries(rips_multifield_persistence ${Boost_SYSTEM_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY} ${GMPXX_LIBRARIES} ${GMP_LIBRARIES})
- add_test(rips_multifield_persistence_2_71 ${CMAKE_CURRENT_BINARY_DIR}/rips_multifield_persistence ${CMAKE_SOURCE_DIR}/data/points/Kl.txt -r 0.25 -d 3 -p 2 -q 71 -m 100)
+ add_test(rips_multifield_persistence_2_71 ${CMAKE_CURRENT_BINARY_DIR}/rips_multifield_persistence ${CMAKE_SOURCE_DIR}/data/points/Kl.txt -r 0.2 -d 3 -p 2 -q 71 -m 100)
add_executable ( performance_rips_persistence performance_rips_persistence.cpp )
target_link_libraries(performance_rips_persistence ${Boost_SYSTEM_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY} ${GMPXX_LIBRARIES} ${GMP_LIBRARIES})
diff --git a/src/Persistent_cohomology/example/alpha_shapes_persistence.cpp b/src/Persistent_cohomology/example/alpha_shapes_persistence.cpp
index 6d5eebcf..92c0b065 100644
--- a/src/Persistent_cohomology/example/alpha_shapes_persistence.cpp
+++ b/src/Persistent_cohomology/example/alpha_shapes_persistence.cpp
@@ -66,7 +66,8 @@ typedef Alpha_shape_3::Edge Edge_3;
typedef std::list<Alpha_shape_3::Vertex_handle> Vertex_list;
// gudhi type definition
-typedef Simplex_tree<>::Vertex_handle Simplex_tree_vertex;
+typedef Simplex_tree<Simplex_tree_options_fast_persistence> ST;
+typedef ST::Vertex_handle Simplex_tree_vertex;
typedef std::map<Alpha_shape_3::Vertex_handle, Simplex_tree_vertex > Alpha_shape_simplex_tree_map;
typedef std::pair<Alpha_shape_3::Vertex_handle, Simplex_tree_vertex> Alpha_shape_simplex_tree_pair;
typedef std::vector< Simplex_tree_vertex > Simplex_tree_vector_vertex;
@@ -184,7 +185,7 @@ int main(int argc, char * const argv[]) {
// Loop on objects vector
Vertex_list vertex_list;
- Simplex_tree<> simplex_tree;
+ ST simplex_tree;
Alpha_shape_simplex_tree_map map_cgal_simplex_tree;
std::vector<Alpha_value_type>::iterator the_alpha_value_iterator = the_alpha_values.begin();
int dim_max = 0;
@@ -281,7 +282,7 @@ int main(int argc, char * const argv[]) {
std::cout << "Simplex_tree dim: " << simplex_tree.dimension() << std::endl;
// Compute the persistence diagram of the complex
- Persistent_cohomology< Simplex_tree<>, Field_Zp > pcoh(simplex_tree);
+ Persistent_cohomology< ST, Field_Zp > pcoh(simplex_tree);
// initializes the coefficient field for homology
pcoh.init_coefficients(coeff_field_characteristic);
diff --git a/src/Persistent_cohomology/example/parallel_rips_persistence.cpp b/src/Persistent_cohomology/example/parallel_rips_persistence.cpp
new file mode 100644
index 00000000..4c6656f5
--- /dev/null
+++ b/src/Persistent_cohomology/example/parallel_rips_persistence.cpp
@@ -0,0 +1,180 @@
+/* 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): Clément Maria, Marc Glisse
+ *
+ * Copyright (C) 2014 INRIA Sophia Antipolis-Méditerranée (France),
+ * 2015 INRIA Saclay ÃŽle de France)
+ *
+ * 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/>.
+ */
+
+#include <gudhi/reader_utils.h>
+#include <gudhi/graph_simplicial_complex.h>
+#include <gudhi/distance_functions.h>
+#include <gudhi/Simplex_tree.h>
+#include <gudhi/Persistent_cohomology.h>
+#include <gudhi/Hasse_complex.h>
+
+#include <boost/program_options.hpp>
+
+#ifdef GUDHI_USE_TBB
+#include <tbb/task_scheduler_init.h>
+#endif
+
+#include <string>
+#include <vector>
+
+////////////////////////////////////////////////////////////////
+// //
+// WARNING: persistence computation itself is not parallel, //
+// and this uses more memory than rips_persistence. //
+// //
+////////////////////////////////////////////////////////////////
+
+using namespace Gudhi;
+using namespace Gudhi::persistent_cohomology;
+
+typedef int Vertex_handle;
+typedef double Filtration_value;
+
+void program_options(int argc, char * argv[]
+ , std::string & filepoints
+ , std::string & filediag
+ , Filtration_value & threshold
+ , int & dim_max
+ , int & p
+ , Filtration_value & min_persistence);
+
+int main(int argc, char * argv[]) {
+ std::string filepoints;
+ std::string filediag;
+ Filtration_value threshold;
+ int dim_max;
+ int p;
+ Filtration_value min_persistence;
+
+ program_options(argc, argv, filepoints, filediag, threshold, dim_max, p, min_persistence);
+
+ // Extract the points from the file filepoints
+ typedef std::vector<double> Point_t;
+ std::vector< Point_t > points;
+ read_points(filepoints, points);
+
+ // Compute the proximity graph of the points
+ Graph_t prox_graph = compute_proximity_graph(points, threshold
+ , euclidean_distance<Point_t>);
+
+ // Construct the Rips complex in a Simplex Tree
+ Simplex_tree<>& st = *new Simplex_tree<>;
+ // insert the proximity graph in the simplex tree
+ st.insert_graph(prox_graph);
+ // expand the graph until dimension dim_max
+ st.expansion(dim_max);
+
+ std::cout << "The complex contains " << st.num_simplices() << " simplices \n";
+ std::cout << " and has dimension " << st.dimension() << " \n";
+
+#ifdef GUDHI_USE_TBB
+ // Unnecessary, but clarifies which operations are parallel.
+ tbb::task_scheduler_init ts;
+#endif
+
+ // Sort the simplices in the order of the filtration
+ st.initialize_filtration();
+ int count = 0;
+ for (auto sh : st.filtration_simplex_range())
+ st.assign_key(sh, count++);
+
+ // Convert to a more convenient representation.
+ Hasse_complex<> hcpx(st);
+
+#ifdef GUDHI_USE_TBB
+ ts.terminate();
+#endif
+
+ // Free some space.
+ delete &st;
+
+ // Compute the persistence diagram of the complex
+ persistent_cohomology::Persistent_cohomology< Hasse_complex<>, Field_Zp > pcoh(hcpx);
+ // initializes the coefficient field for homology
+ pcoh.init_coefficients(p);
+
+ pcoh.compute_persistent_cohomology(min_persistence);
+
+ // Output the diagram in filediag
+ if (filediag.empty()) {
+ pcoh.output_diagram();
+ } else {
+ std::ofstream out(filediag);
+ pcoh.output_diagram(out);
+ out.close();
+ }
+}
+
+void program_options(int argc, char * argv[]
+ , std::string & filepoints
+ , std::string & filediag
+ , Filtration_value & threshold
+ , int & dim_max
+ , int & p
+ , Filtration_value & min_persistence) {
+ namespace po = boost::program_options;
+ po::options_description hidden("Hidden options");
+ hidden.add_options()
+ ("input-file", po::value<std::string>(&filepoints),
+ "Name of file containing a point set. Format is one point per line: X1 ... Xd ");
+
+ po::options_description visible("Allowed options", 100);
+ visible.add_options()
+ ("help,h", "produce help message")
+ ("output-file,o", po::value<std::string>(&filediag)->default_value(std::string()),
+ "Name of file in which the persistence diagram is written. Default print in std::cout")
+ ("max-edge-length,r", po::value<Filtration_value>(&threshold)->default_value(0),
+ "Maximal length of an edge for the Rips complex construction.")
+ ("cpx-dimension,d", po::value<int>(&dim_max)->default_value(1),
+ "Maximal dimension of the Rips complex we want to compute.")
+ ("field-charac,p", po::value<int>(&p)->default_value(11),
+ "Characteristic p of the coefficient field Z/pZ for computing homology.")
+ ("min-persistence,m", po::value<Filtration_value>(&min_persistence),
+ "Minimal lifetime of homology feature to be recorded. Default is 0. Enter a negative value to see zero length intervals");
+
+ po::positional_options_description pos;
+ pos.add("input-file", 1);
+
+ po::options_description all;
+ all.add(visible).add(hidden);
+
+ po::variables_map vm;
+ po::store(po::command_line_parser(argc, argv).
+ options(all).positional(pos).run(), vm);
+ po::notify(vm);
+
+ if (vm.count("help") || !vm.count("input-file")) {
+ std::cout << std::endl;
+ std::cout << "Compute the persistent homology with coefficient field Z/pZ \n";
+ std::cout << "of a Rips complex defined on a set of input points.\n \n";
+ std::cout << "The output diagram contains one bar per line, written with the convention: \n";
+ std::cout << " p dim b d \n";
+ std::cout << "where dim is the dimension of the homological feature,\n";
+ std::cout << "b and d are respectively the birth and death of the feature and \n";
+ std::cout << "p is the characteristic of the field Z/pZ used for homology coefficients." << std::endl << std::endl;
+
+ std::cout << "Usage: " << argv[0] << " [options] input-file" << std::endl << std::endl;
+ std::cout << visible << std::endl;
+ std::abort();
+ }
+}
diff --git a/src/Persistent_cohomology/example/performance_rips_persistence.cpp b/src/Persistent_cohomology/example/performance_rips_persistence.cpp
index fc48d6b1..b4d282ac 100644
--- a/src/Persistent_cohomology/example/performance_rips_persistence.cpp
+++ b/src/Persistent_cohomology/example/performance_rips_persistence.cpp
@@ -86,7 +86,7 @@ int main(int argc, char * argv[]) {
std::cout << "Compute Rips graph in " << elapsed_sec << " ms.\n";
// Construct the Rips complex in a Simplex Tree
- Simplex_tree<> st;
+ Simplex_tree<Simplex_tree_options_fast_persistence> st;
start = std::chrono::system_clock::now();
// insert the proximity graph in the simplex tree
diff --git a/src/Persistent_cohomology/example/persistence_from_file.cpp b/src/Persistent_cohomology/example/persistence_from_file.cpp
index 8eb8d0f3..67235467 100644
--- a/src/Persistent_cohomology/example/persistence_from_file.cpp
+++ b/src/Persistent_cohomology/example/persistence_from_file.cpp
@@ -54,7 +54,7 @@ int main(int argc, char * argv[]) {
<< std::endl;
std::cout << " - p=" << p << " - min_persistence=" << min_persistence << std::endl;
- // Construct the Rips complex in a Simplex Tree
+ // Read the list of simplices from a file.
Simplex_tree<> simplex_tree;
std::ifstream simplex_tree_stream(simplex_tree_file);
diff --git a/src/Persistent_cohomology/example/plain_homology.cpp b/src/Persistent_cohomology/example/plain_homology.cpp
index e293e013..0a692717 100644
--- a/src/Persistent_cohomology/example/plain_homology.cpp
+++ b/src/Persistent_cohomology/example/plain_homology.cpp
@@ -27,6 +27,10 @@
using namespace Gudhi;
+/* We could perfectly well use the default Simplex_tree<> (which uses
+ * Simplex_tree_options_full_featured), the following simply demonstrates
+ * how to save on storage by not storing a filtration value. */
+
struct MyOptions : Simplex_tree_options_full_featured {
// Implicitly use 0 as filtration value for all simplices
static const bool store_filtration = false;
diff --git a/src/Persistent_cohomology/example/rips_multifield_persistence.cpp b/src/Persistent_cohomology/example/rips_multifield_persistence.cpp
index 5277bf7a..c5cd775d 100644
--- a/src/Persistent_cohomology/example/rips_multifield_persistence.cpp
+++ b/src/Persistent_cohomology/example/rips_multifield_persistence.cpp
@@ -68,7 +68,8 @@ int main(int argc, char * argv[]) {
, euclidean_distance<Point_t>);
// Construct the Rips complex in a Simplex Tree
- Simplex_tree<> st;
+ typedef Simplex_tree<Simplex_tree_options_fast_persistence> ST;
+ ST st;
// insert the proximity graph in the simplex tree
st.insert_graph(prox_graph);
// expand the graph until dimension dim_max
@@ -78,7 +79,7 @@ int main(int argc, char * argv[]) {
st.initialize_filtration();
// Compute the persistence diagram of the complex
- Persistent_cohomology< Simplex_tree<>, Multi_field > pcoh(st);
+ Persistent_cohomology<ST, Multi_field > pcoh(st);
// initializes the coefficient field for homology
pcoh.init_coefficients(min_p, max_p);
// compute persistent homology, disgarding persistent features of life shorter than min_persistence
diff --git a/src/Persistent_cohomology/example/rips_persistence.cpp b/src/Persistent_cohomology/example/rips_persistence.cpp
index 9b1ef42f..2d926a0d 100644
--- a/src/Persistent_cohomology/example/rips_persistence.cpp
+++ b/src/Persistent_cohomology/example/rips_persistence.cpp
@@ -65,7 +65,8 @@ int main(int argc, char * argv[]) {
, euclidean_distance<Point_t>);
// Construct the Rips complex in a Simplex Tree
- Simplex_tree<> st;
+ typedef Simplex_tree<Simplex_tree_options_fast_persistence> ST;
+ ST st;
// insert the proximity graph in the simplex tree
st.insert_graph(prox_graph);
// expand the graph until dimension dim_max
@@ -78,7 +79,7 @@ int main(int argc, char * argv[]) {
st.initialize_filtration();
// Compute the persistence diagram of the complex
- persistent_cohomology::Persistent_cohomology< Simplex_tree<>, Field_Zp > pcoh(st);
+ persistent_cohomology::Persistent_cohomology<ST, Field_Zp > pcoh(st);
// initializes the coefficient field for homology
pcoh.init_coefficients(p);
diff --git a/src/Persistent_cohomology/include/gudhi/Persistent_cohomology.h b/src/Persistent_cohomology/include/gudhi/Persistent_cohomology.h
index d096792f..643b810c 100644
--- a/src/Persistent_cohomology/include/gudhi/Persistent_cohomology.h
+++ b/src/Persistent_cohomology/include/gudhi/Persistent_cohomology.h
@@ -27,7 +27,6 @@
#include <gudhi/Persistent_cohomology/Field_Zp.h>
#include <gudhi/Simple_object_pool.h>
-#include <boost/tuple/tuple.hpp>
#include <boost/intrusive/set.hpp>
#include <boost/pending/disjoint_sets.hpp>
#include <boost/intrusive/list.hpp>
@@ -223,7 +222,7 @@ class Persistent_cohomology {
// Sparse column type for the annotation of the boundary of an element.
typedef std::vector<std::pair<Simplex_key, Arith_element> > A_ds_type;
// Persistent interval type. The Arith_element field is used for the multi-field framework.
- typedef boost::tuple<Simplex_handle, Simplex_handle, Arith_element> Persistent_interval;
+ typedef std::tuple<Simplex_handle, Simplex_handle, Arith_element> Persistent_interval;
/** \brief Initializes the Persistent_cohomology class.
*
@@ -431,9 +430,12 @@ class Persistent_cohomology {
std::map<Simplex_key, Arith_element> & map_a_ds, Simplex_handle sigma,
int dim_sigma) {
// traverses the boundary of sigma, keeps track of the annotation vectors,
- // with multiplicity, in a map.
- std::map<Column *, int> annotations_in_boundary;
- std::pair<typename std::map<Column *, int>::iterator, bool> result_insert_bound;
+ // with multiplicity. We used to sum the coefficients directly in
+ // annotations_in_boundary by using a map, we now do it later.
+ typedef std::pair<Column *, int> annotation_t;
+ // Danger: not thread-safe!
+ static std::vector<annotation_t> annotations_in_boundary;
+ annotations_in_boundary.clear();
int sign = 1 - 2 * (dim_sigma % 2); // \in {-1,1} provides the sign in the
// alternate sum in the boundary.
Simplex_key key;
@@ -445,22 +447,29 @@ class Persistent_cohomology {
// Find its annotation vector
curr_col = ds_repr_[dsets_.find_set(key)];
if (curr_col != NULL) { // and insert it in annotations_in_boundary with multyiplicative factor "sign".
- result_insert_bound = annotations_in_boundary.insert(std::pair<Column *, int>(curr_col, sign));
- if (!(result_insert_bound.second)) {
- result_insert_bound.first->second += sign;
- }
+ annotations_in_boundary.emplace_back(curr_col, sign);
}
}
sign = -sign;
}
+ // Place identical annotations consecutively so we can easily sum their multiplicities.
+ std::sort(annotations_in_boundary.begin(), annotations_in_boundary.end(),
+ [](annotation_t const& a, annotation_t const& b) { return a.first < b.first; });
+
// Sum the annotations with multiplicity, using a map<key,coeff>
// to represent a sparse vector.
std::pair<typename std::map<Simplex_key, Arith_element>::iterator, bool> result_insert_a_ds;
- for (auto ann_ref : annotations_in_boundary) {
- if (ann_ref.second != coeff_field_.additive_identity()) { // For all columns in the boundary,
- for (auto cell_ref : ann_ref.first->col_) { // insert every cell in map_a_ds with multiplicity
- Arith_element w_y = coeff_field_.times(cell_ref.coefficient_, ann_ref.second); // coefficient * multiplicity
+ for (auto ann_it = annotations_in_boundary.begin(); ann_it != annotations_in_boundary.end(); /**/) {
+ Column* col = ann_it->first;
+ int mult = ann_it->second;
+ while (++ann_it != annotations_in_boundary.end() && ann_it->first == col) {
+ mult += ann_it->second;
+ }
+ // The following test is just a heuristic, it is not required, and it is fine that is misses p == 0.
+ if (mult != coeff_field_.additive_identity()) { // For all columns in the boundary,
+ for (auto cell_ref : col->col_) { // insert every cell in map_a_ds with multiplicity
+ Arith_element w_y = coeff_field_.times(cell_ref.coefficient_, mult); // coefficient * multiplicity
if (w_y != coeff_field_.additive_identity()) { // if != 0
result_insert_a_ds = map_a_ds.insert(std::pair<Simplex_key, Arith_element>(cell_ref.key_, w_y));
diff --git a/src/Persistent_cohomology/include/gudhi/Persistent_cohomology/Multi_field.h b/src/Persistent_cohomology/include/gudhi/Persistent_cohomology/Multi_field.h
index 0591fc95..38bc08d1 100644
--- a/src/Persistent_cohomology/include/gudhi/Persistent_cohomology/Multi_field.h
+++ b/src/Persistent_cohomology/include/gudhi/Persistent_cohomology/Multi_field.h
@@ -81,8 +81,7 @@ class Multi_field {
// set m to primorial(bound_prime)
prod_characteristics_ = 1;
for (auto p : primes_) {
- mpz_mul_ui(prod_characteristics_.get_mpz_t(),
- prod_characteristics_.get_mpz_t(), p);
+ prod_characteristics_ *= p;
}
// Uvect_
diff --git a/src/Persistent_cohomology/include/gudhi/Persistent_cohomology/Persistent_cohomology_column.h b/src/Persistent_cohomology/include/gudhi/Persistent_cohomology/Persistent_cohomology_column.h
index 612658e6..5deb2d88 100644
--- a/src/Persistent_cohomology/include/gudhi/Persistent_cohomology/Persistent_cohomology_column.h
+++ b/src/Persistent_cohomology/include/gudhi/Persistent_cohomology/Persistent_cohomology_column.h
@@ -23,7 +23,6 @@
#ifndef PERSISTENT_COHOMOLOGY_PERSISTENT_COHOMOLOGY_COLUMN_H_
#define PERSISTENT_COHOMOLOGY_PERSISTENT_COHOMOLOGY_COLUMN_H_
-#include <boost/tuple/tuple.hpp>
#include <boost/intrusive/set.hpp>
#include <boost/intrusive/list.hpp>
diff --git a/src/Persistent_cohomology/test/CMakeLists.txt b/src/Persistent_cohomology/test/CMakeLists.txt
index ed63a6ac..d16be5be 100644
--- a/src/Persistent_cohomology/test/CMakeLists.txt
+++ b/src/Persistent_cohomology/test/CMakeLists.txt
@@ -4,14 +4,10 @@ project(GUDHIPersistentCohomologyUT)
if (GCOVR_PATH)
# for gcovr to make coverage reports - Corbera Jenkins plugin
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
- set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage")
- set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fprofile-arcs -ftest-coverage")
endif()
if (GPROF_PATH)
# for gprof to make coverage reports - Jenkins
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg")
- set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -pg")
- set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -pg")
endif()
add_executable ( PersistentCohomologyUT persistent_cohomology_unit_test.cpp )
diff --git a/src/Simplex_tree/concept/SimplexTreeOptions.h b/src/Simplex_tree/concept/SimplexTreeOptions.h
index add3ebdd..d072cf34 100644
--- a/src/Simplex_tree/concept/SimplexTreeOptions.h
+++ b/src/Simplex_tree/concept/SimplexTreeOptions.h
@@ -37,5 +37,7 @@ struct SimplexTreeOptions {
static const bool store_key;
/// If true, each simplex has extra storage for one `Filtration_value`, and this value is propagated by operations like `Gudhi::Simplex_tree::expansion`. Without it, `Persistent_cohomology` degenerates to computing usual (non-persistent) cohomology.
static const bool store_filtration;
+ /// If true, the list of vertices present in the complex must always be 0, ..., num_vertices-1, without any hole.
+ static constexpr bool contiguous_vertices;
};
diff --git a/src/Simplex_tree/example/CMakeLists.txt b/src/Simplex_tree/example/CMakeLists.txt
index c70cfe35..200161a6 100644
--- a/src/Simplex_tree/example/CMakeLists.txt
+++ b/src/Simplex_tree/example/CMakeLists.txt
@@ -14,11 +14,7 @@ add_test(mini_simplex_tree ${CMAKE_CURRENT_BINARY_DIR}/mini_simplex_tree)
# An example with Simplex-tree using CGAL alpha_shapes_3
if(GMP_FOUND AND CGAL_FOUND)
- message("CGAL_lib = ${CGAL_LIBRARIES_DIR}")
- message("GMP_LIBRARIES = ${GMP_LIBRARIES}")
- INCLUDE_DIRECTORIES(${GMP_INCLUDE_DIR})
- INCLUDE_DIRECTORIES(${CGAL_INCLUDE_DIRS})
- add_executable ( simplex_tree_from_alpha_shapes_3 simplex_tree_from_alpha_shapes_3.cpp )
- target_link_libraries(simplex_tree_from_alpha_shapes_3 ${GMP_LIBRARIES} ${CGAL_LIBRARY})
- add_test(simplex_tree_from_alpha_shapes_3 ${CMAKE_CURRENT_BINARY_DIR}/simplex_tree_from_alpha_shapes_3 ${CMAKE_SOURCE_DIR}/data/points/bunny_5000)
+ add_executable ( simplex_tree_from_alpha_shapes_3 simplex_tree_from_alpha_shapes_3.cpp )
+ target_link_libraries(simplex_tree_from_alpha_shapes_3 ${GMP_LIBRARIES} ${CGAL_LIBRARY} ${Boost_SYSTEM_LIBRARY})
+ add_test(simplex_tree_from_alpha_shapes_3 ${CMAKE_CURRENT_BINARY_DIR}/simplex_tree_from_alpha_shapes_3 ${CMAKE_SOURCE_DIR}/data/points/bunny_5000)
endif()
diff --git a/src/Simplex_tree/example/simplex_tree_from_alpha_shapes_3.cpp b/src/Simplex_tree/example/simplex_tree_from_alpha_shapes_3.cpp
index 45efe3ed..49d358ab 100644
--- a/src/Simplex_tree/example/simplex_tree_from_alpha_shapes_3.cpp
+++ b/src/Simplex_tree/example/simplex_tree_from_alpha_shapes_3.cpp
@@ -62,7 +62,8 @@ typedef Alpha_shape_3::Edge Edge;
typedef std::list<Alpha_shape_3::Vertex_handle> Vertex_list;
// gudhi type definition
-typedef Gudhi::Simplex_tree<>::Vertex_handle Simplex_tree_vertex;
+typedef Gudhi::Simplex_tree<> Simplex_tree;
+typedef Simplex_tree::Vertex_handle Simplex_tree_vertex;
typedef std::map<Alpha_shape_3::Vertex_handle, Simplex_tree_vertex > Alpha_shape_simplex_tree_map;
typedef std::pair<Alpha_shape_3::Vertex_handle, Simplex_tree_vertex> Alpha_shape_simplex_tree_pair;
typedef std::vector< Simplex_tree_vertex > Simplex_tree_vector_vertex;
@@ -161,7 +162,7 @@ int main(int argc, char * const argv[]) {
// Loop on objects vector
Vertex_list vertex_list;
- Gudhi::Simplex_tree<> simplex_tree;
+ Simplex_tree simplex_tree;
Alpha_shape_simplex_tree_map map_cgal_simplex_tree;
std::vector<Alpha_value_type>::iterator the_alpha_value_iterator = the_alpha_values.begin();
for (auto object_iterator : the_objects) {
diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h
index 4c6a95e8..096270ee 100644
--- a/src/Simplex_tree/include/gudhi/Simplex_tree.h
+++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h
@@ -35,10 +35,15 @@
#include <boost/iterator/transform_iterator.hpp>
#include <boost/graph/adjacency_list.hpp>
+#ifdef GUDHI_USE_TBB
+#include <tbb/parallel_sort.h>
+#endif
+
#include <algorithm>
#include <utility>
#include <vector>
#include <functional> // for greater<>
+#include <initializer_list>
namespace Gudhi {
@@ -77,15 +82,7 @@ namespace Gudhi {
* @{
*/
-/// Model of SimplexTreeOptions.
-struct Simplex_tree_options_full_featured {
- typedef linear_indexing_tag Indexing_tag;
- typedef int Vertex_handle;
- typedef double Filtration_value;
- typedef int Simplex_key;
- static const bool store_key = true;
- static const bool store_filtration = true;
-};
+struct Simplex_tree_options_full_featured;
/**
* \brief Simplex Tree data structure for representing simplicial complexes.
@@ -328,11 +325,10 @@ class Simplex_tree {
Simplex_tree(const Simplex_tree& simplex_source)
: null_vertex_(simplex_source.null_vertex_),
threshold_(simplex_source.threshold_),
+ root_(nullptr, null_vertex_ , simplex_source.root_.members_),
filtration_vect_(),
dimension_(simplex_source.dimension_) {
auto root_source = simplex_source.root_;
- auto memb_source = root_source.members();
- root_ = Siblings(nullptr, null_vertex_, memb_source);
rec_copy(&root_, &root_source);
}
@@ -344,7 +340,7 @@ class Simplex_tree {
Siblings * newsib = new Siblings(sib, sh_source->first);
newsib->members_.reserve(sh_source->second.children()->members().size());
for (auto & child : sh_source->second.children()->members())
- newsib->members_.emplace_hint(newsib->members_.end(), child.first, Node(sib, child.second.filtration()));
+ newsib->members_.emplace_hint(newsib->members_.end(), child.first, Node(newsib, child.second.filtration()));
rec_copy(newsib, sh_source->second.children());
sh->second.assign_children(newsib);
}
@@ -531,7 +527,7 @@ class Simplex_tree {
* The type InputVertexRange must be a range of <CODE>Vertex_handle</CODE>
* on which we can call std::begin() function
*/
- template<class InputVertexRange>
+ template<class InputVertexRange = std::initializer_list<Vertex_handle>>
Simplex_handle find(const InputVertexRange & s) {
auto first = std::begin(s);
auto last = std::end(s);
@@ -567,9 +563,22 @@ class Simplex_tree {
/** \brief Returns the Simplex_handle corresponding to the 0-simplex
* representing the vertex with Vertex_handle v. */
Simplex_handle find_vertex(Vertex_handle v) {
- return root_.members_.begin() + v;
+ if (Options::contiguous_vertices) {
+ assert(contiguous_vertices());
+ return root_.members_.begin() + v;
+ } else {
+ return root_.members_.find(v);
+ }
+ }
+
+ public:
+ /** \private \brief Test if the vertices have contiguous numbering: 0, 1, etc. */
+ bool contiguous_vertices() const {
+ if (root_.members_.empty()) return true;
+ if (root_.members_.begin()->first != 0) return false;
+ if (std::prev(root_.members_.end())->first != root_.members_.size()-1) return false;
+ return true;
}
- //{ return root_.members_.find(v); }
private:
/** \brief Inserts a simplex represented by a vector of vertex.
@@ -625,7 +634,7 @@ class Simplex_tree {
*
* The type InputVertexRange must be a range for which .begin() and
* .end() return input iterators, with 'value_type' Vertex_handle. */
- template<class InputVertexRange>
+ template<class InputVertexRange = std::initializer_list<Vertex_handle>>
std::pair<Simplex_handle, bool> insert_simplex(const InputVertexRange & simplex,
Filtration_value filtration = 0) {
auto first = std::begin(simplex);
@@ -654,7 +663,7 @@ class Simplex_tree {
* output pair to the Simplex_handle of the simplex. Otherwise, we set the Simplex_handle part to
* null_simplex.
*/
- template<class InputVertexRange>
+ template<class InputVertexRange=std::initializer_list<Vertex_handle>>
std::pair<Simplex_handle, bool> insert_simplex_and_subfaces(const InputVertexRange& Nsimplex,
Filtration_value filtration = 0) {
auto first = std::begin(Nsimplex);
@@ -788,8 +797,12 @@ class Simplex_tree {
* heuristic consists in inserting the cofaces of a simplex as soon as
* possible.
*/
+#ifdef GUDHI_USE_TBB
+ tbb::parallel_sort(filtration_vect_, is_before_in_filtration(this));
+#else
std::stable_sort(filtration_vect_.begin(), filtration_vect_.end(),
is_before_in_filtration(this));
+#endif
}
private:
@@ -1145,6 +1158,31 @@ std::istream& operator>>(std::istream & is, Simplex_tree<T...> & st) {
return is;
}
+
+/// Model of SimplexTreeOptions.
+struct Simplex_tree_options_full_featured {
+ typedef linear_indexing_tag Indexing_tag;
+ typedef int Vertex_handle;
+ typedef double Filtration_value;
+ typedef int Simplex_key;
+ static const bool store_key = true;
+ static const bool store_filtration = true;
+ static const bool contiguous_vertices = false;
+};
+
+/** Model of SimplexTreeOptions, faster than
+ `Simplex_tree_options_full_featured` but note the unsafe
+ `contiguous_vertices` option. */
+struct Simplex_tree_options_fast_persistence {
+ typedef linear_indexing_tag Indexing_tag;
+ typedef int Vertex_handle;
+ typedef float Filtration_value;
+ typedef int Simplex_key;
+ static const bool store_key = true;
+ static const bool store_filtration = true;
+ static const bool contiguous_vertices = true;
+};
+
/** @} */ // end defgroup simplex_tree
} // namespace Gudhi
diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_iterators.h b/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_iterators.h
index 372ef329..936b7a1f 100644
--- a/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_iterators.h
+++ b/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_iterators.h
@@ -54,7 +54,7 @@ class Simplex_tree_simplex_vertex_iterator : public boost::iterator_facade<
explicit Simplex_tree_simplex_vertex_iterator(SimplexTree * st)
: // any end() iterator
- sib_(NULL),
+ sib_(nullptr),
v_(st->null_vertex()) {
}
@@ -99,21 +99,22 @@ class Simplex_tree_boundary_simplex_iterator : public boost::iterator_facade<
// any end() iterator
explicit Simplex_tree_boundary_simplex_iterator(SimplexTree * st)
- : last_(st->null_vertex()),
- sib_(NULL) {
+ : sib_(nullptr),
+ sh_(st->null_simplex()),
+ st_(st) {
}
Simplex_tree_boundary_simplex_iterator(SimplexTree * st, Simplex_handle sh)
- : suffix_(),
+ : last_(sh->first),
+ sib_(nullptr),
st_(st) {
- last_ = sh->first;
Siblings * sib = st->self_siblings(sh);
next_ = sib->parent();
- sib_ = sib->oncles(); /* \todo check if NULL*/
- if (sib_ != NULL) {
+ sib_ = sib->oncles();
+ if (sib_ != nullptr) {
sh_ = sib_->find(next_);
} else {
- last_ = st->null_vertex();
+ sh_ = st->null_simplex();
} // vertex: == end()
}
@@ -121,28 +122,40 @@ class Simplex_tree_boundary_simplex_iterator : public boost::iterator_facade<
friend class boost::iterator_core_access;
// valid when iterating along the SAME boundary.
bool equal(Simplex_tree_boundary_simplex_iterator const& other) const {
- return (sib_ == other.sib_ && last_ == other.last_);
+ return sh_ == other.sh_;
}
Simplex_handle const& dereference() const {
+ assert(sh_ != st_->null_simplex());
return sh_;
}
void increment() {
- if (sib_ == NULL) {
- last_ = st_->null_vertex();
+ if (sib_ == nullptr) {
+ sh_ = st_->null_simplex();
return;
}
Siblings * for_sib = sib_;
- for (auto rit = suffix_.rbegin(); rit != suffix_.rend(); ++rit) {
+ Siblings * new_sib = sib_->oncles();
+ auto rit = suffix_.rbegin();
+ if (SimplexTree::Options::contiguous_vertices && new_sib == nullptr && rit != suffix_.rend()) {
+ // We reached the root, use a short-cut to find a vertex. We could also
+ // optimize finding the second vertex of a segment, but people are
+ // expected to call endpoints().
+ assert(st_->contiguous_vertices());
+ sh_ = for_sib->members_.begin()+*rit;
+ for_sib = sh_->second.children();
+ ++rit;
+ }
+ for (; rit != suffix_.rend(); ++rit) {
sh_ = for_sib->find(*rit);
for_sib = sh_->second.children();
}
sh_ = for_sib->find(last_); // sh_ points to the right simplex now
suffix_.push_back(next_);
next_ = sib_->parent();
- sib_ = sib_->oncles();
+ sib_ = new_sib;
}
// Most of the storage should be moved to the range, iterators should be light.
@@ -176,13 +189,15 @@ class Simplex_tree_complex_simplex_iterator : public boost::iterator_facade<
// any end() iterator
Simplex_tree_complex_simplex_iterator()
- : st_(NULL) {
+ : sib_(nullptr),
+ st_(nullptr) {
}
explicit Simplex_tree_complex_simplex_iterator(SimplexTree * st)
- : st_(st) {
- if (st == NULL || st->root() == NULL || st->root()->members().empty()) {
- st_ = NULL;
+ : sib_(nullptr),
+ st_(st) {
+ if (st == nullptr || st->root() == nullptr || st->root()->members().empty()) {
+ st_ = nullptr;
} else {
sh_ = st->root()->members().begin();
sib_ = st->root();
@@ -197,10 +212,10 @@ class Simplex_tree_complex_simplex_iterator : public boost::iterator_facade<
// valid when iterating along the SAME boundary.
bool equal(Simplex_tree_complex_simplex_iterator const& other) const {
- if (other.st_ == NULL) {
- return (st_ == NULL);
+ if (other.st_ == nullptr) {
+ return (st_ == nullptr);
}
- if (st_ == NULL) {
+ if (st_ == nullptr) {
return false;
}
return (&(sh_->second) == &(other.sh_->second));
@@ -214,8 +229,8 @@ class Simplex_tree_complex_simplex_iterator : public boost::iterator_facade<
void increment() {
++sh_;
if (sh_ == sib_->members().end()) {
- if (sib_->oncles() == NULL) {
- st_ = NULL;
+ if (sib_->oncles() == nullptr) {
+ st_ = nullptr;
return;
} // reach the end
sh_ = sib_->oncles()->members().find(sib_->parent());
@@ -248,15 +263,19 @@ class Simplex_tree_skeleton_simplex_iterator : public boost::iterator_facade<
// any end() iterator
Simplex_tree_skeleton_simplex_iterator()
- : st_(NULL) {
+ : sib_(nullptr),
+ st_(nullptr),
+ dim_skel_(0),
+ curr_dim_(0) {
}
Simplex_tree_skeleton_simplex_iterator(SimplexTree * st, int dim_skel)
- : st_(st),
+ : sib_(nullptr),
+ st_(st),
dim_skel_(dim_skel),
curr_dim_(0) {
- if (st == NULL || st->root() == NULL || st->root()->members().empty()) {
- st_ = NULL;
+ if (st == nullptr || st->root() == nullptr || st->root()->members().empty()) {
+ st_ = nullptr;
} else {
sh_ = st->root()->members().begin();
sib_ = st->root();
@@ -272,10 +291,10 @@ class Simplex_tree_skeleton_simplex_iterator : public boost::iterator_facade<
// valid when iterating along the SAME boundary.
bool equal(Simplex_tree_skeleton_simplex_iterator const& other) const {
- if (other.st_ == NULL) {
- return (st_ == NULL);
+ if (other.st_ == nullptr) {
+ return (st_ == nullptr);
}
- if (st_ == NULL) {
+ if (st_ == nullptr) {
return false;
}
return (&(sh_->second) == &(other.sh_->second));
@@ -289,8 +308,8 @@ class Simplex_tree_skeleton_simplex_iterator : public boost::iterator_facade<
void increment() {
++sh_;
if (sh_ == sib_->members().end()) {
- if (sib_->oncles() == NULL) {
- st_ = NULL;
+ if (sib_->oncles() == nullptr) {
+ st_ = nullptr;
return;
} // reach the end
sh_ = sib_->oncles()->members().find(sib_->parent());
diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_siblings.h b/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_siblings.h
index 158ee1f7..072afc8d 100644
--- a/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_siblings.h
+++ b/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_siblings.h
@@ -57,7 +57,7 @@ class Simplex_tree_siblings {
/* Default constructor.*/
Simplex_tree_siblings()
- : oncles_(NULL),
+ : oncles_(nullptr),
parent_(-1),
members_() {
}
diff --git a/src/Simplex_tree/test/CMakeLists.txt b/src/Simplex_tree/test/CMakeLists.txt
index c9eae163..1f2f7d33 100644
--- a/src/Simplex_tree/test/CMakeLists.txt
+++ b/src/Simplex_tree/test/CMakeLists.txt
@@ -4,14 +4,10 @@ project(GUDHISimplexTreeUT)
if (GCOVR_PATH)
# for gcovr to make coverage reports - Corbera Jenkins plugin
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
- set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage")
- set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fprofile-arcs -ftest-coverage")
endif()
if (GPROF_PATH)
# for gprof to make coverage reports - Jenkins
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg")
- set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -pg")
- set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -pg")
endif()
add_executable ( SimplexTreeUT simplex_tree_unit_test.cpp )
diff --git a/src/Simplex_tree/test/simplex_tree_unit_test.cpp b/src/Simplex_tree/test/simplex_tree_unit_test.cpp
index fff00d77..874c3363 100644
--- a/src/Simplex_tree/test/simplex_tree_unit_test.cpp
+++ b/src/Simplex_tree/test/simplex_tree_unit_test.cpp
@@ -4,10 +4,12 @@
#include <utility> // std::pair, std::make_pair
#include <cmath> // float comparison
#include <limits>
+#include <functional> // greater
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE "simplex_tree"
#include <boost/test/unit_test.hpp>
+#include <boost/mpl/list.hpp>
// ^
// /!\ Nothing else from Simplex_tree shall be included to test includes are well defined.
@@ -15,26 +17,25 @@
using namespace Gudhi;
-typedef Simplex_tree<> typeST;
-typedef std::pair<typeST::Simplex_handle, bool> typePairSimplexBool;
-typedef std::vector<Vertex_handle> typeVectorVertex;
-typedef std::pair<typeVectorVertex, Filtration_value> typeSimplex;
+typedef boost::mpl::list<Simplex_tree<>, Simplex_tree<Simplex_tree_options_fast_persistence>> list_of_tested_variants;
const Vertex_handle DEFAULT_VERTEX_HANDLE = (const Vertex_handle) - 1;
const Filtration_value DEFAULT_FILTRATION_VALUE = (const Filtration_value) 0.0;
+template<class typeST>
void test_empty_simplex_tree(typeST& tst) {
BOOST_CHECK(tst.null_vertex() == DEFAULT_VERTEX_HANDLE);
BOOST_CHECK(tst.filtration() == DEFAULT_FILTRATION_VALUE);
BOOST_CHECK(tst.num_vertices() == (size_t) 0);
BOOST_CHECK(tst.num_simplices() == (size_t) 0);
- typeST::Siblings* STRoot = tst.root();
- BOOST_CHECK(STRoot != NULL);
- BOOST_CHECK(STRoot->oncles() == NULL);
+ typename typeST::Siblings* STRoot = tst.root();
+ BOOST_CHECK(STRoot != nullptr);
+ BOOST_CHECK(STRoot->oncles() == nullptr);
BOOST_CHECK(STRoot->parent() == DEFAULT_VERTEX_HANDLE);
BOOST_CHECK(tst.dimension() == -1);
}
+template<class typeST>
void test_iterators_on_empty_simplex_tree(typeST& tst) {
std::cout << "Iterator on vertices: " << std::endl;
for (auto vertex : tst.complex_vertex_range()) {
@@ -56,8 +57,9 @@ void test_iterators_on_empty_simplex_tree(typeST& tst) {
}
}
-BOOST_AUTO_TEST_CASE(simplex_tree_when_empty) {
- const Filtration_value DEFAULT_FILTRATION_VALUE = 0;
+BOOST_AUTO_TEST_CASE_TEMPLATE(simplex_tree_when_empty, typeST, list_of_tested_variants) {
+ typedef std::pair<typename typeST::Simplex_handle, bool> typePairSimplexBool;
+ typedef std::vector<Vertex_handle> typeVectorVertex;
std::cout << "********************************************************************" << std::endl;
std::cout << "TEST OF DEFAULT CONSTRUCTOR" << std::endl;
@@ -72,7 +74,7 @@ BOOST_AUTO_TEST_CASE(simplex_tree_when_empty) {
BOOST_CHECK(simplexVectorEmpty.empty() == true);
typePairSimplexBool returnEmptyValue = st.insert_simplex(simplexVectorEmpty,
DEFAULT_FILTRATION_VALUE);
- BOOST_CHECK(returnEmptyValue.first == typeST::Simplex_handle(NULL));
+ BOOST_CHECK(returnEmptyValue.first == typename typeST::Simplex_handle(nullptr));
BOOST_CHECK(returnEmptyValue.second == true);
test_empty_simplex_tree(st);
@@ -84,7 +86,7 @@ bool AreAlmostTheSame(float a, float b) {
return std::fabs(a - b) < std::numeric_limits<float>::epsilon();
}
-BOOST_AUTO_TEST_CASE(simplex_tree_from_file) {
+BOOST_AUTO_TEST_CASE_TEMPLATE(simplex_tree_from_file, typeST, list_of_tested_variants) {
// TEST OF INSERTION
std::cout << "********************************************************************" << std::endl;
std::cout << "TEST OF SIMPLEX TREE FROM A FILE" << std::endl;
@@ -101,7 +103,7 @@ BOOST_AUTO_TEST_CASE(simplex_tree_from_file) {
// Check
BOOST_CHECK(st.num_simplices() == 143353);
BOOST_CHECK(st.dimension() == 3);
- BOOST_CHECK(st.filtration() == 0.4);
+ BOOST_CHECK(AreAlmostTheSame(st.filtration(), 0.4));
int previous_size = 0;
for (auto f_simplex : st.filtration_simplex_range()) {
@@ -119,6 +121,7 @@ BOOST_AUTO_TEST_CASE(simplex_tree_from_file) {
simplex_tree_stream.close();
}
+template<class typeST, class typeSimplex>
void test_simplex_tree_contains(typeST& simplexTree, typeSimplex& simplex, int pos) {
auto f_simplex = simplexTree.filtration_simplex_range().begin() + pos;
@@ -135,16 +138,18 @@ void test_simplex_tree_contains(typeST& simplexTree, typeSimplex& simplex, int p
}
}
+template<class typeST, class typePairSimplexBool>
void test_simplex_tree_insert_returns_true(const typePairSimplexBool& returnValue) {
BOOST_CHECK(returnValue.second == true);
- typeST::Simplex_handle shReturned = returnValue.first; // Simplex_handle = boost::container::flat_map< Vertex_handle, Node >::iterator
- BOOST_CHECK(shReturned != typeST::Simplex_handle(NULL));
+ typename typeST::Simplex_handle shReturned = returnValue.first; // Simplex_handle = boost::container::flat_map< Vertex_handle, Node >::iterator
+ BOOST_CHECK(shReturned != typename typeST::Simplex_handle(nullptr));
}
// Global variables
Filtration_value max_fil = DEFAULT_FILTRATION_VALUE;
int dim_max = -1;
+template<class typeST, class Filtration_value>
void set_and_test_simplex_tree_dim_fil(typeST& simplexTree, int vectorSize, const Filtration_value& fil) {
if (vectorSize > dim_max + 1) {
dim_max = vectorSize - 1;
@@ -173,11 +178,17 @@ void set_and_test_simplex_tree_dim_fil(typeST& simplexTree, int vectorSize, cons
BOOST_CHECK(simplexTree.num_simplices() == num_simp);
}
-BOOST_AUTO_TEST_CASE(simplex_tree_insertion) {
+BOOST_AUTO_TEST_CASE_TEMPLATE(simplex_tree_insertion, typeST, list_of_tested_variants) {
+ typedef std::pair<typename typeST::Simplex_handle, bool> typePairSimplexBool;
+ typedef std::vector<Vertex_handle> typeVectorVertex;
+ typedef std::pair<typeVectorVertex, Filtration_value> typeSimplex;
const Filtration_value FIRST_FILTRATION_VALUE = 0.1;
const Filtration_value SECOND_FILTRATION_VALUE = 0.2;
const Filtration_value THIRD_FILTRATION_VALUE = 0.3;
const Filtration_value FOURTH_FILTRATION_VALUE = 0.4;
+ // reset since we run the test several times
+ dim_max = -1;
+ max_fil = DEFAULT_FILTRATION_VALUE;
// TEST OF INSERTION
std::cout << "********************************************************************" << std::endl;
@@ -191,7 +202,7 @@ BOOST_AUTO_TEST_CASE(simplex_tree_insertion) {
typeSimplex firstSimplex = std::make_pair(firstSimplexVector, Filtration_value(FIRST_FILTRATION_VALUE));
typePairSimplexBool returnValue = st.insert_simplex(firstSimplex.first, firstSimplex.second);
- test_simplex_tree_insert_returns_true(returnValue);
+ test_simplex_tree_insert_returns_true<typeST>(returnValue);
set_and_test_simplex_tree_dim_fil(st, firstSimplexVector.size(), firstSimplex.second);
BOOST_CHECK(st.num_vertices() == (size_t) 1);
@@ -202,7 +213,7 @@ BOOST_AUTO_TEST_CASE(simplex_tree_insertion) {
typeSimplex secondSimplex = std::make_pair(secondSimplexVector, Filtration_value(FIRST_FILTRATION_VALUE));
returnValue = st.insert_simplex(secondSimplex.first, secondSimplex.second);
- test_simplex_tree_insert_returns_true(returnValue);
+ test_simplex_tree_insert_returns_true<typeST>(returnValue);
set_and_test_simplex_tree_dim_fil(st, secondSimplexVector.size(), secondSimplex.second);
BOOST_CHECK(st.num_vertices() == (size_t) 2);
@@ -213,7 +224,7 @@ BOOST_AUTO_TEST_CASE(simplex_tree_insertion) {
typeSimplex thirdSimplex = std::make_pair(thirdSimplexVector, Filtration_value(SECOND_FILTRATION_VALUE));
returnValue = st.insert_simplex(thirdSimplex.first, thirdSimplex.second);
- test_simplex_tree_insert_returns_true(returnValue);
+ test_simplex_tree_insert_returns_true<typeST>(returnValue);
set_and_test_simplex_tree_dim_fil(st, thirdSimplexVector.size(), thirdSimplex.second);
BOOST_CHECK(st.num_vertices() == (size_t) 2); // Not incremented !!
@@ -224,7 +235,7 @@ BOOST_AUTO_TEST_CASE(simplex_tree_insertion) {
typeSimplex fourthSimplex = std::make_pair(fourthSimplexVector, Filtration_value(FIRST_FILTRATION_VALUE));
returnValue = st.insert_simplex(fourthSimplex.first, fourthSimplex.second);
- test_simplex_tree_insert_returns_true(returnValue);
+ test_simplex_tree_insert_returns_true<typeST>(returnValue);
set_and_test_simplex_tree_dim_fil(st, fourthSimplexVector.size(), fourthSimplex.second);
BOOST_CHECK(st.num_vertices() == (size_t) 3);
@@ -235,7 +246,7 @@ BOOST_AUTO_TEST_CASE(simplex_tree_insertion) {
typeSimplex fifthSimplex = std::make_pair(fifthSimplexVector, Filtration_value(SECOND_FILTRATION_VALUE));
returnValue = st.insert_simplex(fifthSimplex.first, fifthSimplex.second);
- test_simplex_tree_insert_returns_true(returnValue);
+ test_simplex_tree_insert_returns_true<typeST>(returnValue);
set_and_test_simplex_tree_dim_fil(st, fifthSimplexVector.size(), fifthSimplex.second);
BOOST_CHECK(st.num_vertices() == (size_t) 3); // Not incremented !!
@@ -246,7 +257,7 @@ BOOST_AUTO_TEST_CASE(simplex_tree_insertion) {
typeSimplex sixthSimplex = std::make_pair(sixthSimplexVector, Filtration_value(SECOND_FILTRATION_VALUE));
returnValue = st.insert_simplex(sixthSimplex.first, sixthSimplex.second);
- test_simplex_tree_insert_returns_true(returnValue);
+ test_simplex_tree_insert_returns_true<typeST>(returnValue);
set_and_test_simplex_tree_dim_fil(st, sixthSimplexVector.size(), sixthSimplex.second);
BOOST_CHECK(st.num_vertices() == (size_t) 3); // Not incremented !!
@@ -257,7 +268,7 @@ BOOST_AUTO_TEST_CASE(simplex_tree_insertion) {
typeSimplex seventhSimplex = std::make_pair(seventhSimplexVector, Filtration_value(THIRD_FILTRATION_VALUE));
returnValue = st.insert_simplex(seventhSimplex.first, seventhSimplex.second);
- test_simplex_tree_insert_returns_true(returnValue);
+ test_simplex_tree_insert_returns_true<typeST>(returnValue);
set_and_test_simplex_tree_dim_fil(st, seventhSimplexVector.size(), seventhSimplex.second);
BOOST_CHECK(st.num_vertices() == (size_t) 3); // Not incremented !!
@@ -268,7 +279,7 @@ BOOST_AUTO_TEST_CASE(simplex_tree_insertion) {
typeSimplex eighthSimplex = std::make_pair(eighthSimplexVector, Filtration_value(FIRST_FILTRATION_VALUE));
returnValue = st.insert_simplex(eighthSimplex.first, eighthSimplex.second);
- test_simplex_tree_insert_returns_true(returnValue);
+ test_simplex_tree_insert_returns_true<typeST>(returnValue);
set_and_test_simplex_tree_dim_fil(st, eighthSimplexVector.size(), eighthSimplex.second);
BOOST_CHECK(st.num_vertices() == (size_t) 4);
@@ -279,7 +290,7 @@ BOOST_AUTO_TEST_CASE(simplex_tree_insertion) {
typeSimplex ninethSimplex = std::make_pair(ninethSimplexVector, Filtration_value(SECOND_FILTRATION_VALUE));
returnValue = st.insert_simplex(ninethSimplex.first, ninethSimplex.second);
- test_simplex_tree_insert_returns_true(returnValue);
+ test_simplex_tree_insert_returns_true<typeST>(returnValue);
set_and_test_simplex_tree_dim_fil(st, ninethSimplexVector.size(), ninethSimplex.second);
BOOST_CHECK(st.num_vertices() == (size_t) 4); // Not incremented !!
@@ -292,8 +303,8 @@ BOOST_AUTO_TEST_CASE(simplex_tree_insertion) {
returnValue = st.insert_simplex(tenthSimplex.first, tenthSimplex.second);
BOOST_CHECK(returnValue.second == false);
- typeST::Simplex_handle shReturned = returnValue.first; // Simplex_handle = boost::container::flat_map< Vertex_handle, Node >::iterator
- BOOST_CHECK(shReturned == typeST::Simplex_handle(NULL));
+ typename typeST::Simplex_handle shReturned = returnValue.first; // Simplex_handle = boost::container::flat_map< Vertex_handle, Node >::iterator
+ BOOST_CHECK(shReturned == typename typeST::Simplex_handle(nullptr));
BOOST_CHECK(st.num_vertices() == (size_t) 4); // Not incremented !!
BOOST_CHECK(st.dimension() == dim_max);
BOOST_CHECK(AreAlmostTheSame(st.filtration(), max_fil));
@@ -307,7 +318,7 @@ BOOST_AUTO_TEST_CASE(simplex_tree_insertion) {
BOOST_CHECK(returnValue.second == false);
shReturned = returnValue.first; // Simplex_handle = boost::container::flat_map< Vertex_handle, Node >::iterator
- BOOST_CHECK(shReturned == typeST::Simplex_handle(NULL));
+ BOOST_CHECK(shReturned == typename typeST::Simplex_handle(nullptr));
BOOST_CHECK(st.num_vertices() == (size_t) 4); // Not incremented !!
BOOST_CHECK(st.dimension() == dim_max);
BOOST_CHECK(AreAlmostTheSame(st.filtration(), max_fil));
@@ -362,9 +373,10 @@ BOOST_AUTO_TEST_CASE(simplex_tree_insertion) {
}
-bool sort_in_decr_order (Vertex_handle i,Vertex_handle j) { return (i>j); }
-
-BOOST_AUTO_TEST_CASE(NSimplexAndSubfaces_tree_insertion) {
+BOOST_AUTO_TEST_CASE_TEMPLATE(NSimplexAndSubfaces_tree_insertion, typeST, list_of_tested_variants) {
+ typedef std::pair<typename typeST::Simplex_handle, bool> typePairSimplexBool;
+ typedef std::vector<Vertex_handle> typeVectorVertex;
+ typedef std::pair<typeVectorVertex, Filtration_value> typeSimplex;
std::cout << "********************************************************************" << std::endl;
std::cout << "TEST OF RECURSIVE INSERTION" << std::endl;
typeST st;
@@ -382,7 +394,7 @@ BOOST_AUTO_TEST_CASE(NSimplexAndSubfaces_tree_insertion) {
// Check it is well inserted
BOOST_CHECK(true == returnValue.second);
position = 0;
- std::sort(SimplexVector1.begin(), SimplexVector1.end(), sort_in_decr_order);
+ std::sort(SimplexVector1.begin(), SimplexVector1.end(), std::greater<Vertex_handle>());
for (auto vertex : st.simplex_vertex_range(returnValue.first)) {
// Check returned Simplex_handle
std::cout << "vertex = " << vertex << " | vector[" << position << "] = " << SimplexVector1[position] << std::endl;
@@ -401,7 +413,7 @@ BOOST_AUTO_TEST_CASE(NSimplexAndSubfaces_tree_insertion) {
// Check it is well inserted
BOOST_CHECK(true == returnValue.second);
position = 0;
- std::sort(SimplexVector2.begin(), SimplexVector2.end(), sort_in_decr_order);
+ std::sort(SimplexVector2.begin(), SimplexVector2.end(), std::greater<Vertex_handle>());
for (auto vertex : st.simplex_vertex_range(returnValue.first)) {
// Check returned Simplex_handle
std::cout << "vertex = " << vertex << " | vector[" << position << "] = " << SimplexVector2[position] << std::endl;
@@ -420,7 +432,7 @@ BOOST_AUTO_TEST_CASE(NSimplexAndSubfaces_tree_insertion) {
// Check it is well inserted
BOOST_CHECK(true == returnValue.second);
position = 0;
- std::sort(SimplexVector3.begin(), SimplexVector3.end(), sort_in_decr_order);
+ std::sort(SimplexVector3.begin(), SimplexVector3.end(), std::greater<Vertex_handle>());
for (auto vertex : st.simplex_vertex_range(returnValue.first)) {
// Check returned Simplex_handle
std::cout << "vertex = " << vertex << " | vector[" << position << "] = " << SimplexVector3[position] << std::endl;
@@ -450,7 +462,7 @@ BOOST_AUTO_TEST_CASE(NSimplexAndSubfaces_tree_insertion) {
// Check it is well inserted
BOOST_CHECK(true == returnValue.second);
position = 0;
- std::sort(SimplexVector5.begin(), SimplexVector5.end(), sort_in_decr_order);
+ std::sort(SimplexVector5.begin(), SimplexVector5.end(), std::greater<Vertex_handle>());
for (auto vertex : st.simplex_vertex_range(returnValue.first)) {
// Check returned Simplex_handle
std::cout << "vertex = " << vertex << " | vector[" << position << "] = " << SimplexVector5[position] << std::endl;
@@ -469,7 +481,7 @@ BOOST_AUTO_TEST_CASE(NSimplexAndSubfaces_tree_insertion) {
// Check it is well inserted
BOOST_CHECK(true == returnValue.second);
position = 0;
- std::sort(SimplexVector6.begin(), SimplexVector6.end(), sort_in_decr_order);
+ std::sort(SimplexVector6.begin(), SimplexVector6.end(), std::greater<Vertex_handle>());
for (auto vertex : st.simplex_vertex_range(returnValue.first)) {
// Check returned Simplex_handle
std::cout << "vertex = " << vertex << " | vector[" << position << "] = " << SimplexVector6[position] << std::endl;
@@ -509,7 +521,7 @@ BOOST_AUTO_TEST_CASE(NSimplexAndSubfaces_tree_insertion) {
// Find in the simplex_tree
// ------------------------------------------------------------------------------------------------------------------
typeVectorVertex simpleSimplexVector{1};
- Simplex_tree<>::Simplex_handle simplexFound = st.find(simpleSimplexVector);
+ typename typeST::Simplex_handle simplexFound = st.find(simpleSimplexVector);
std::cout << "**************IS THE SIMPLEX {1} IN THE SIMPLEX TREE ?\n";
if (simplexFound != st.null_simplex())
std::cout << "***+ YES IT IS!\n";
@@ -570,14 +582,15 @@ BOOST_AUTO_TEST_CASE(NSimplexAndSubfaces_tree_insertion) {
}
}
-void test_cofaces(typeST& st, std::vector<Vertex_handle> expected, int dim, std::vector<typeST::Simplex_handle> res) {
- typeST::Cofaces_simplex_range cofaces;
+template<class typeST, class Vertex_handle>
+void test_cofaces(typeST& st, const std::vector<Vertex_handle>& expected, int dim, const std::vector<typename typeST::Simplex_handle>& res) {
+ typename typeST::Cofaces_simplex_range cofaces;
if (dim == 0)
cofaces = st.star_simplex_range(st.find(expected));
else
cofaces = st.cofaces_simplex_range(st.find(expected), dim);
for (auto simplex = cofaces.begin(); simplex != cofaces.end(); ++simplex) {
- typeST::Simplex_vertex_range rg = st.simplex_vertex_range(*simplex);
+ typename typeST::Simplex_vertex_range rg = st.simplex_vertex_range(*simplex);
for (auto vertex = rg.begin(); vertex != rg.end(); ++vertex) {
std::cout << "(" << *vertex << ")";
}
@@ -586,7 +599,8 @@ void test_cofaces(typeST& st, std::vector<Vertex_handle> expected, int dim, std:
}
}
-BOOST_AUTO_TEST_CASE(coface_on_simplex_tree) {
+BOOST_AUTO_TEST_CASE_TEMPLATE(coface_on_simplex_tree, typeST, list_of_tested_variants) {
+ typedef std::vector<Vertex_handle> typeVectorVertex;
std::cout << "********************************************************************" << std::endl;
std::cout << "TEST COFACE ALGORITHM" << std::endl;
typeST st;
@@ -616,7 +630,7 @@ BOOST_AUTO_TEST_CASE(coface_on_simplex_tree) {
st.set_dimension(3);
std::vector<Vertex_handle> simplex_result;
- std::vector<typeST::Simplex_handle> result;
+ std::vector<typename typeST::Simplex_handle> result;
std::cout << "First test - Star of (3):" << std::endl;
simplex_result = {3};
@@ -684,7 +698,8 @@ BOOST_AUTO_TEST_CASE(coface_on_simplex_tree) {
}
-BOOST_AUTO_TEST_CASE(copy_move_on_simplex_tree) {
+BOOST_AUTO_TEST_CASE_TEMPLATE(copy_move_on_simplex_tree, typeST, list_of_tested_variants) {
+ typedef std::vector<Vertex_handle> typeVectorVertex;
std::cout << "********************************************************************" << std::endl;
std::cout << "TEST COPY MOVE CONSTRUCTORS" << std::endl;
typeST st;
@@ -744,3 +759,39 @@ BOOST_AUTO_TEST_CASE(copy_move_on_simplex_tree) {
std::cout << "Printing st once again- address = " << &st << std::endl;
}
+
+template<class typeST>
+void test_simplex_is_vertex(typeST& st, typename typeST::Simplex_handle sh, typename typeST::Vertex_handle v) {
+ BOOST_CHECK(st.dimension(sh) == 0);
+ auto&& r = st.simplex_vertex_range(sh);
+ auto i = std::begin(r);
+ BOOST_CHECK(*i == v);
+ BOOST_CHECK(++i == std::end(r));
+}
+
+BOOST_AUTO_TEST_CASE(non_contiguous) {
+ typedef Simplex_tree<> typeST;
+ typedef typeST::Vertex_handle Vertex_handle;
+ typedef typeST::Simplex_handle Simplex_handle;
+ std::cout << "********************************************************************" << std::endl;
+ std::cout << "TEST NON-CONTIGUOUS VERTICES" << std::endl;
+ typeST st;
+ Vertex_handle e[] = {3,-7};
+ std::cout << "Insert" << std::endl;
+ st.insert_simplex_and_subfaces(e);
+ BOOST_CHECK(st.num_vertices() == 2);
+ BOOST_CHECK(st.num_simplices() == 3);
+ std::cout << "Find" << std::endl;
+ Simplex_handle sh = st.find(e);
+ BOOST_CHECK(sh != st.null_simplex());
+ std::cout << "Endpoints" << std::endl;
+ auto p = st.endpoints(sh);
+ test_simplex_is_vertex(st, p.first, 3);
+ test_simplex_is_vertex(st, p.second, -7);
+ std::cout << "Boundary" << std::endl;
+ auto&& b = st.boundary_simplex_range(sh);
+ auto i = std::begin(b);
+ test_simplex_is_vertex(st, *i, -7);
+ test_simplex_is_vertex(st, *++i, 3);
+ BOOST_CHECK(++i == std::end(b));
+}
diff --git a/src/Skeleton_blocker/example/Skeleton_blocker_from_simplices.cpp b/src/Skeleton_blocker/example/Skeleton_blocker_from_simplices.cpp
index 2738c01c..5935a56d 100644
--- a/src/Skeleton_blocker/example/Skeleton_blocker_from_simplices.cpp
+++ b/src/Skeleton_blocker/example/Skeleton_blocker_from_simplices.cpp
@@ -35,24 +35,23 @@ using namespace skbl;
typedef Skeleton_blocker_complex<Skeleton_blocker_simple_traits> Complex;
typedef Complex::Vertex_handle Vertex_handle;
-typedef Complex::Simplex_handle Simplex_handle;
-typedef Complex::Simplex_handle Simplex;
+typedef Complex::Simplex Simplex;
int main(int argc, char *argv[]) {
- std::vector<Simplex_handle> simplices;
+ std::vector<Simplex> simplices;
// add 4 triangles of a tetrahedron 0123
- simplices.push_back(Simplex_handle(Vertex_handle(0), Vertex_handle(1), Vertex_handle(2)));
- simplices.push_back(Simplex_handle(Vertex_handle(1), Vertex_handle(2), Vertex_handle(3)));
- simplices.push_back(Simplex_handle(Vertex_handle(3), Vertex_handle(0), Vertex_handle(2)));
- simplices.push_back(Simplex_handle(Vertex_handle(3), Vertex_handle(0), Vertex_handle(1)));
+ simplices.push_back(Simplex(Vertex_handle(0), Vertex_handle(1), Vertex_handle(2)));
+ simplices.push_back(Simplex(Vertex_handle(1), Vertex_handle(2), Vertex_handle(3)));
+ simplices.push_back(Simplex(Vertex_handle(3), Vertex_handle(0), Vertex_handle(2)));
+ simplices.push_back(Simplex(Vertex_handle(3), Vertex_handle(0), Vertex_handle(1)));
// get complex from top faces
Complex complex(make_complex_from_top_faces<Complex>(simplices.begin(), simplices.end()));
std::cout << "Simplices:" << std::endl;
- for (const Simplex & s : complex.simplex_range())
+ for (const Simplex & s : complex.complex_simplex_range())
std::cout << s << " ";
std::cout << std::endl;
@@ -61,16 +60,16 @@ int main(int argc, char *argv[]) {
// now build a complex from its full list of simplices
simplices.clear();
- simplices.push_back(Simplex_handle(Vertex_handle(0)));
- simplices.push_back(Simplex_handle(Vertex_handle(1)));
- simplices.push_back(Simplex_handle(Vertex_handle(2)));
- simplices.push_back(Simplex_handle(Vertex_handle(0), Vertex_handle(1)));
- simplices.push_back(Simplex_handle(Vertex_handle(1), Vertex_handle(2)));
- simplices.push_back(Simplex_handle(Vertex_handle(2), Vertex_handle(0)));
+ simplices.push_back(Simplex(Vertex_handle(0)));
+ simplices.push_back(Simplex(Vertex_handle(1)));
+ simplices.push_back(Simplex(Vertex_handle(2)));
+ simplices.push_back(Simplex(Vertex_handle(0), Vertex_handle(1)));
+ simplices.push_back(Simplex(Vertex_handle(1), Vertex_handle(2)));
+ simplices.push_back(Simplex(Vertex_handle(2), Vertex_handle(0)));
complex = Complex(simplices.begin(), simplices.end());
std::cout << "Simplices:" << std::endl;
- for (const Simplex & s : complex.simplex_range())
+ for (const Simplex & s : complex.complex_simplex_range())
std::cout << s << " ";
std::cout << std::endl;
diff --git a/src/Skeleton_blocker/example/Skeleton_blocker_iteration.cpp b/src/Skeleton_blocker/example/Skeleton_blocker_iteration.cpp
index 69557694..41b5ee00 100644
--- a/src/Skeleton_blocker/example/Skeleton_blocker_iteration.cpp
+++ b/src/Skeleton_blocker/example/Skeleton_blocker_iteration.cpp
@@ -37,7 +37,7 @@ using namespace skbl;
typedef Skeleton_blocker_complex<Skeleton_blocker_simple_traits> Complex;
typedef Complex::Vertex_handle Vertex_handle;
-typedef Complex::Simplex_handle Simplex;
+typedef Complex::Simplex Simplex;
Complex build_complete_complex(int n) {
// build a full complex with n vertices and 2^n-1 simplices
@@ -46,8 +46,7 @@ Complex build_complete_complex(int n) {
complex.add_vertex();
for (int i = 0; i < n; i++)
for (int j = 0; j < i; j++)
- // note that add_edge, add the edge and all its cofaces
- complex.add_edge(Vertex_handle(i), Vertex_handle(j));
+ complex.add_edge_without_blockers(Vertex_handle(i), Vertex_handle(j));
return complex;
}
@@ -77,7 +76,7 @@ int main(int argc, char *argv[]) {
// we use a reference to a simplex instead of a copy
// value here because a simplex is a set of integers
// and copying it cost time
- for (const Simplex & s : complex.simplex_range()) {
+ for (const Simplex & s : complex.complex_simplex_range()) {
++num_simplices;
if (s.dimension() % 2 == 0)
euler += 1;
diff --git a/src/Skeleton_blocker/example/Skeleton_blocker_link.cpp b/src/Skeleton_blocker/example/Skeleton_blocker_link.cpp
index 002cbc49..698a8106 100644
--- a/src/Skeleton_blocker/example/Skeleton_blocker_link.cpp
+++ b/src/Skeleton_blocker/example/Skeleton_blocker_link.cpp
@@ -35,13 +35,16 @@ using namespace skbl;
typedef Skeleton_blocker_complex<Skeleton_blocker_simple_traits> Complex;
typedef Complex::Vertex_handle Vertex_handle;
typedef Complex::Root_vertex_handle Root_vertex_handle;
-typedef Complex::Simplex_handle Simplex;
+typedef Complex::Simplex Simplex;
int main(int argc, char *argv[]) {
// build a full complex with 4 vertices and 2^4-1 simplices
- // Initial vertices are (0,1,2,3,4)
- Simplex tetrahedron(Vertex_handle(0), Vertex_handle(1), Vertex_handle(2), Vertex_handle(3));
+
+ // Create a complex with four vertices (0,1,2,3)
Complex complex;
+
+ // Add a tetrahedron to this complex
+ Simplex tetrahedron(Vertex_handle(0), Vertex_handle(1), Vertex_handle(2), Vertex_handle(3));
complex.add_simplex(tetrahedron);
cout << "complex:" << complex.to_string() << endl;
@@ -61,7 +64,8 @@ int main(int argc, char *argv[]) {
// To access to the initial vertices eg (0,1,2,3,4), Root_vertex_handle must be used.
// For instance, to test if the link contains the vertex that was labeled i:
for (int i = 0; i < 5; ++i)
- cout << "link.contains_vertex(Root_vertex_handle(" << i << ")):" << link.contains_vertex(Root_vertex_handle(i)) << endl;
+ cout << "link.contains_vertex(Root_vertex_handle(" << i << ")):" <<
+ link.contains_vertex(Root_vertex_handle(i)) << endl;
return EXIT_SUCCESS;
}
diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker.h
index 3be480fd..615b3a81 100644
--- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker.h
+++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker.h
@@ -129,7 +129,7 @@ of a simplicial complex.
\code{.cpp}
typedef Skeleton_blocker_complex<Skeleton_blocker_simple_traits> Complex;
typedef Complex::Vertex_handle Vertex_handle;
- typedef Complex::Simplex_handle Simplex;
+ typedef Complex::Simplex Simplex;
const int n = 15;
@@ -139,8 +139,7 @@ of a simplicial complex.
complex.add_vertex();
for(int i=0;i<n;i++)
for(int j=0;j<i;j++)
- //note that add_edge adds the edge and all its cofaces
- complex.add_edge(Vertex_handle(i),Vertex_handle(j));
+ complex.add_edge_without_blockers(Vertex_handle(i),Vertex_handle(j));
// this is just to illustrate iterators, to count number of vertices
// or edges, complex.num_vertices() and complex.num_edges() are
@@ -159,7 +158,7 @@ of a simplicial complex.
// we use a reference to a simplex instead of a copy
// value here because a simplex is a set of integers
// and copying it cost time
- for(const Simplex & s : complex.simplex_range()){
+ for(const Simplex & s : complex.star_simplex_range()){
++num_simplices;
if(s.dimension()%2 == 0)
euler += 1;
@@ -182,20 +181,20 @@ The Euler Characteristic is 1
\subsection s Constructing a skeleton-blockers from a list of maximal faces or from a list of faces
\code{.cpp}
- std::vector<Simplex_handle> simplices;
+ std::vector<Simplex> simplices;
//add 4 triangles of a tetrahedron 0123
- simplices.push_back(Simplex_handle(Vertex_handle(0),Vertex_handle(1),Vertex_handle(2)));
- simplices.push_back(Simplex_handle(Vertex_handle(1),Vertex_handle(2),Vertex_handle(3)));
- simplices.push_back(Simplex_handle(Vertex_handle(3),Vertex_handle(0),Vertex_handle(2)));
- simplices.push_back(Simplex_handle(Vertex_handle(3),Vertex_handle(0),Vertex_handle(1)));
+ simplices.push_back(Simplex(Vertex_handle(0),Vertex_handle(1),Vertex_handle(2)));
+ simplices.push_back(Simplex(Vertex_handle(1),Vertex_handle(2),Vertex_handle(3)));
+ simplices.push_back(Simplex(Vertex_handle(3),Vertex_handle(0),Vertex_handle(2)));
+ simplices.push_back(Simplex(Vertex_handle(3),Vertex_handle(0),Vertex_handle(1)));
Complex complex;
//get complex from top faces
make_complex_from_top_faces(complex,simplices.begin(),simplices.end());
std::cout << "Simplices:"<<std::endl;
- for(const Simplex & s : complex.simplex_range())
+ for(const Simplex & s : complex.star_simplex_range())
std::cout << s << " ";
std::cout << std::endl;
@@ -204,16 +203,16 @@ The Euler Characteristic is 1
//now build a complex from its full list of simplices
simplices.clear();
- simplices.push_back(Simplex_handle(Vertex_handle(0)));
- simplices.push_back(Simplex_handle(Vertex_handle(1)));
- simplices.push_back(Simplex_handle(Vertex_handle(2)));
- simplices.push_back(Simplex_handle(Vertex_handle(0),Vertex_handle(1)));
- simplices.push_back(Simplex_handle(Vertex_handle(1),Vertex_handle(2)));
- simplices.push_back(Simplex_handle(Vertex_handle(2),Vertex_handle(0)));
+ simplices.push_back(Simplex(Vertex_handle(0)));
+ simplices.push_back(Simplex(Vertex_handle(1)));
+ simplices.push_back(Simplex(Vertex_handle(2)));
+ simplices.push_back(Simplex(Vertex_handle(0),Vertex_handle(1)));
+ simplices.push_back(Simplex(Vertex_handle(1),Vertex_handle(2)));
+ simplices.push_back(Simplex(Vertex_handle(2),Vertex_handle(0)));
complex = Complex(simplices.begin(),simplices.end());
std::cout << "Simplices:"<<std::endl;
- for(const Simplex & s : complex.simplex_range())
+ for(const Simplex & s : complex.star_simplex_range())
std::cout << s << " ";
std::cout << std::endl;
diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_complex_visitor.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_complex_visitor.h
index 72bdf4c9..4ade68e7 100644
--- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_complex_visitor.h
+++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_complex_visitor.h
@@ -41,7 +41,7 @@ class Skeleton_blocker_complex_visitor {
virtual void on_add_vertex(Vertex_handle) = 0;
virtual void on_remove_vertex(Vertex_handle) = 0;
- virtual void on_add_edge(Vertex_handle a, Vertex_handle b) = 0;
+ virtual void on_add_edge_without_blockers(Vertex_handle a, Vertex_handle b) = 0;
virtual void on_remove_edge(Vertex_handle a, Vertex_handle b) = 0;
/**
@@ -54,7 +54,7 @@ class Skeleton_blocker_complex_visitor {
* @brief Called when performing an edge contraction when
* an edge bx is replaced by an edge ax (not already present).
* Precisely, this methods is called this way in contract_edge :
- * add_edge(a,x)
+ * add_edge_without_blockers(a,x)
* on_swaped_edge(a,b,x)
* remove_edge(b,x)
*/
@@ -79,7 +79,7 @@ class Dummy_complex_visitor : public Skeleton_blocker_complex_visitor<
}
void on_remove_vertex(Vertex_handle) {
}
- void on_add_edge(Vertex_handle a, Vertex_handle b) {
+ void on_add_edge_without_blockers(Vertex_handle a, Vertex_handle b) {
}
void on_remove_edge(Vertex_handle a, Vertex_handle b) {
}
@@ -108,8 +108,8 @@ class Print_complex_visitor : public Skeleton_blocker_complex_visitor<
void on_remove_vertex(Vertex_handle v) {
std::cerr << "on_remove_vertex:" << v << std::endl;
}
- void on_add_edge(Vertex_handle a, Vertex_handle b) {
- std::cerr << "on_add_edge:" << a << "," << b << std::endl;
+ void on_add_edge_without_blockers(Vertex_handle a, Vertex_handle b) {
+ std::cerr << "on_add_edge_without_blockers:" << a << "," << b << std::endl;
}
void on_remove_edge(Vertex_handle a, Vertex_handle b) {
std::cerr << "on_remove_edge:" << a << "," << b << std::endl;
diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_link_superior.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_link_superior.h
index d39fa9f3..876bdba9 100644
--- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_link_superior.h
+++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_link_superior.h
@@ -44,13 +44,13 @@ class Skeleton_blocker_link_superior : public Skeleton_blocker_link_complex<
public:
typedef typename ComplexType::Vertex_handle Vertex_handle;
typedef typename ComplexType::Root_vertex_handle Root_vertex_handle;
- typedef typename ComplexType::Simplex_handle Simplex_handle;
+ typedef typename ComplexType::Simplex Simplex;
typedef typename ComplexType::Root_simplex_handle Root_simplex_handle;
typedef typename ComplexType::BlockerMap BlockerMap;
typedef typename ComplexType::BlockerPair BlockerPair;
typedef typename ComplexType::BlockerMapIterator BlockerMapIterator;
typedef typename ComplexType::BlockerMapConstIterator BlockerMapConstIterator;
- typedef typename ComplexType::Simplex_handle::Simplex_vertex_const_iterator AddressSimplexConstIterator;
+ typedef typename ComplexType::Simplex::Simplex_vertex_const_iterator AddressSimplexConstIterator;
typedef typename ComplexType::Root_simplex_handle::Simplex_vertex_const_iterator IdSimplexConstIterator;
Skeleton_blocker_link_superior()
@@ -58,7 +58,7 @@ class Skeleton_blocker_link_superior : public Skeleton_blocker_link_complex<
}
Skeleton_blocker_link_superior(const ComplexType & parent_complex,
- Simplex_handle& alpha_parent_adress)
+ Simplex& alpha_parent_adress)
: Skeleton_blocker_link_complex<ComplexType>(parent_complex,
alpha_parent_adress, true) {
}
diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_off_io.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_off_io.h
index ec000986..ad2d2f85 100644
--- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_off_io.h
+++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_off_io.h
@@ -61,7 +61,7 @@ class Skeleton_blocker_off_flag_visitor_reader {
if (!load_only_points_) {
for (size_t i = 0; i < face.size(); ++i)
for (size_t j = i + 1; j < face.size(); ++j) {
- complex_.add_edge(Vertex_handle(face[i]), Vertex_handle(face[j]));
+ complex_.add_edge_without_blockers(Vertex_handle(face[i]), Vertex_handle(face[j]));
}
}
}
@@ -76,12 +76,12 @@ template<typename Complex>
class Skeleton_blocker_off_visitor_reader {
Complex& complex_;
typedef typename Complex::Vertex_handle Vertex_handle;
- typedef typename Complex::Simplex_handle Simplex_handle;
+ typedef typename Complex::Simplex Simplex;
typedef typename Complex::Point Point;
const bool load_only_points_;
std::vector<Point> points_;
- std::vector<Simplex_handle> maximal_faces_;
+ std::vector<Simplex> maximal_faces_;
public:
explicit Skeleton_blocker_off_visitor_reader(Complex& complex, bool load_only_points = false) :
@@ -99,7 +99,7 @@ class Skeleton_blocker_off_visitor_reader {
void maximal_face(const std::vector<int>& face) {
if (!load_only_points_) {
- Simplex_handle s;
+ Simplex s;
for (auto x : face)
s.add_vertex(Vertex_handle(x));
maximal_faces_.emplace_back(s);
diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_simplex.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_simplex.h
index 0d838d50..714bf23c 100644
--- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_simplex.h
+++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_simplex.h
@@ -218,7 +218,7 @@ class Skeleton_blocker_simplex {
}
/**
- * Returns the first vertex of the (oriented) simplex.
+ * Returns the first and smallest vertex of the simplex.
*
* Be careful : assumes the simplex is non-empty.
*/
@@ -228,7 +228,7 @@ class Skeleton_blocker_simplex {
}
/**
- * Returns the last vertex of the (oriented) simplex.
+ * Returns the last and greatest vertex of the simplex.
*
* Be careful : assumes the simplex is non-empty.
*/
diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_sub_complex.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_sub_complex.h
index b33b9606..50a83345 100644
--- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_sub_complex.h
+++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_sub_complex.h
@@ -66,12 +66,12 @@ class Skeleton_blocker_sub_complex : public ComplexType {
public:
using ComplexType::add_vertex;
- using ComplexType::add_edge;
+ using ComplexType::add_edge_without_blockers;
using ComplexType::add_blocker;
typedef typename ComplexType::Vertex_handle Vertex_handle;
typedef typename ComplexType::Root_vertex_handle Root_vertex_handle;
- typedef typename ComplexType::Simplex_handle Simplex_handle;
+ typedef typename ComplexType::Simplex Simplex;
typedef typename ComplexType::Root_simplex_handle Root_simplex_handle;
protected:
@@ -109,11 +109,11 @@ class Skeleton_blocker_sub_complex : public ComplexType {
* It assumes that both vertices corresponding to v1_root and v2_root are present
* in the sub-complex.
*/
- void add_edge(Root_vertex_handle v1_root, Root_vertex_handle v2_root) {
+ void add_edge_without_blockers(Root_vertex_handle v1_root, Root_vertex_handle v2_root) {
auto v1_sub(this->get_address(v1_root));
auto v2_sub(this->get_address(v2_root));
assert(v1_sub && v2_sub);
- this->ComplexType::add_edge(*v1_sub, *v2_sub);
+ this->ComplexType::add_edge_without_blockers(*v1_sub, *v2_sub);
}
/**
@@ -124,7 +124,7 @@ class Skeleton_blocker_sub_complex : public ComplexType {
void add_blocker(const Root_simplex_handle& blocker_root) {
auto blocker_sub = this->get_address(blocker_root);
assert(blocker_sub);
- this->add_blocker(new Simplex_handle(*blocker_sub));
+ this->add_blocker(new Simplex(*blocker_sub));
}
public:
@@ -133,7 +133,7 @@ class Skeleton_blocker_sub_complex : public ComplexType {
* vertices of 'simplex'.
*/
void make_restricted_complex(const ComplexType & parent_complex,
- const Simplex_handle& simplex) {
+ const Simplex& simplex) {
this->clear();
// add vertices to the sub complex
for (auto x : simplex) {
@@ -145,11 +145,11 @@ class Skeleton_blocker_sub_complex : public ComplexType {
// add edges to the sub complex
for (auto x : simplex) {
// x_neigh is the neighbor of x intersected with vertices_simplex
- Simplex_handle x_neigh;
+ Simplex x_neigh;
parent_complex.add_neighbours(x, x_neigh, true);
x_neigh.intersection(simplex);
for (auto y : x_neigh) {
- this->add_edge(parent_complex[x].get_id(), parent_complex[y].get_id());
+ this->add_edge_without_blockers(parent_complex[x].get_id(), parent_complex[y].get_id());
}
}
@@ -158,9 +158,9 @@ class Skeleton_blocker_sub_complex : public ComplexType {
// check if it is the first time we encounter the blocker
if (simplex.contains(*blocker)) {
Root_simplex_handle blocker_root(parent_complex.get_id(*(blocker)));
- Simplex_handle blocker_restr(
+ Simplex blocker_restr(
*(this->get_simplex_address(blocker_root)));
- this->add_blocker(new Simplex_handle(blocker_restr));
+ this->add_blocker(new Simplex(blocker_restr));
}
}
}
@@ -188,7 +188,7 @@ class Skeleton_blocker_sub_complex : public ComplexType {
// * Allocates a simplex in L corresponding to the simplex s in K
// * with its local adresses and returns an AddressSimplex.
// */
- // boost::optional<Simplex_handle> get_address(const Root_simplex_handle & s) const;
+ // boost::optional<Simplex> get_address(const Root_simplex_handle & s) const;
// private:
/**
@@ -220,7 +220,7 @@ bool proper_face_in_union(
// we test that all vertices of 'addresses_sigma_in_link' but 'vertex_to_be_ignored'
// are in link1 if it is the case we construct the corresponding simplex
bool vertices_sigma_are_in_link = true;
- typename ComplexType::Simplex_handle sigma_in_link;
+ typename ComplexType::Simplex sigma_in_link;
for (int i = 0; i < addresses_sigma_in_link.size(); ++i) {
if (i != vertex_to_be_ignored) {
if (!addresses_sigma_in_link[i]) {
diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/internal/Trie.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/internal/Trie.h
index aa0416ef..499980c4 100644
--- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/internal/Trie.h
+++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/internal/Trie.h
@@ -36,7 +36,7 @@ namespace skbl {
template<typename SimplexHandle>
struct Trie {
- typedef SimplexHandle Simplex_handle;
+ typedef SimplexHandle Simplex;
typedef typename SimplexHandle::Vertex_handle Vertex_handle;
Vertex_handle v;
@@ -64,7 +64,7 @@ struct Trie {
}
}
- typedef typename Simplex_handle::Simplex_vertex_const_iterator Simplex_vertex_const_iterator;
+ typedef typename Simplex::Simplex_vertex_const_iterator Simplex_vertex_const_iterator;
Trie* make_trie(Simplex_vertex_const_iterator s_it, Simplex_vertex_const_iterator s_end) {
if (s_it == s_end) {
@@ -97,7 +97,7 @@ struct Trie {
return;
}
- void maximal_faces_helper(std::vector<Simplex_handle>& res) const {
+ void maximal_faces_helper(std::vector<Simplex>& res) const {
if (is_leaf()) res.push_back(simplex());
else
for (auto child : childs)
@@ -108,14 +108,14 @@ struct Trie {
/**
* adds the simplex to the trie
*/
- void add_simplex(const Simplex_handle& s) {
+ void add_simplex(const Simplex& s) {
if (s.empty()) return;
assert(v == s.first_vertex());
add_simplex_helper(s.begin(), s.end());
}
- std::vector<Simplex_handle> maximal_faces() const {
- std::vector<Simplex_handle> res;
+ std::vector<Simplex> maximal_faces() const {
+ std::vector<Simplex> res;
maximal_faces_helper(res);
return res;
}
@@ -123,14 +123,14 @@ struct Trie {
/**
* Goes to the root in the trie to consitute simplex
*/
- void add_vertices_up_to_the_root(Simplex_handle& res) const {
+ void add_vertices_up_to_the_root(Simplex& res) const {
res.add_vertex(v);
if (parent_)
parent_->add_vertices_up_to_the_root(res);
}
- Simplex_handle simplex() const {
- Simplex_handle res;
+ Simplex simplex() const {
+ Simplex res;
add_vertices_up_to_the_root(res);
return res;
}
@@ -156,7 +156,7 @@ struct Trie {
/**
* true iff the simplex corresponds to one node in the trie
*/
- bool contains(const Simplex_handle& s) const {
+ bool contains(const Simplex& s) const {
Trie const* current = this;
if (s.empty()) return true;
if (current->v != s.first_vertex()) return false;
@@ -196,9 +196,9 @@ struct Trie {
template<typename SimplexHandle>
struct Tries {
typedef typename SimplexHandle::Vertex_handle Vertex_handle;
- typedef SimplexHandle Simplex_handle;
+ typedef SimplexHandle Simplex;
- typedef Trie<Simplex_handle> STrie;
+ typedef Trie<Simplex> STrie;
template<typename SimpleHandleOutputIterator>
Tries(unsigned num_vertices, SimpleHandleOutputIterator simplex_begin, SimpleHandleOutputIterator simplex_end) :
@@ -218,14 +218,14 @@ struct Tries {
// return a simplex that consists in all u such uv is an edge and u>v
- Simplex_handle positive_neighbors(Vertex_handle v) const {
- Simplex_handle res;
+ Simplex positive_neighbors(Vertex_handle v) const {
+ Simplex res;
for (auto child : cofaces_[v]->childs)
res.add_vertex(child->v);
return res;
}
- bool contains(const Simplex_handle& s) const {
+ bool contains(const Simplex& s) const {
auto first_v = s.first_vertex();
return cofaces_[first_v]->contains(s);
}
@@ -238,8 +238,8 @@ struct Tries {
// init_next_dimension must be called first
- std::vector<Simplex_handle> next_dimension_simplices() const {
- std::vector<Simplex_handle> res;
+ std::vector<Simplex> next_dimension_simplices() const {
+ std::vector<Simplex> res;
while (!to_see_.empty() && to_see_.front()->simplex().dimension() == current_dimension_) {
res.emplace_back(to_see_.front()->simplex());
for (auto child : to_see_.front()->childs)
diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_blockers_iterators.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_blockers_iterators.h
index 56a20a24..4a437ac6 100644
--- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_blockers_iterators.h
+++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_blockers_iterators.h
@@ -31,7 +31,7 @@ namespace skbl {
/**
* @brief Iterator through the blockers of a vertex.
*/
-// ReturnType = const Simplex_handle* or Simplex_handle*
+// ReturnType = const Simplex* or Simplex*
// MapIteratorType = BlockerMapConstIterator or BlockerMapIterator
template<typename MapIteratorType, typename ReturnType>
@@ -83,7 +83,7 @@ ReturnType
/**
* @brief Iterator through the blockers of a vertex
*/
-// ReturnType = const Simplex_handle* or Simplex_handle*
+// ReturnType = const Simplex* or Simplex*
// MapIteratorType = BlockerMapConstIterator or BlockerMapIterator
template<typename MapIteratorType, typename ReturnType>
diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_simplices_iterators.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_simplices_iterators.h
index 4d71b3f5..ce565166 100644
--- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_simplices_iterators.h
+++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_simplices_iterators.h
@@ -48,20 +48,20 @@ namespace skbl {
template<typename SkeletonBlockerComplex, typename Link>
class Simplex_around_vertex_iterator :
public boost::iterator_facade < Simplex_around_vertex_iterator<SkeletonBlockerComplex, Link>
-, typename SkeletonBlockerComplex::Simplex_handle
+, typename SkeletonBlockerComplex::Simplex
, boost::forward_traversal_tag
-, typename SkeletonBlockerComplex::Simplex_handle
+, typename SkeletonBlockerComplex::Simplex
> {
friend class boost::iterator_core_access;
typedef SkeletonBlockerComplex Complex;
typedef typename Complex::Vertex_handle Vertex_handle;
typedef typename Complex::Edge_handle Edge_handle;
- typedef typename Complex::Simplex_handle Simplex_handle;
+ typedef typename Complex::Simplex Simplex;
// Link_vertex_handle == Complex_Vertex_handle but this renaming helps avoiding confusion
typedef typename Link::Vertex_handle Link_vertex_handle;
- typedef typename Gudhi::skbl::Trie<Simplex_handle> Trie;
+ typedef typename Gudhi::skbl::Trie<Simplex> Trie;
private:
const Complex* complex;
@@ -120,7 +120,7 @@ public boost::iterator_facade < Simplex_around_vertex_iterator<SkeletonBlockerCo
Trie* res = new Trie(parent_vertex(link_vh), parent);
for (Link_vertex_handle nv : link_v->vertex_range(link_vh)) {
if (link_vh < nv) {
- Simplex_handle simplex_node_plus_nv(res->simplex());
+ Simplex simplex_node_plus_nv(res->simplex());
simplex_node_plus_nv.add_vertex(parent_vertex(nv));
if (complex->contains(simplex_node_plus_nv)) {
res->add_child(build_trie(nv, res));
@@ -176,13 +176,13 @@ public boost::iterator_facade < Simplex_around_vertex_iterator<SkeletonBlockerCo
}
}
- Simplex_handle dereference() const {
+ Simplex dereference() const {
assert(!nodes_to_be_seen.empty());
Trie* first_node = nodes_to_be_seen.front();
return first_node->simplex();
}
- Simplex_handle get_trie_address() const {
+ Simplex get_trie_address() const {
assert(!nodes_to_be_seen.empty());
return nodes_to_be_seen.front();
}
@@ -200,9 +200,9 @@ public boost::iterator_facade < Simplex_around_vertex_iterator<SkeletonBlockerCo
template<typename SkeletonBlockerComplex>
class Simplex_iterator :
public boost::iterator_facade < Simplex_iterator<SkeletonBlockerComplex>
-, typename SkeletonBlockerComplex::Simplex_handle
+, typename SkeletonBlockerComplex::Simplex
, boost::forward_traversal_tag
-, typename SkeletonBlockerComplex::Simplex_handle
+, typename SkeletonBlockerComplex::Simplex
> {
typedef Skeleton_blocker_link_superior<SkeletonBlockerComplex> Link;
@@ -213,7 +213,7 @@ public boost::iterator_facade < Simplex_iterator<SkeletonBlockerComplex>
typedef SkeletonBlockerComplex Complex;
typedef typename Complex::Vertex_handle Vertex_handle;
typedef typename Complex::Edge_handle Edge_handle;
- typedef typename Complex::Simplex_handle Simplex_handle;
+ typedef typename Complex::Simplex Simplex;
typedef typename Complex::Complex_vertex_iterator Complex_vertex_iterator;
typedef typename Link::Vertex_handle Link_vertex_handle;
@@ -290,7 +290,7 @@ public boost::iterator_facade < Simplex_iterator<SkeletonBlockerComplex>
}
}
- Simplex_handle dereference() const {
+ Simplex dereference() const {
return current_simplex_around_current_vertex_.dereference();
}
@@ -304,6 +304,93 @@ public boost::iterator_facade < Simplex_iterator<SkeletonBlockerComplex>
}
};
+/**
+ * Iterator through the maximal faces of the coboundary of a simplex.
+ */
+template<typename SkeletonBlockerComplex, typename Link>
+class Simplex_coboundary_iterator :
+public boost::iterator_facade < Simplex_coboundary_iterator<SkeletonBlockerComplex, Link>
+, typename SkeletonBlockerComplex::Simplex, boost::forward_traversal_tag, typename SkeletonBlockerComplex::Simplex> {
+ friend class boost::iterator_core_access;
+ typedef SkeletonBlockerComplex Complex;
+ typedef typename Complex::Vertex_handle Vertex_handle;
+ typedef typename Complex::Edge_handle Edge_handle;
+ typedef typename Complex::Simplex Simplex;
+ typedef typename Complex::Complex_vertex_iterator Complex_vertex_iterator;
+
+ // Link_vertex_handle == Complex_Vertex_handle but this renaming helps avoiding confusion
+ typedef typename Link::Vertex_handle Link_vertex_handle;
+
+ private:
+ const Complex* complex;
+ const Simplex& sigma;
+ std::shared_ptr<Link> link;
+ Complex_vertex_iterator current_vertex;
+ Complex_vertex_iterator link_vertex_end;
+
+ public:
+ Simplex_coboundary_iterator() : complex(0) {}
+
+ Simplex_coboundary_iterator(const Complex* complex_, const Simplex& sigma_) :
+ complex(complex_),
+ sigma(sigma_),
+ //need only vertices of the link hence the true flag
+ link(new Link(*complex_, sigma_, false, true)) {
+ auto link_vertex_range = link->vertex_range();
+ current_vertex = link_vertex_range.begin();
+ link_vertex_end = link_vertex_range.end();
+ }
+
+ Simplex_coboundary_iterator(const Simplex_coboundary_iterator& other) :
+ complex(other.complex),
+ sigma(other.sigma),
+ link(other.link),
+ current_vertex(other.current_vertex),
+ link_vertex_end(other.link_vertex_end) { }
+
+ // returns an iterator to the end
+ Simplex_coboundary_iterator(const Complex* complex_,const Simplex& sigma_, bool end) :
+ complex(complex_),
+ sigma(sigma_) {
+ // to represent an end iterator without having to build a useless link, we use
+ // the convection that link is not initialized.
+ }
+
+ private:
+ Vertex_handle parent_vertex(Link_vertex_handle link_vh) const {
+ return complex->convert_handle_from_another_complex(*link, link_vh);
+ }
+
+public:
+ friend std::ostream& operator<<(std::ostream& stream, const Simplex_coboundary_iterator& sci) {
+ return stream;
+ }
+
+ // assume that iterator points to the same complex and comes from the same simplex
+ bool equal(const Simplex_coboundary_iterator& other) const {
+ assert(complex == other.complex && sigma == other.sigma);
+ if(is_end()) return other.is_end();
+ if(other.is_end()) return is_end();
+ return *current_vertex == *(other.current_vertex);
+ }
+
+ void increment() {
+ ++current_vertex;
+ }
+
+ Simplex dereference() const {
+ Simplex res(sigma);
+ res.add_vertex(parent_vertex(*current_vertex));
+ return res;
+ }
+
+private:
+ bool is_end() const {
+ return !link || current_vertex == link_vertex_end;
+ }
+};
+
+
} // namespace skbl
} // namespace Gudhi
diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_triangles_iterators.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_triangles_iterators.h
index 28f5805d..116023d7 100644
--- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_triangles_iterators.h
+++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_triangles_iterators.h
@@ -37,15 +37,15 @@ namespace skbl {
template<typename Complex, typename LinkType>
class Triangle_around_vertex_iterator : public boost::iterator_facade
< Triangle_around_vertex_iterator <Complex, LinkType>
-, typename Complex::Simplex_handle const
+, typename Complex::Simplex const
, boost::forward_traversal_tag
-, typename Complex::Simplex_handle const> {
+, typename Complex::Simplex const> {
friend class boost::iterator_core_access;
template<typename T> friend class Triangle_iterator;
private:
typedef typename LinkType::Vertex_handle Vertex_handle;
typedef typename LinkType::Root_vertex_handle Root_vertex_handle;
- typedef typename LinkType::Simplex_handle Simplex_handle;
+ typedef typename LinkType::Simplex Simplex;
typedef typename Complex::Complex_edge_iterator Complex_edge_iterator_;
const Complex* complex_;
@@ -87,10 +87,10 @@ class Triangle_around_vertex_iterator : public boost::iterator_facade
return (complex_ == other.complex_) && ((finished() && other.finished()) || current_edge_ == other.current_edge_);
}
- Simplex_handle dereference() const {
+ Simplex dereference() const {
Root_vertex_handle v1 = (*link_)[*current_edge_].first();
Root_vertex_handle v2 = (*link_)[*current_edge_].second();
- return Simplex_handle(v_, *(complex_->get_address(v1)), *(complex_->get_address(v2)));
+ return Simplex(v_, *(complex_->get_address(v1)), *(complex_->get_address(v2)));
}
void increment() {
@@ -112,14 +112,14 @@ class Triangle_around_vertex_iterator : public boost::iterator_facade
template<typename SkeletonBlockerComplex>
class Triangle_iterator : public boost::iterator_facade<
Triangle_iterator <SkeletonBlockerComplex>,
-typename SkeletonBlockerComplex::Simplex_handle const
+typename SkeletonBlockerComplex::Simplex const
, boost::forward_traversal_tag
-, typename SkeletonBlockerComplex::Simplex_handle const> {
+, typename SkeletonBlockerComplex::Simplex const> {
friend class boost::iterator_core_access;
private:
typedef typename SkeletonBlockerComplex::Vertex_handle Vertex_handle;
typedef typename SkeletonBlockerComplex::Root_vertex_handle Root_vertex_handle;
- typedef typename SkeletonBlockerComplex::Simplex_handle Simplex_handle;
+ typedef typename SkeletonBlockerComplex::Simplex Simplex;
typedef typename SkeletonBlockerComplex::Superior_triangle_around_vertex_iterator STAVI;
typedef typename SkeletonBlockerComplex::Complex_vertex_iterator Complex_vertex_iterator;
@@ -175,7 +175,7 @@ typename SkeletonBlockerComplex::Simplex_handle const
current_vertex_ == other.current_vertex_ && current_triangle_ == other.current_triangle_));
}
- Simplex_handle dereference() const {
+ Simplex dereference() const {
return *current_triangle_;
}
diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_complex.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_complex.h
index d26d12b0..5b774f25 100644
--- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_complex.h
+++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_complex.h
@@ -28,11 +28,9 @@
#include <gudhi/Skeleton_blocker/Skeleton_blocker_link_superior.h>
#include <gudhi/Skeleton_blocker/Skeleton_blocker_sub_complex.h>
#include <gudhi/Skeleton_blocker/Skeleton_blocker_simplex.h>
-
#include <gudhi/Skeleton_blocker/Skeleton_blocker_complex_visitor.h>
#include <gudhi/Skeleton_blocker/internal/Top_faces.h>
#include <gudhi/Skeleton_blocker/internal/Trie.h>
-
#include <gudhi/Utils.h>
#include <boost/graph/adjacency_list.hpp>
@@ -94,16 +92,16 @@ class Skeleton_blocker_complex {
/**
* @brief A ordered set of integers that represents a simplex.
*/
- typedef Skeleton_blocker_simplex<Vertex_handle> Simplex_handle;
+ typedef Skeleton_blocker_simplex<Vertex_handle> Simplex;
typedef Skeleton_blocker_simplex<Root_vertex_handle> Root_simplex_handle;
/**
* @brief Handle to a blocker of the complex.
*/
- typedef Simplex_handle* Blocker_handle;
+ typedef Simplex* Blocker_handle;
typedef typename Root_simplex_handle::Simplex_vertex_const_iterator Root_simplex_iterator;
- typedef typename Simplex_handle::Simplex_vertex_const_iterator Simplex_handle_iterator;
+ typedef typename Simplex::Simplex_vertex_const_iterator Simplex_handle_iterator;
protected:
typedef typename boost::adjacency_list<boost::setS, // edges
@@ -128,14 +126,14 @@ class Skeleton_blocker_complex {
typedef typename boost::graph_traits<Graph>::edge_descriptor Edge_handle;
protected:
- typedef std::multimap<Vertex_handle, Simplex_handle *> BlockerMap;
- typedef typename std::multimap<Vertex_handle, Simplex_handle *>::value_type BlockerPair;
- typedef typename std::multimap<Vertex_handle, Simplex_handle *>::iterator BlockerMapIterator;
- typedef typename std::multimap<Vertex_handle, Simplex_handle *>::const_iterator BlockerMapConstIterator;
+ typedef std::multimap<Vertex_handle, Simplex *> BlockerMap;
+ typedef typename std::multimap<Vertex_handle, Simplex *>::value_type BlockerPair;
+ typedef typename std::multimap<Vertex_handle, Simplex *>::iterator BlockerMapIterator;
+ typedef typename std::multimap<Vertex_handle, Simplex *>::const_iterator BlockerMapConstIterator;
protected:
- int num_vertices_;
- int num_blockers_;
+ size_t num_vertices_;
+ size_t num_blockers_;
typedef Skeleton_blocker_complex_visitor<Vertex_handle> Visitor;
// typedef Visitor* Visitor_ptr;
@@ -164,17 +162,17 @@ class Skeleton_blocker_complex {
/**
*@brief constructs a simplicial complex with a given number of vertices and a visitor.
*/
- explicit Skeleton_blocker_complex(int num_vertices_ = 0, Visitor* visitor_ = NULL)
+ explicit Skeleton_blocker_complex(size_t num_vertices_ = 0, Visitor* visitor_ = NULL)
: visitor(visitor_) {
clear();
- for (int i = 0; i < num_vertices_; ++i) {
+ for (size_t i = 0; i < num_vertices_; ++i) {
add_vertex();
}
}
private:
// typedef Trie<Skeleton_blocker_complex<SkeletonBlockerDS>> STrie;
- typedef Trie<Simplex_handle> STrie;
+ typedef Trie<Simplex> STrie;
public:
/**
@@ -182,37 +180,41 @@ class Skeleton_blocker_complex {
* @details is_flag_complex indicates if the complex is a flag complex or not (to know if blockers have to be computed or not).
*/
template<typename SimpleHandleOutputIterator>
- Skeleton_blocker_complex(SimpleHandleOutputIterator simplex_begin, SimpleHandleOutputIterator simplex_end,
+ Skeleton_blocker_complex(SimpleHandleOutputIterator simplices_begin, SimpleHandleOutputIterator simplices_end,
bool is_flag_complex = false, Visitor* visitor_ = NULL)
: num_vertices_(0),
num_blockers_(0),
visitor(visitor_) {
- add_vertex_and_edges(simplex_begin, simplex_end);
+ add_vertices_and_edges(simplices_begin, simplices_end);
if (!is_flag_complex)
// need to compute blockers
- add_blockers(simplex_begin, simplex_end);
+ add_blockers(simplices_begin, simplices_end);
}
private:
+ /**
+ * Add vertices and edges of a simplex in one pass
+ */
template<typename SimpleHandleOutputIterator>
- void add_vertex_and_edges(SimpleHandleOutputIterator simplex_begin, SimpleHandleOutputIterator simplex_end) {
+ void add_vertices_and_edges(SimpleHandleOutputIterator simplices_begin, SimpleHandleOutputIterator simplices_end) {
std::vector<std::pair<Vertex_handle, Vertex_handle>> edges;
// first pass to add vertices and edges
int num_vertex = -1;
- for (auto s_it = simplex_begin; s_it != simplex_end; ++s_it) {
+ for (auto s_it = simplices_begin; s_it != simplices_end; ++s_it) {
if (s_it->dimension() == 0) num_vertex = (std::max)(num_vertex, s_it->first_vertex().vertex);
if (s_it->dimension() == 1) edges.emplace_back(s_it->first_vertex(), s_it->last_vertex());
}
while (num_vertex-- >= 0) add_vertex();
for (const auto& e : edges)
- add_edge(e.first, e.second);
+ add_edge_without_blockers(e.first, e.second);
}
+
template<typename SimpleHandleOutputIterator>
- void add_blockers(SimpleHandleOutputIterator simplex_begin, SimpleHandleOutputIterator simplex_end) {
- Tries<Simplex_handle> tries(num_vertices(), simplex_begin, simplex_end);
+ void add_blockers(SimpleHandleOutputIterator simplices_begin, SimpleHandleOutputIterator simplices_end) {
+ Tries<Simplex> tries(num_vertices(), simplices_begin, simplices_end);
tries.init_next_dimension();
auto simplices(tries.next_dimension_simplices());
@@ -221,7 +223,7 @@ class Skeleton_blocker_complex {
for (auto& sigma : simplices) {
// common_positive_neighbors is the set of vertices u such that
// for all s in sigma, us is an edge and u>s
- Simplex_handle common_positive_neighbors(tries.positive_neighbors(sigma.last_vertex()));
+ Simplex common_positive_neighbors(tries.positive_neighbors(sigma.last_vertex()));
for (auto sigma_it = sigma.rbegin(); sigma_it != sigma.rend(); ++sigma_it)
if (sigma_it != sigma.rbegin())
common_positive_neighbors.intersection(tries.positive_neighbors(*sigma_it));
@@ -378,6 +380,7 @@ class Skeleton_blocker_complex {
/**
* @brief Adds a vertex to the simplicial complex and returns its Vertex_handle.
+ * @remark Vertex representation is contiguous.
*/
Vertex_handle add_vertex() {
Vertex_handle address(boost::add_vertex(skeleton));
@@ -427,7 +430,7 @@ class Skeleton_blocker_complex {
* @return true iff the simplicial complex contains all vertices
* of simplex sigma
*/
- bool contains_vertices(const Simplex_handle & sigma) const {
+ bool contains_vertices(const Simplex & sigma) const {
for (auto vertex : sigma)
if (!contains_vertex(vertex))
return false;
@@ -535,41 +538,68 @@ class Skeleton_blocker_complex {
* @details it assumes that the edge is present in the complex
*/
- Simplex_handle get_vertices(Edge_handle edge_handle) const {
+ Simplex get_vertices(Edge_handle edge_handle) const {
auto edge((*this)[edge_handle]);
- return Simplex_handle((*this)[edge.first()], (*this)[edge.second()]);
+ return Simplex((*this)[edge.first()], (*this)[edge.second()]);
}
/**
- * @brief Adds an edge between vertices a and b and all its cofaces.
+ * @brief Adds an edge between vertices a and b.
+ * @details For instance, the complex contains edge 01 and 12, then calling
+ * add_edge with vertex 0 and 2 will create a complex containing
+ * the edges 01, 12, 20 but not the triangle 012 (and hence this complex
+ * will contains a blocker 012).
*/
Edge_handle add_edge(Vertex_handle a, Vertex_handle b) {
+ // if the edge is already there we musnt go further
+ // as we may add blockers that should not be here
+ if (contains_edge(a, b))
+ return *((*this)[std::make_pair(a, b)]);
+ auto res = add_edge_without_blockers(a, b);
+ add_blockers_after_simplex_insertion(Simplex(a, b));
+ return res;
+ }
+
+ /**
+ * @brief Adds all edges of s in the complex.
+ */
+ void add_edge(const Simplex& s) {
+ for (auto i = s.begin(); i != s.end(); ++i)
+ for (auto j = i; ++j != s.end(); /**/)
+ add_edge(*i, *j);
+ }
+
+ /**
+ * @brief Adds an edge between vertices a and b without blockers.
+ * @details For instance, the complex contains edge 01 and 12, then calling
+ * add_edge with vertex 0 and 2 will create a complex containing
+ * the triangle 012.
+ */
+ Edge_handle add_edge_without_blockers(Vertex_handle a, Vertex_handle b) {
assert(contains_vertex(a) && contains_vertex(b));
assert(a != b);
auto edge_handle((*this)[std::make_pair(a, b)]);
- // std::pair<Edge_handle,bool> pair_descr_bool = (*this)[std::make_pair(a,b)];
- // Edge_handle edge_descr;
- // bool edge_present = pair_descr_bool.second;
if (!edge_handle) {
edge_handle = boost::add_edge(a.vertex, b.vertex, skeleton).first;
(*this)[*edge_handle].setId(get_id(a), get_id(b));
degree_[a.vertex]++;
degree_[b.vertex]++;
if (visitor)
- visitor->on_add_edge(a, b);
+ visitor->on_add_edge_without_blockers(a, b);
}
return *edge_handle;
}
+
/**
- * @brief Adds all edges and their cofaces of a simplex to the simplicial complex.
+ * @brief Adds all edges of s in the complex without adding blockers.
*/
- void add_edges(const Simplex_handle & sigma) {
- Simplex_handle_iterator i, j;
- for (i = sigma.begin(); i != sigma.end(); ++i)
- for (j = i, j++; j != sigma.end(); ++j)
- add_edge(*i, *j);
+ void add_edge_without_blockers(Simplex s) {
+ for (auto i = s.begin(); i != s.end(); ++i) {
+ for (auto j = i; ++j != s.end(); /**/)
+ add_edge_without_blockers(*i, *j);
+ }
}
/**
@@ -627,7 +657,7 @@ class Skeleton_blocker_complex {
* @return true iff the simplicial complex contains all vertices
* and all edges of simplex sigma
*/
- bool contains_edges(const Simplex_handle & sigma) const {
+ bool contains_edges(const Simplex & sigma) const {
for (auto i = sigma.begin(); i != sigma.end(); ++i) {
if (!contains_vertex(*i))
return false;
@@ -649,15 +679,14 @@ class Skeleton_blocker_complex {
* @brief Adds the simplex to the set of blockers and
* returns a Blocker_handle toward it if was not present before and 0 otherwise.
*/
- Blocker_handle add_blocker(const Simplex_handle& blocker) {
+ Blocker_handle add_blocker(const Simplex& blocker) {
assert(blocker.dimension() > 1);
if (contains_blocker(blocker)) {
- // std::cerr << "ATTEMPT TO ADD A BLOCKER ALREADY THERE ---> BLOCKER IGNORED" << endl;
return 0;
} else {
if (visitor)
visitor->on_add_blocker(blocker);
- Blocker_handle blocker_pt = new Simplex_handle(blocker);
+ Blocker_handle blocker_pt = new Simplex(blocker);
num_blockers_++;
auto vertex = blocker_pt->begin();
while (vertex != blocker_pt->end()) {
@@ -739,7 +768,7 @@ class Skeleton_blocker_complex {
*
* @remark contrarily to delete_blockers does not call the destructor
*/
- void remove_blocker(const Simplex_handle& sigma) {
+ void remove_blocker(const Simplex& sigma) {
assert(contains_blocker(sigma));
for (auto vertex : sigma)
remove_blocker(sigma, vertex);
@@ -777,7 +806,7 @@ class Skeleton_blocker_complex {
/**
* @return true iff s is a blocker of the simplicial complex
*/
- bool contains_blocker(const Simplex_handle & s) const {
+ bool contains_blocker(const Simplex & s) const {
if (s.dimension() < 2)
return false;
@@ -795,7 +824,7 @@ class Skeleton_blocker_complex {
* @return true iff a blocker of the simplicial complex
* is a face of sigma.
*/
- bool blocks(const Simplex_handle & sigma) const {
+ bool blocks(const Simplex & sigma) const {
for (auto s : sigma)
for (auto blocker : const_blocker_range(s))
if (sigma.contains(*blocker))
@@ -810,7 +839,7 @@ class Skeleton_blocker_complex {
* @details Adds to simplex the neighbours of v e.g. \f$ n \leftarrow n \cup N(v) \f$.
* If keep_only_superior is true then only vertices that are greater than v are added.
*/
- virtual void add_neighbours(Vertex_handle v, Simplex_handle & n,
+ virtual void add_neighbours(Vertex_handle v, Simplex & n,
bool keep_only_superior = false) const {
boost_adjacency_iterator ai, ai_end;
for (tie(ai, ai_end) = adjacent_vertices(v.vertex, skeleton); ai != ai_end;
@@ -833,7 +862,7 @@ class Skeleton_blocker_complex {
* todo revoir
*
*/
- virtual void add_neighbours(const Simplex_handle &alpha, Simplex_handle & res,
+ virtual void add_neighbours(const Simplex &alpha, Simplex & res,
bool keep_only_superior = false) const {
res.clear();
auto alpha_vertex = alpha.begin();
@@ -848,9 +877,9 @@ class Skeleton_blocker_complex {
* not neighbours of v e.g. \f$ res \leftarrow res \cap N(v) \f$.
* If 'keep_only_superior' is true then only vertices that are greater than v are keeped.
*/
- virtual void keep_neighbours(Vertex_handle v, Simplex_handle& res,
+ virtual void keep_neighbours(Vertex_handle v, Simplex& res,
bool keep_only_superior = false) const {
- Simplex_handle nv;
+ Simplex nv;
add_neighbours(v, nv, keep_only_superior);
res.intersection(nv);
}
@@ -860,9 +889,9 @@ class Skeleton_blocker_complex {
* neighbours of v eg \f$ res \leftarrow res \setminus N(v) \f$.
* If 'keep_only_superior' is true then only vertices that are greater than v are added.
*/
- virtual void remove_neighbours(Vertex_handle v, Simplex_handle & res,
+ virtual void remove_neighbours(Vertex_handle v, Simplex & res,
bool keep_only_superior = false) const {
- Simplex_handle nv;
+ Simplex nv;
add_neighbours(v, nv, keep_only_superior);
res.difference(nv);
}
@@ -874,7 +903,7 @@ class Skeleton_blocker_complex {
* Constructs the link of 'simplex' with points coordinates.
*/
Link_complex link(Vertex_handle v) const {
- return Link_complex(*this, Simplex_handle(v));
+ return Link_complex(*this, Simplex(v));
}
/**
@@ -887,7 +916,7 @@ class Skeleton_blocker_complex {
/**
* Constructs the link of 'simplex' with points coordinates.
*/
- Link_complex link(const Simplex_handle& simplex) const {
+ Link_complex link(const Simplex& simplex) const {
return Link_complex(*this, simplex);
}
@@ -899,11 +928,11 @@ class Skeleton_blocker_complex {
*/
// xxx rename get_address et place un using dans sub_complex
- boost::optional<Simplex_handle> get_simplex_address(
+ boost::optional<Simplex> get_simplex_address(
const Root_simplex_handle& s) const {
- boost::optional<Simplex_handle> res;
+ boost::optional<Simplex> res;
- Simplex_handle s_address;
+ Simplex s_address;
// Root_simplex_const_iterator i;
for (auto i = s.begin(); i != s.end(); ++i) {
boost::optional<Vertex_handle> address = get_address(*i);
@@ -920,7 +949,7 @@ class Skeleton_blocker_complex {
* @brief returns a simplex with vertices which are the id of vertices of the
* argument.
*/
- Root_simplex_handle get_id(const Simplex_handle& local_simplex) const {
+ Root_simplex_handle get_id(const Simplex& local_simplex) const {
Root_simplex_handle global_simplex;
for (auto x = local_simplex.begin(); x != local_simplex.end(); ++x) {
global_simplex.add_vertex(get_id(*x));
@@ -932,7 +961,7 @@ class Skeleton_blocker_complex {
* @brief returns true iff the simplex s belongs to the simplicial
* complex.
*/
- virtual bool contains(const Simplex_handle & s) const {
+ virtual bool contains(const Simplex & s) const {
if (s.dimension() == -1) {
return false;
} else if (s.dimension() == 0) {
@@ -972,10 +1001,31 @@ class Skeleton_blocker_complex {
return std::distance(triangles.begin(), triangles.end());
}
+
+ /*
+ * @brief returns the number of simplices of a given dimension in the complex.
+ */
+ size_t num_simplices() const {
+ auto simplices = complex_simplex_range();
+ return std::distance(simplices.begin(), simplices.end());
+ }
+
+ /*
+ * @brief returns the number of simplices of a given dimension in the complex.
+ */
+ size_t num_simplices(unsigned dimension) const {
+ // TODO(DS): iterator on k-simplices
+ size_t res = 0;
+ for (const auto& s : complex_simplex_range())
+ if (s.dimension() == dimension)
+ ++res;
+ return res;
+ }
+
/*
* @brief returns the number of blockers in the complex.
*/
- int num_blockers() const {
+ size_t num_blockers() const {
return num_blockers_;
}
@@ -1061,7 +1111,7 @@ class Skeleton_blocker_complex {
* Furthermore, all simplices tau of the form sigma \setminus simplex_to_be_removed must be added
* whenever the dimension of tau is at least 2.
*/
- void update_blockers_after_remove_star_of_vertex_or_edge(const Simplex_handle& simplex_to_be_removed);
+ void update_blockers_after_remove_star_of_vertex_or_edge(const Simplex& simplex_to_be_removed);
public:
/**
@@ -1078,31 +1128,33 @@ class Skeleton_blocker_complex {
/**
* Remove the star of the simplex 'sigma' which needs to belong to the complex
*/
- void remove_star(const Simplex_handle& sigma);
+ void remove_star(const Simplex& sigma);
/**
- * @brief add a maximal simplex plus all its cofaces.
- * @details the simplex must have dimension greater than one (otherwise use add_vertex or add_edge).
+ * @brief add a simplex and all its faces.
+ * @details the simplex must have dimension greater than one (otherwise use add_vertex or add_edge_without_blockers).
*/
- void add_simplex(const Simplex_handle& sigma);
+ void add_simplex(const Simplex& sigma);
private:
+ void add_blockers_after_simplex_insertion(Simplex s);
+
/**
* remove all blockers that contains sigma
*/
- void remove_blocker_containing_simplex(const Simplex_handle& sigma);
+ void remove_blocker_containing_simplex(const Simplex& sigma);
/**
* remove all blockers that contains sigma
*/
- void remove_blocker_include_in_simplex(const Simplex_handle& sigma);
+ void remove_blocker_include_in_simplex(const Simplex& sigma);
public:
enum simplifiable_status {
NOT_HOMOTOPY_EQ, MAYBE_HOMOTOPY_EQ, HOMOTOPY_EQ
};
- simplifiable_status is_remove_star_homotopy_preserving(const Simplex_handle& simplex) {
+ simplifiable_status is_remove_star_homotopy_preserving(const Simplex& simplex) {
// todo write a virtual method 'link' in Skeleton_blocker_complex which will be overloaded by the current one of
// Skeleton_blocker_geometric_complex
// then call it there to build the link and return the value of link.is_contractible()
@@ -1174,7 +1226,7 @@ class Skeleton_blocker_complex {
* that may be used to construct a new blocker after contracting ab.
* It requires that the link condition is satisfied.
*/
- void tip_blockers(Vertex_handle a, Vertex_handle b, std::vector<Simplex_handle> & buffer) const;
+ void tip_blockers(Vertex_handle a, Vertex_handle b, std::vector<Simplex> & buffer) const;
private:
/**
@@ -1217,7 +1269,7 @@ class Skeleton_blocker_complex {
private:
void get_blockers_to_be_added_after_contraction(Vertex_handle a, Vertex_handle b,
- std::set<Simplex_handle>& blockers_to_add);
+ std::set<Simplex>& blockers_to_add);
/**
* delete all blockers that passes through a or b
*/
@@ -1358,12 +1410,28 @@ class Skeleton_blocker_complex {
/**
* @brief Returns a Complex_simplex_around_vertex_range over all the simplices around a vertex of the complex
*/
- Complex_simplex_around_vertex_range simplex_range(Vertex_handle v) const {
+ Complex_simplex_around_vertex_range star_simplex_range(Vertex_handle v) const {
assert(contains_vertex(v));
return Complex_simplex_around_vertex_range(
Complex_simplex_around_vertex_iterator(this, v),
Complex_simplex_around_vertex_iterator(this, v, true));
}
+ typedef Simplex_coboundary_iterator<Skeleton_blocker_complex, Link> Complex_simplex_coboundary_iterator;
+
+ /**
+ * @brief Range over the simplices of the coboundary of a simplex.
+ * Methods .begin() and .end() return a Complex_simplex_coboundary_iterator.
+ */
+ typedef boost::iterator_range < Complex_simplex_coboundary_iterator > Complex_coboundary_range;
+
+ /**
+ * @brief Returns a Complex_simplex_coboundary_iterator over the simplices of the coboundary of a simplex.
+ */
+ Complex_coboundary_range coboundary_range(const Simplex& s) const {
+ assert(contains(s));
+ return Complex_coboundary_range(Complex_simplex_coboundary_iterator(this, s),
+ Complex_simplex_coboundary_iterator(this, s, true));
+ }
// typedef Simplex_iterator<Skeleton_blocker_complex,Superior_link> Complex_simplex_iterator;
typedef Simplex_iterator<Skeleton_blocker_complex> Complex_simplex_iterator;
@@ -1373,7 +1441,7 @@ class Skeleton_blocker_complex {
/**
* @brief Returns a Complex_simplex_range over all the simplices of the complex
*/
- Complex_simplex_range simplex_range() const {
+ Complex_simplex_range complex_simplex_range() const {
Complex_simplex_iterator end(this, true);
if (empty()) {
return Complex_simplex_range(end, end);
@@ -1393,7 +1461,7 @@ class Skeleton_blocker_complex {
* @brief Iterator over the blockers adjacent to a vertex
*/
typedef Blocker_iterator_around_vertex_internal<
- typename std::multimap<Vertex_handle, Simplex_handle *>::iterator,
+ typename std::multimap<Vertex_handle, Simplex *>::iterator,
Blocker_handle>
Complex_blocker_around_vertex_iterator;
@@ -1401,7 +1469,7 @@ class Skeleton_blocker_complex {
* @brief Iterator over (constant) blockers adjacent to a vertex
*/
typedef Blocker_iterator_around_vertex_internal<
- typename std::multimap<Vertex_handle, Simplex_handle *>::const_iterator,
+ typename std::multimap<Vertex_handle, Simplex *>::const_iterator,
const Blocker_handle>
Const_complex_blocker_around_vertex_iterator;
@@ -1433,7 +1501,7 @@ class Skeleton_blocker_complex {
* @brief Iterator over the blockers.
*/
typedef Blocker_iterator_internal<
- typename std::multimap<Vertex_handle, Simplex_handle *>::iterator,
+ typename std::multimap<Vertex_handle, Simplex *>::iterator,
Blocker_handle>
Complex_blocker_iterator;
@@ -1441,7 +1509,7 @@ class Skeleton_blocker_complex {
* @brief Iterator over the (constant) blockers.
*/
typedef Blocker_iterator_internal<
- typename std::multimap<Vertex_handle, Simplex_handle *>::const_iterator,
+ typename std::multimap<Vertex_handle, Simplex *>::const_iterator,
const Blocker_handle>
Const_complex_blocker_iterator;
@@ -1515,11 +1583,12 @@ class Skeleton_blocker_complex {
* return the total number of simplices
*/
template<typename Complex, typename SimplexHandleIterator>
-Complex make_complex_from_top_faces(SimplexHandleIterator simplex_begin, SimplexHandleIterator simplex_end,
+Complex make_complex_from_top_faces(SimplexHandleIterator simplices_begin, SimplexHandleIterator simplices_end,
bool is_flag_complex = false) {
- typedef typename Complex::Simplex_handle Simplex_handle;
- std::vector<Simplex_handle> simplices;
- for (auto top_face = simplex_begin; top_face != simplex_end; ++top_face) {
+ // TODO(DS): use add_simplex instead! should be more efficient and more elegant :)
+ typedef typename Complex::Simplex Simplex;
+ std::vector<Simplex> simplices;
+ for (auto top_face = simplices_begin; top_face != simplices_end; ++top_face) {
auto subfaces_topface = subfaces(*top_face);
simplices.insert(simplices.end(), subfaces_topface.begin(), subfaces_topface.end());
}
diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_geometric_complex.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_geometric_complex.h
index b8395251..5c898152 100644
--- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_geometric_complex.h
+++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_geometric_complex.h
@@ -46,7 +46,7 @@ public Skeleton_blocker_complex<SkeletonBlockerGeometricDS> {
typedef typename SimplifiableSkeletonblocker::Vertex_handle Vertex_handle;
typedef typename SimplifiableSkeletonblocker::Root_vertex_handle Root_vertex_handle;
typedef typename SimplifiableSkeletonblocker::Edge_handle Edge_handle;
- typedef typename SimplifiableSkeletonblocker::Simplex_handle Simplex_handle;
+ typedef typename SimplifiableSkeletonblocker::Simplex Simplex;
typedef typename SimplifiableSkeletonblocker::Graph_vertex Graph_vertex;
@@ -140,7 +140,7 @@ public Skeleton_blocker_complex<SkeletonBlockerGeometricDS> {
* Constructs the link of 'simplex' with points coordinates.
*/
Geometric_link link(Vertex_handle v) const {
- Geometric_link link(*this, Simplex_handle(v));
+ Geometric_link link(*this, Simplex(v));
// we now add the point info
add_points_to_link(link);
return link;
@@ -149,7 +149,7 @@ public Skeleton_blocker_complex<SkeletonBlockerGeometricDS> {
/**
* Constructs the link of 'simplex' with points coordinates.
*/
- Geometric_link link(const Simplex_handle& simplex) const {
+ Geometric_link link(const Simplex& simplex) const {
Geometric_link link(*this, simplex);
// we now add the point info
add_points_to_link(link);
@@ -172,13 +172,13 @@ public Skeleton_blocker_complex<SkeletonBlockerGeometricDS> {
* Constructs the abstract link of v (without points coordinates).
*/
Abstract_link abstract_link(Vertex_handle v) const {
- return Abstract_link(*this, Simplex_handle(v));
+ return Abstract_link(*this, Simplex(v));
}
/**
* Constructs the link of 'simplex' with points coordinates.
*/
- Abstract_link abstract_link(const Simplex_handle& simplex) const {
+ Abstract_link abstract_link(const Simplex& simplex) const {
return Abstract_link(*this, simplex);
}
diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_link_complex.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_link_complex.h
index 95d8fa97..85a6b0b5 100644
--- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_link_complex.h
+++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_link_complex.h
@@ -52,12 +52,11 @@ class Skeleton_blocker_link_complex : public Skeleton_blocker_sub_complex<
typedef typename ComplexType::Vertex_handle Vertex_handle;
typedef typename ComplexType::Root_vertex_handle Root_vertex_handle;
- typedef typename ComplexType::Simplex_handle Simplex_handle;
+ typedef typename ComplexType::Simplex Simplex;
typedef typename ComplexType::Root_simplex_handle Root_simplex_handle;
typedef typename ComplexType::Blocker_handle Blocker_handle;
- typedef typename ComplexType::Simplex_handle::Simplex_vertex_const_iterator Simplex_handle_iterator;
typedef typename ComplexType::Root_simplex_handle::Simplex_vertex_const_iterator Root_simplex_handle_iterator;
explicit Skeleton_blocker_link_complex(bool only_superior_vertices = false)
@@ -67,13 +66,15 @@ class Skeleton_blocker_link_complex : public Skeleton_blocker_sub_complex<
/**
* If the parameter only_superior_vertices is true,
* only vertices greater than the one of alpha are added.
+ * Only vertices are computed if only_vertices is true.
*/
Skeleton_blocker_link_complex(const ComplexType & parent_complex,
- const Simplex_handle& alpha_parent_adress,
- bool only_superior_vertices = false)
+ const Simplex& alpha_parent_adress,
+ bool only_superior_vertices = false,
+ bool only_vertices = false)
: only_superior_vertices_(only_superior_vertices) {
if (!alpha_parent_adress.empty())
- build_link(parent_complex, alpha_parent_adress);
+ build_link(parent_complex, alpha_parent_adress, only_vertices);
}
/**
@@ -84,7 +85,7 @@ class Skeleton_blocker_link_complex : public Skeleton_blocker_sub_complex<
Vertex_handle a_parent_adress,
bool only_superior_vertices = false)
: only_superior_vertices_(only_superior_vertices) {
- Simplex_handle alpha_simplex(a_parent_adress);
+ Simplex alpha_simplex(a_parent_adress);
build_link(parent_complex, alpha_simplex);
}
@@ -96,7 +97,7 @@ class Skeleton_blocker_link_complex : public Skeleton_blocker_sub_complex<
Edge_handle edge, bool only_superior_vertices =
false)
: only_superior_vertices_(only_superior_vertices) {
- Simplex_handle alpha_simplex(parent_complex.first_vertex(edge),
+ Simplex alpha_simplex(parent_complex.first_vertex(edge),
parent_complex.second_vertex(edge));
build_link(parent_complex, alpha_simplex);
}
@@ -108,7 +109,7 @@ class Skeleton_blocker_link_complex : public Skeleton_blocker_sub_complex<
* are greater than vertices of alpha_parent_adress are added.
*/
void compute_link_vertices(const ComplexType & parent_complex,
- const Simplex_handle& alpha_parent_adress,
+ const Simplex& alpha_parent_adress,
bool only_superior_vertices,
bool is_alpha_blocker = false) {
if (alpha_parent_adress.dimension() == 0) {
@@ -119,7 +120,7 @@ class Skeleton_blocker_link_complex : public Skeleton_blocker_sub_complex<
only_superior_vertices_);
} else {
// we compute the intersection of neighbors of alpha and store it in link_vertices
- Simplex_handle link_vertices_parent;
+ Simplex link_vertices_parent;
parent_complex.add_neighbours(alpha_parent_adress, link_vertices_parent,
only_superior_vertices);
// For all vertex 'v' in this intersection, we go through all its adjacent blockers.
@@ -162,13 +163,8 @@ class Skeleton_blocker_link_complex : public Skeleton_blocker_sub_complex<
}
void compute_link_edges(const ComplexType & parent_complex,
- const Simplex_handle& alpha_parent_adress,
+ const Simplex& alpha_parent_adress,
bool is_alpha_blocker = false) {
- Simplex_handle_iterator y_link, x_parent, y_parent;
- // ----------------------------
- // Compute edges in the link
- // -------------------------
-
if (this->num_vertices() <= 1)
return;
@@ -194,7 +190,7 @@ class Skeleton_blocker_link_complex : public Skeleton_blocker_sub_complex<
}
}
if (new_edge)
- this->add_edge(*x_link, *y_link);
+ this->add_edge_without_blockers(*x_link, *y_link);
}
}
}
@@ -217,7 +213,7 @@ class Skeleton_blocker_link_complex : public Skeleton_blocker_sub_complex<
* the blocker is anticollapsed.
*/
void compute_link_blockers(const ComplexType & parent_complex,
- const Simplex_handle& alpha_parent,
+ const Simplex& alpha_parent,
bool is_alpha_blocker = false) {
for (auto x_link : this->vertex_range()) {
Vertex_handle x_parent = *this->give_equivalent_vertex(parent_complex,
@@ -225,7 +221,7 @@ class Skeleton_blocker_link_complex : public Skeleton_blocker_sub_complex<
for (auto blocker_parent : parent_complex.const_blocker_range(x_parent)) {
if (!is_alpha_blocker || *blocker_parent != alpha_parent) {
- Simplex_handle sigma_parent(*blocker_parent);
+ Simplex sigma_parent(*blocker_parent);
sigma_parent.difference(alpha_parent);
@@ -239,7 +235,7 @@ class Skeleton_blocker_link_complex : public Skeleton_blocker_sub_complex<
for (auto a : alpha_parent) {
for (auto eta_parent : parent_complex.const_blocker_range(a)) {
if (!is_alpha_blocker || *eta_parent != alpha_parent) {
- Simplex_handle eta_minus_alpha(*eta_parent);
+ Simplex eta_minus_alpha(*eta_parent);
eta_minus_alpha.difference(alpha_parent);
if (eta_minus_alpha != sigma_parent
&& sigma_parent.contains_difference(*eta_parent,
@@ -253,7 +249,7 @@ class Skeleton_blocker_link_complex : public Skeleton_blocker_sub_complex<
break;
}
if (is_new_blocker)
- this->add_blocker(new Simplex_handle(*sigma_link));
+ this->add_blocker(new Simplex(*sigma_link));
}
}
}
@@ -268,14 +264,15 @@ class Skeleton_blocker_link_complex : public Skeleton_blocker_sub_complex<
* with vertices that are greater than vertices of alpha_parent_adress.
*/
void build_link(const ComplexType & parent_complex,
- const Simplex_handle& alpha_parent_adress,
- bool is_alpha_blocker = false) {
+ const Simplex& alpha_parent_adress,
+ bool is_alpha_blocker = false,
+ bool only_vertices = false) {
assert(is_alpha_blocker || parent_complex.contains(alpha_parent_adress));
- compute_link_vertices(parent_complex, alpha_parent_adress,
- only_superior_vertices_);
- compute_link_edges(parent_complex, alpha_parent_adress, is_alpha_blocker);
- compute_link_blockers(parent_complex, alpha_parent_adress,
- is_alpha_blocker);
+ compute_link_vertices(parent_complex, alpha_parent_adress, only_superior_vertices_);
+ if(!only_vertices) {
+ compute_link_edges(parent_complex, alpha_parent_adress, is_alpha_blocker);
+ compute_link_blockers(parent_complex, alpha_parent_adress, is_alpha_blocker);
+ }
}
/**
@@ -284,7 +281,7 @@ class Skeleton_blocker_link_complex : public Skeleton_blocker_sub_complex<
* removed from the blockers of the complex.
*/
friend void build_link_of_blocker(const ComplexType & parent_complex,
- Simplex_handle& blocker,
+ Simplex& blocker,
Skeleton_blocker_link_complex & result) {
assert(blocker.dimension() >= 2);
assert(parent_complex.contains_blocker(blocker));
diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_simplifiable_complex.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_simplifiable_complex.h
index 17a237a7..94a125c1 100644
--- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_simplifiable_complex.h
+++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_simplifiable_complex.h
@@ -45,9 +45,7 @@ bool Skeleton_blocker_complex<SkeletonBlockerDS>::is_popable_blocker(Blocker_han
assert(this->contains_blocker(*sigma));
Skeleton_blocker_link_complex<Skeleton_blocker_complex> link_blocker_sigma;
build_link_of_blocker(*this, *sigma, link_blocker_sigma);
-
- bool res = link_blocker_sigma.is_contractible() == CONTRACTIBLE;
- return res;
+ return link_blocker_sigma.is_contractible() == CONTRACTIBLE;
}
/**
@@ -133,7 +131,7 @@ void Skeleton_blocker_complex<SkeletonBlockerDS>::remove_all_popable_blockers(Ve
template<typename SkeletonBlockerDS>
void Skeleton_blocker_complex<SkeletonBlockerDS>::remove_star(Vertex_handle v) {
// we remove the blockers that are not consistent anymore
- update_blockers_after_remove_star_of_vertex_or_edge(Simplex_handle(v));
+ update_blockers_after_remove_star_of_vertex_or_edge(Simplex(v));
while (this->degree(v) > 0) {
Vertex_handle w(* (adjacent_vertices(v.vertex, this->skeleton).first));
this->remove_edge(v, w);
@@ -148,7 +146,7 @@ void Skeleton_blocker_complex<SkeletonBlockerDS>::remove_star(Vertex_handle v) {
*/
template<typename SkeletonBlockerDS>
void Skeleton_blocker_complex<SkeletonBlockerDS>::update_blockers_after_remove_star_of_vertex_or_edge(
- const Simplex_handle& simplex_to_be_removed) {
+ const Simplex& simplex_to_be_removed) {
std::list <Blocker_handle> blockers_to_update;
if (simplex_to_be_removed.empty()) return;
@@ -159,7 +157,7 @@ void Skeleton_blocker_complex<SkeletonBlockerDS>::update_blockers_after_remove_s
}
for (auto blocker_to_update : blockers_to_update) {
- Simplex_handle sub_blocker_to_be_added;
+ Simplex sub_blocker_to_be_added;
bool sub_blocker_need_to_be_added =
(blocker_to_update->dimension() - simplex_to_be_removed.dimension()) >= 2;
if (sub_blocker_need_to_be_added) {
@@ -178,7 +176,7 @@ void Skeleton_blocker_complex<SkeletonBlockerDS>::update_blockers_after_remove_s
*/
template<typename SkeletonBlockerDS>
void Skeleton_blocker_complex<SkeletonBlockerDS>::remove_star(Vertex_handle a, Vertex_handle b) {
- update_blockers_after_remove_star_of_vertex_or_edge(Simplex_handle(a, b));
+ update_blockers_after_remove_star_of_vertex_or_edge(Simplex(a, b));
// we remove the edge
this->remove_edge(a, b);
}
@@ -195,7 +193,7 @@ void Skeleton_blocker_complex<SkeletonBlockerDS>::remove_star(Edge_handle e) {
* Remove the star of the simplex 'sigma' which needs to belong to the complex
*/
template<typename SkeletonBlockerDS>
-void Skeleton_blocker_complex<SkeletonBlockerDS>::remove_star(const Simplex_handle& sigma) {
+void Skeleton_blocker_complex<SkeletonBlockerDS>::remove_star(const Simplex& sigma) {
assert(this->contains(sigma));
if (sigma.dimension() == 0) {
remove_star(sigma.first_vertex());
@@ -207,34 +205,41 @@ void Skeleton_blocker_complex<SkeletonBlockerDS>::remove_star(const Simplex_hand
}
}
-/**
- * @brief add a maximal simplex plus all its cofaces. All vertices lower than the higher vertex of
- * sigma must already be present.
- * @details the simplex must have dimension greater than one (otherwise use add_vertex or add_edge).
- */
template<typename SkeletonBlockerDS>
-void Skeleton_blocker_complex<SkeletonBlockerDS>::add_simplex(const Simplex_handle& sigma) {
+void Skeleton_blocker_complex<SkeletonBlockerDS>::add_simplex(const Simplex& sigma) {
+ // to add a simplex s, all blockers included in s are first removed
+ // and then all simplex in the coboundary of s are added as blockers
assert(!this->contains(sigma));
assert(sigma.dimension() > 1);
+ if (!contains_vertices(sigma)) {
+ std::cerr << "add_simplex: Some vertices were not present in the complex, adding them" << std::endl;
+ size_t num_vertices_to_add = sigma.last_vertex() - this->num_vertices() + 1;
+ for (size_t i = 0; i < num_vertices_to_add; ++i)
+ this->add_vertex();
+ }
+ assert(contains_vertices(sigma));
+ if (!contains_edges(sigma))
+ add_edge(sigma);
+ remove_blocker_include_in_simplex(sigma);
+ add_blockers_after_simplex_insertion(sigma);
+}
- int num_vertex_to_add = 0;
- for (auto v : sigma)
- if (!contains_vertex(v)) ++num_vertex_to_add;
- while (num_vertex_to_add--) add_vertex();
- for (auto u_it = sigma.begin(); u_it != sigma.end(); ++u_it)
- for (auto v_it = u_it; ++v_it != sigma.end(); /**/) {
- // std::cout << "add edge" << *u_it << " " << *v_it << std::endl;
- add_edge(*u_it, *v_it);
- }
- remove_blocker_include_in_simplex(sigma);
+
+template<typename SkeletonBlockerDS>
+void Skeleton_blocker_complex<SkeletonBlockerDS>::add_blockers_after_simplex_insertion(Simplex sigma) {
+ if (sigma.dimension() < 1) return;
+
+ for (auto s : coboundary_range(sigma)) {
+ this->add_blocker(s);
+ }
}
/**
* remove all blockers that contains sigma
*/
template<typename SkeletonBlockerDS>
-void Skeleton_blocker_complex<SkeletonBlockerDS>::remove_blocker_containing_simplex(const Simplex_handle& sigma) {
+void Skeleton_blocker_complex<SkeletonBlockerDS>::remove_blocker_containing_simplex(const Simplex& sigma) {
std::vector <Blocker_handle> blockers_to_remove;
for (auto blocker : this->blocker_range(sigma.first_vertex())) {
if (blocker->contains(sigma))
@@ -248,14 +253,26 @@ void Skeleton_blocker_complex<SkeletonBlockerDS>::remove_blocker_containing_simp
* remove all blockers that contains sigma
*/
template<typename SkeletonBlockerDS>
-void Skeleton_blocker_complex<SkeletonBlockerDS>::remove_blocker_include_in_simplex(const Simplex_handle& sigma) {
- std::vector <Blocker_handle> blockers_to_remove;
- for (auto blocker : this->blocker_range(sigma.first_vertex())) {
- if (sigma.contains(*blocker))
- blockers_to_remove.push_back(blocker);
+void Skeleton_blocker_complex<SkeletonBlockerDS>::remove_blocker_include_in_simplex(const Simplex& sigma) {
+ // TODO(DS): write efficiently by using only superior blockers
+ // eg for all s, check blockers whose vertices are all greater than s
+ std::set <Blocker_handle> blockers_to_remove;
+ for (auto s : sigma) {
+ for (auto blocker : this->blocker_range(s)) {
+ if (sigma.contains(*blocker))
+ blockers_to_remove.insert(blocker);
+ }
}
- for (auto blocker_to_update : blockers_to_remove)
+ for (auto blocker_to_update : blockers_to_remove) {
+ auto s = *blocker_to_update;
this->delete_blocker(blocker_to_update);
+ // now if there is a vertex v in the link of s
+ // and v is not included in sigma then v.s is a blocker
+ // (all faces of v.s are there since v belongs to the link of s)
+ for (const auto& b : coboundary_range(s))
+ if (!sigma.contains(b))
+ this->add_blocker(b);
+ }
}
/**
@@ -265,21 +282,21 @@ void Skeleton_blocker_complex<SkeletonBlockerDS>::remove_blocker_include_in_simp
*/
template<typename SkeletonBlockerDS>
void Skeleton_blocker_complex<SkeletonBlockerDS>::tip_blockers(Vertex_handle a, Vertex_handle b,
- std::vector<Simplex_handle> & buffer) const {
+ std::vector<Simplex> & buffer) const {
for (auto const & blocker : this->const_blocker_range(a)) {
- Simplex_handle beta = (*blocker);
+ Simplex beta = (*blocker);
beta.remove_vertex(a);
buffer.push_back(beta);
}
- Simplex_handle n;
+ Simplex n;
this->add_neighbours(b, n);
this->remove_neighbours(a, n);
n.remove_vertex(a);
for (Vertex_handle y : n) {
- Simplex_handle beta;
+ Simplex beta;
beta.add_vertex(y);
buffer.push_back(beta);
}
@@ -296,7 +313,7 @@ void Skeleton_blocker_complex<SkeletonBlockerDS>::tip_blockers(Vertex_handle a,
template<typename SkeletonBlockerDS>
void
Skeleton_blocker_complex<SkeletonBlockerDS>::swap_edge(Vertex_handle a, Vertex_handle b, Vertex_handle x) {
- this->add_edge(a, x);
+ this->add_edge_without_blockers(a, x);
if (this->visitor) this->visitor->on_swaped_edge(a, b, x);
this->remove_edge(b, x);
}
@@ -341,13 +358,13 @@ Skeleton_blocker_complex<SkeletonBlockerDS>::contract_edge(Vertex_handle a, Vert
assert(this->contains_vertex(b));
if (this->contains_edge(a, b))
- this->add_edge(a, b);
+ this->add_edge_without_blockers(a, b);
// if some blockers passes through 'ab', we need to remove them.
if (!link_condition(a, b))
delete_blockers_around_edge(a, b);
- std::set<Simplex_handle> blockers_to_add;
+ std::set<Simplex> blockers_to_add;
get_blockers_to_be_added_after_contraction(a, b, blockers_to_add);
@@ -367,9 +384,8 @@ Skeleton_blocker_complex<SkeletonBlockerDS>::contract_edge(Vertex_handle a, Vert
}
template<typename SkeletonBlockerDS>
-void
-Skeleton_blocker_complex<SkeletonBlockerDS>::get_blockers_to_be_added_after_contraction(Vertex_handle a, Vertex_handle b,
- std::set<Simplex_handle>& blockers_to_add) {
+void Skeleton_blocker_complex<SkeletonBlockerDS>::get_blockers_to_be_added_after_contraction(Vertex_handle a,
+ Vertex_handle b, std::set<Simplex>& blockers_to_add) {
blockers_to_add.clear();
typedef Skeleton_blocker_link_complex<Skeleton_blocker_complex<SkeletonBlockerDS> > LinkComplexType;
@@ -377,19 +393,19 @@ Skeleton_blocker_complex<SkeletonBlockerDS>::get_blockers_to_be_added_after_cont
LinkComplexType link_a(*this, a);
LinkComplexType link_b(*this, b);
- std::vector<Simplex_handle> vector_alpha, vector_beta;
+ std::vector<Simplex> vector_alpha, vector_beta;
tip_blockers(a, b, vector_alpha);
tip_blockers(b, a, vector_beta);
for (auto alpha = vector_alpha.begin(); alpha != vector_alpha.end(); ++alpha) {
for (auto beta = vector_beta.begin(); beta != vector_beta.end(); ++beta) {
- Simplex_handle sigma = *alpha;
+ Simplex sigma = *alpha;
sigma.union_vertices(*beta);
Root_simplex_handle sigma_id = this->get_id(sigma);
if (this->contains(sigma) &&
proper_faces_in_union<Skeleton_blocker_complex < SkeletonBlockerDS >> (sigma_id, link_a, link_b)) {
- // Blocker_handle blocker = new Simplex_handle(sigma);
+ // Blocker_handle blocker = new Simplex(sigma);
sigma.add_vertex(a);
blockers_to_add.insert(sigma);
}
diff --git a/src/Skeleton_blocker/test/CMakeLists.txt b/src/Skeleton_blocker/test/CMakeLists.txt
index 8b6fb672..5e063845 100644
--- a/src/Skeleton_blocker/test/CMakeLists.txt
+++ b/src/Skeleton_blocker/test/CMakeLists.txt
@@ -4,14 +4,10 @@ project(GUDHIskbl)
if (GCOVR_PATH)
# for gcovr to make coverage reports - Corbera Jenkins plugin
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
- set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage")
- set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fprofile-arcs -ftest-coverage")
endif()
if (GPROF_PATH)
# for gprof to make coverage reports - Jenkins
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg")
- set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -pg")
- set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -pg")
endif()
add_executable(TestSkeletonBlockerComplex TestSkeletonBlockerComplex.cpp)
diff --git a/src/Skeleton_blocker/test/TestGeometricComplex.cpp b/src/Skeleton_blocker/test/TestGeometricComplex.cpp
index bd7af89b..084e2b6b 100644
--- a/src/Skeleton_blocker/test/TestGeometricComplex.cpp
+++ b/src/Skeleton_blocker/test/TestGeometricComplex.cpp
@@ -1,24 +1,24 @@
- /* 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): David Salinas
- *
- * Copyright (C) 2014 INRIA Sophia Antipolis-Mediterranee (France)
- *
- * 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/>.
- */
+/* 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): David Salinas
+ *
+ * Copyright (C) 2014 INRIA Sophia Antipolis-Mediterranee (France)
+ *
+ * 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/>.
+ */
#include <stdio.h>
#include <stdlib.h>
@@ -33,8 +33,8 @@ using namespace std;
using namespace Gudhi;
using namespace skbl;
-struct Geometry_trait{
- typedef std::vector<double> Point;
+struct Geometry_trait {
+ typedef std::vector<double> Point;
};
typedef Geometry_trait::Point Point;
@@ -42,79 +42,77 @@ typedef Skeleton_blocker_simple_geometric_traits<Geometry_trait> Complex_geometr
typedef Skeleton_blocker_geometric_complex< Complex_geometric_traits > Complex;
typedef Complex::Vertex_handle Vertex_handle;
+bool test_constructor1() {
+ Complex complex;
+ Skeleton_blocker_off_reader<Complex> off_reader("test2.off", complex);
+ if (!off_reader.is_valid()) {
+ std::cerr << "Unable to read file" << std::endl;
+ return false;
+ }
-bool test_constructor1(){
- Complex complex;
- Skeleton_blocker_off_reader<Complex> off_reader("test2.off",complex);
- if(!off_reader.is_valid()){
- std::cerr << "Unable to read file"<<std::endl;
- return false;
- }
+ std::cout << "complex has " <<
+ complex.num_vertices() << " vertices, " <<
+ complex.num_blockers() << " blockers, " <<
+ complex.num_edges() << " edges and" <<
+ complex.num_triangles() << " triangles.";
- std::cout << "complex has "<<
- complex.num_vertices()<<" vertices, "<<
- complex.num_blockers()<<" blockers, "<<
- complex.num_edges()<<" edges and" <<
- complex.num_triangles()<<" triangles.";
+ if (complex.num_vertices() != 7 || complex.num_edges() != 12 || complex.num_triangles() != 6)
+ return false;
- if(complex.num_vertices()!=7 || complex.num_edges()!=12 || complex.num_triangles() !=6)
- return false;
+ Skeleton_blocker_off_writer<Complex> off_writer("tmp.off", complex);
+ Complex same;
+ Skeleton_blocker_off_reader<Complex> off_reader2("tmp.off", same);
- Skeleton_blocker_off_writer<Complex> off_writer("tmp.off",complex);
- Complex same;
- Skeleton_blocker_off_reader<Complex> off_reader2("tmp.off",same);
+ std::cout << "\ncomplex:" << complex.to_string() << endl;
+ std::cout << "\nsame:" << same.to_string() << endl;
- std::cout<<"\ncomplex:"<<complex.to_string()<<endl;
- std::cout<<"\nsame:"<<same.to_string()<<endl;
-
- return (complex==same);
+ return (complex == same);
}
-bool test_constructor2(){
- Complex complex;
- Skeleton_blocker_off_reader<Complex> off_reader("test2.off",complex);
- if(!off_reader.is_valid()){
- std::cerr << "Unable to read file"<<std::endl;
- return false;
- }
- std::cout << "complex has "<<
- complex.num_vertices()<<" vertices, "<<
- complex.num_blockers()<<" blockers, "<<
- complex.num_edges()<<" edges and" <<
- complex.num_triangles()<<" triangles.";
+bool test_constructor2() {
+ Complex complex;
+ Skeleton_blocker_off_reader<Complex> off_reader("test2.off", complex);
+ if (!off_reader.is_valid()) {
+ std::cerr << "Unable to read file" << std::endl;
+ return false;
+ }
+ std::cout << "complex has " <<
+ complex.num_vertices() << " vertices, " <<
+ complex.num_blockers() << " blockers, " <<
+ complex.num_edges() << " edges and" <<
+ complex.num_triangles() << " triangles.";
- if(complex.num_vertices()!=7 || complex.num_edges()!=12 || complex.num_triangles() !=6)
- return false;
+ if (complex.num_vertices() != 7 || complex.num_edges() != 12 || complex.num_triangles() != 6)
+ return false;
- auto link_0 = complex.abstract_link(Vertex_handle(0));
+ auto link_0 = complex.abstract_link(Vertex_handle(0));
- std::cout<<"\n link(0):"<<link_0.to_string()<<endl;
+ std::cout << "\n link(0):" << link_0.to_string() << endl;
- auto link_geometric_0 = complex.link(Vertex_handle(0));
+ auto link_geometric_0 = complex.link(Vertex_handle(0));
- auto print_point = [&](Vertex_handle v){for(auto x : link_geometric_0.point(v)) std::cout <<x<<" "; std::cout<<std::endl;};
+ auto print_point = [&](Vertex_handle v) {
+ for (auto x : link_geometric_0.point(v)) std::cout << x << " ";
+ std::cout << std::endl;
+ };
- std::for_each(link_geometric_0.vertex_range().begin(),link_geometric_0.vertex_range().end(),print_point);
+ std::for_each(link_geometric_0.vertex_range().begin(), link_geometric_0.vertex_range().end(), print_point);
-// for(auto v : link_geometric_0.vertex_range())
-// std::cout<<"point("<<v<<"):"<<link_geometric_0.point(v)<<std::endl;
+ // for(auto v : link_geometric_0.vertex_range())
+ // std::cout<<"point("<<v<<"):"<<link_geometric_0.point(v)<<std::endl;
- return link_0.num_vertices()==2;
+ return link_0.num_vertices() == 2;
}
+int main(int argc, char *argv[]) {
+ Tests tests_geometric_complex;
+ tests_geometric_complex.add("Test constructor 1", test_constructor1);
+ tests_geometric_complex.add("Test constructor 2", test_constructor2);
-
-
-int main (int argc, char *argv[])
-{
- Tests tests_geometric_complex;
- tests_geometric_complex.add("Test constructor 1",test_constructor1);
- tests_geometric_complex.add("Test constructor 2",test_constructor2);
-
- if(tests_geometric_complex.run())
- return EXIT_SUCCESS;
- else
- return EXIT_FAILURE;
+ if (tests_geometric_complex.run())
+ return EXIT_SUCCESS;
+ else
+ return EXIT_FAILURE;
}
diff --git a/src/Skeleton_blocker/test/TestSimplifiable.cpp b/src/Skeleton_blocker/test/TestSimplifiable.cpp
index 09176934..b0855ce9 100644
--- a/src/Skeleton_blocker/test/TestSimplifiable.cpp
+++ b/src/Skeleton_blocker/test/TestSimplifiable.cpp
@@ -1,24 +1,24 @@
- /* 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): David Salinas
- *
- * Copyright (C) 2014 INRIA Sophia Antipolis-Mediterranee (France)
- *
- * 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/>.
- */
+/* 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): David Salinas
+ *
+ * Copyright (C) 2014 INRIA Sophia Antipolis-Mediterranee (France)
+ *
+ * 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/>.
+ */
#include <stdio.h>
@@ -41,316 +41,382 @@ template<typename ComplexType> class Skeleton_blocker_sub_complex;
typedef Skeleton_blocker_complex<Skeleton_blocker_simple_traits> Complex;
typedef Complex::Vertex_handle Vertex_handle;
typedef Complex::Root_vertex_handle Root_vertex_handle;
-typedef Skeleton_blocker_simplex<Vertex_handle> Simplex_handle;
+typedef Skeleton_blocker_simplex<Vertex_handle> Simplex;
// true iff v \in complex
-bool assert_vertex(Complex &complex,Vertex_handle v){
- Simplex_handle simplex(v);
- bool test = complex.contains(simplex);
- assert(test);
- return test;
+
+bool assert_vertex(Complex &complex, Vertex_handle v) {
+ Simplex simplex(v);
+ bool test = complex.contains(simplex);
+ assert(test);
+ return test;
}
// true iff the blocker (a,b,c) is in complex
-bool assert_blocker(Complex &complex,Root_vertex_handle a,Root_vertex_handle b,Root_vertex_handle c){
- return complex.contains_blocker(Simplex_handle(*complex.get_address(a),*complex.get_address(b),*complex.get_address(c)));
- //return complex.contains_blocker((a),(b),(c));
+bool assert_blocker(Complex &complex, Root_vertex_handle a, Root_vertex_handle b, Root_vertex_handle c) {
+
+ return complex.contains_blocker(Simplex(*complex.get_address(a), *complex.get_address(b), *complex.get_address(c)));
+ //return complex.contains_blocker((a),(b),(c));
}
-void build_complete(int n,Complex& complex){
- complex.clear();
- for(int i=0;i<n;i++)
- complex.add_vertex();
- for(int i=0;i<n;i++)
- for(int j=0;j<i;j++)
- complex.add_edge(Vertex_handle(i),Vertex_handle(j));
+void build_complete(int n, Complex& complex) {
+ complex.clear();
+ for (int i = 0; i < n; i++)
+ complex.add_vertex();
+ for (int i = 0; i < n; i++)
+ for (int j = 0; j < i; j++)
+ complex.add_edge_without_blockers(Vertex_handle(i), Vertex_handle(j));
}
-bool test_contraction1(){
- enum { a, b, x, y, z, n };
- Complex complex(n);
- build_complete(n,complex);
- complex.remove_edge(static_cast<Vertex_handle>(b), static_cast<Vertex_handle>(z));
- complex.add_blocker(Simplex_handle(static_cast<Vertex_handle>(a), static_cast<Vertex_handle>(x),
- static_cast<Vertex_handle>(y)));
- complex.add_blocker(Simplex_handle(static_cast<Vertex_handle>(b), static_cast<Vertex_handle>(x),
- static_cast<Vertex_handle>(y)));
-
- // Print result
- cerr << "complex before complex"<< complex.to_string()<<endl;
-
- cerr <<endl<<endl;
- complex.contract_edge(static_cast<Vertex_handle>(a),static_cast<Vertex_handle>(b));
- // Print result
- cerr << "ContractEdge(0,1)\n";
- PRINT(complex.to_string());
-
- // verification
- for (int i=0;i<5;i++)
- if (i!=1) assert_vertex(complex, static_cast<Vertex_handle>(i));
- bool test1 = !complex.contains_edge(static_cast<Vertex_handle>(a),static_cast<Vertex_handle>(b));
- bool test2 = assert_blocker(complex,Root_vertex_handle(a),Root_vertex_handle(x),Root_vertex_handle(y));
- bool test3 = complex.num_edges()==6;
- bool test4 = complex.num_blockers()==1;
- Simplex_handle sigma;
- sigma.add_vertex(static_cast<Vertex_handle>(a));
- sigma.add_vertex(static_cast<Vertex_handle>(x));
- sigma.add_vertex(static_cast<Vertex_handle>(y));
- sigma.add_vertex(static_cast<Vertex_handle>(z));
- bool test5 = !(complex.contains(sigma));
- return test1&&test2&&test3&&test4&&test5;
+bool test_contraction1() {
+
+ enum {
+ a, b, x, y, z, n
+ };
+ Complex complex(n);
+ build_complete(n, complex);
+ complex.remove_edge(static_cast<Vertex_handle> (b), static_cast<Vertex_handle> (z));
+ complex.add_blocker(Simplex(static_cast<Vertex_handle> (a), static_cast<Vertex_handle> (x),
+ static_cast<Vertex_handle> (y)));
+ complex.add_blocker(Simplex(static_cast<Vertex_handle> (b), static_cast<Vertex_handle> (x),
+ static_cast<Vertex_handle> (y)));
+
+ // Print result
+ cerr << "complex before complex" << complex.to_string() << endl;
+
+ cerr << endl << endl;
+ complex.contract_edge(static_cast<Vertex_handle> (a), static_cast<Vertex_handle> (b));
+ // Print result
+ cerr << "ContractEdge(0,1)\n";
+ PRINT(complex.to_string());
+
+ // verification
+ for (int i = 0; i < 5; i++)
+ if (i != 1) assert_vertex(complex, static_cast<Vertex_handle> (i));
+ bool test1 = !complex.contains_edge(static_cast<Vertex_handle> (a), static_cast<Vertex_handle> (b));
+ bool test2 = assert_blocker(complex, Root_vertex_handle(a), Root_vertex_handle(x), Root_vertex_handle(y));
+ bool test3 = complex.num_edges() == 6;
+ bool test4 = complex.num_blockers() == 1;
+ Simplex sigma;
+ sigma.add_vertex(static_cast<Vertex_handle> (a));
+ sigma.add_vertex(static_cast<Vertex_handle> (x));
+ sigma.add_vertex(static_cast<Vertex_handle> (y));
+ sigma.add_vertex(static_cast<Vertex_handle> (z));
+ bool test5 = !(complex.contains(sigma));
+ return test1 && test2 && test3 && test4&&test5;
}
+bool test_contraction2() {
-bool test_contraction2(){
- enum { a, b, x, y, z, n };
- Complex complex(n);
- build_complete(n,complex);
- complex.remove_edge(static_cast<Vertex_handle>(b),static_cast<Vertex_handle>(x));
- Simplex_handle blocker;
- blocker.add_vertex(static_cast<Vertex_handle>(a));
- blocker.add_vertex(static_cast<Vertex_handle>(y));
- blocker.add_vertex(static_cast<Vertex_handle>(z));
+ enum {
+ a, b, x, y, z, n
+ };
+ Complex complex(n);
+ build_complete(n, complex);
+ complex.remove_edge(static_cast<Vertex_handle> (b), static_cast<Vertex_handle> (x));
+ Simplex blocker;
+ blocker.add_vertex(static_cast<Vertex_handle> (a));
+ blocker.add_vertex(static_cast<Vertex_handle> (y));
+ blocker.add_vertex(static_cast<Vertex_handle> (z));
- complex.add_blocker(blocker);
+ complex.add_blocker(blocker);
- // Print result
- cerr << "complex complex"<< complex.to_string();
- cerr <<endl<<endl;
- complex.contract_edge(static_cast<Vertex_handle>(a),static_cast<Vertex_handle>(b));
+ // Print result
+ cerr << "complex complex" << complex.to_string();
+ cerr << endl << endl;
+ complex.contract_edge(static_cast<Vertex_handle> (a), static_cast<Vertex_handle> (b));
- cerr << "complex.ContractEdge(a,b)"<< complex.to_string();
+ cerr << "complex.ContractEdge(a,b)" << complex.to_string();
- cerr <<endl<<endl;
+ cerr << endl << endl;
- // there should be one blocker (a,c,d,e) in the complex
- bool test ;
- test = complex.contains_blocker(Simplex_handle(static_cast<Vertex_handle>(a), static_cast<Vertex_handle>(x),
- static_cast<Vertex_handle>(y),static_cast<Vertex_handle>(z)));
- test = test && complex.num_blockers()==1;
- return test;
+ // there should be one blocker (a,c,d,e) in the complex
+ bool test;
+ test = complex.contains_blocker(Simplex(static_cast<Vertex_handle> (a), static_cast<Vertex_handle> (x),
+ static_cast<Vertex_handle> (y), static_cast<Vertex_handle> (z)));
+ test = test && complex.num_blockers() == 1;
+ return test;
}
-bool test_link_condition1(){
+bool test_link_condition1() {
- Complex complex(0);
- // Build the complexes
- build_complete(4,complex);
- complex.add_blocker(Simplex_handle(static_cast<Vertex_handle>(0), static_cast<Vertex_handle>(1), static_cast<Vertex_handle>(2)));
+ Complex complex(0);
+ // Build the complexes
+ build_complete(4, complex);
+ complex.add_blocker(Simplex(static_cast<Vertex_handle> (0), static_cast<Vertex_handle> (1), static_cast<Vertex_handle> (2)));
- // Print result
- cerr << "complex complex"<< complex.to_string();
- cerr <<endl<<endl;
+ // Print result
+ cerr << "complex complex" << complex.to_string();
+ cerr << endl << endl;
- bool weak_link_condition = complex.link_condition(Vertex_handle(1),Vertex_handle(2),true);
+ bool weak_link_condition = complex.link_condition(Vertex_handle(1), Vertex_handle(2), true);
- bool strong_link_condition = complex.link_condition(Vertex_handle(1),Vertex_handle(2),false);
+ bool strong_link_condition = complex.link_condition(Vertex_handle(1), Vertex_handle(2), false);
- return weak_link_condition && !strong_link_condition;
+ return weak_link_condition && !strong_link_condition;
}
-
-bool test_collapse0(){
- Complex complex(5);
- build_complete(4,complex);
- complex.add_vertex();
- complex.add_edge(static_cast<Vertex_handle>(2), static_cast<Vertex_handle>(4));
- complex.add_edge(static_cast<Vertex_handle>(3), static_cast<Vertex_handle>(4));
- // Print result
- cerr << "initial complex :\n"<< complex.to_string();
- cerr <<endl<<endl;
-
- Simplex_handle simplex_123(static_cast<Vertex_handle>(1), static_cast<Vertex_handle>(2), static_cast<Vertex_handle>(3));
- complex.remove_star(simplex_123);
- cerr << "complex.remove_star(1,2,3):\n"<< complex.to_string();
- cerr <<endl<<endl;
-
- // verification
- bool blocker123_here = complex.contains_blocker(simplex_123);
- cerr <<"----> Ocomplex \n";
- return blocker123_here;
+bool test_collapse0() {
+ Complex complex(5);
+ build_complete(4, complex);
+ complex.add_vertex();
+ complex.add_edge_without_blockers(static_cast<Vertex_handle> (2), static_cast<Vertex_handle> (4));
+ complex.add_edge_without_blockers(static_cast<Vertex_handle> (3), static_cast<Vertex_handle> (4));
+ // Print result
+ cerr << "initial complex :\n" << complex.to_string();
+ cerr << endl << endl;
+
+ Simplex simplex_123(static_cast<Vertex_handle> (1), static_cast<Vertex_handle> (2), static_cast<Vertex_handle> (3));
+ complex.remove_star(simplex_123);
+ cerr << "complex.remove_star(1,2,3):\n" << complex.to_string();
+ cerr << endl << endl;
+
+ // verification
+ bool blocker123_here = complex.contains_blocker(simplex_123);
+ cerr << "----> Ocomplex \n";
+ return blocker123_here;
}
-
-bool test_collapse1(){
- Complex complex(5);
- build_complete(4,complex);
- complex.add_blocker(Simplex_handle(Vertex_handle(0),Vertex_handle(1),Vertex_handle(2),Vertex_handle(3)));
- // Print result
- cerr << "initial complex :\n"<< complex.to_string();
- cerr <<endl<<endl;
-
- Simplex_handle simplex_123(Vertex_handle(1),Vertex_handle(2),Vertex_handle(3));
- complex.remove_star(simplex_123);
- cerr << "complex.remove_star(1,2,3):\n"<< complex.to_string();
- cerr <<endl<<endl;
-
- // verification
- bool res = complex.contains_blocker(simplex_123);
- res = res && complex.num_blockers()==1;
- cerr <<"----> Ocomplex \n";
- return res;
+bool test_collapse1() {
+ Complex complex(5);
+ build_complete(4, complex);
+ complex.add_blocker(Simplex(Vertex_handle(0), Vertex_handle(1), Vertex_handle(2), Vertex_handle(3)));
+ // Print result
+ cerr << "initial complex :\n" << complex.to_string();
+ cerr << endl << endl;
+
+ Simplex simplex_123(Vertex_handle(1), Vertex_handle(2), Vertex_handle(3));
+ complex.remove_star(simplex_123);
+ cerr << "complex.remove_star(1,2,3):\n" << complex.to_string();
+ cerr << endl << endl;
+
+ // verification
+ bool res = complex.contains_blocker(simplex_123);
+ res = res && complex.num_blockers() == 1;
+ cerr << "----> Ocomplex \n";
+ return res;
}
-bool test_collapse2(){
- Complex complex(5);
- build_complete(4,complex);
- complex.add_vertex();
- complex.add_edge(Vertex_handle(1),Vertex_handle(4));
- complex.add_edge(Vertex_handle(2),Vertex_handle(4));
- complex.add_edge(Vertex_handle(3),Vertex_handle(4));
- complex.add_blocker(Simplex_handle(Vertex_handle(1),Vertex_handle(2),Vertex_handle(3),Vertex_handle(4)));
- // Print result
- cerr << "initial complex :\n"<< complex.to_string();
- cerr <<endl<<endl;
-
- Simplex_handle sigma(Vertex_handle(1),Vertex_handle(2),Vertex_handle(3));
- complex.remove_star(sigma);
- cerr << "complex.remove_star(1,2,3):\n"<< complex.to_string();
- cerr <<endl<<endl;
-
- // verification
- bool blocker_removed = !complex.contains_blocker(Simplex_handle(Vertex_handle(1),Vertex_handle(2),Vertex_handle(3),Vertex_handle(4)));
- bool blocker123_here = complex.contains_blocker(sigma);
- return blocker_removed && blocker123_here;
+bool test_collapse2() {
+ Complex complex(5);
+ build_complete(4, complex);
+ complex.add_vertex();
+ complex.add_edge_without_blockers(Vertex_handle(1), Vertex_handle(4));
+ complex.add_edge_without_blockers(Vertex_handle(2), Vertex_handle(4));
+ complex.add_edge_without_blockers(Vertex_handle(3), Vertex_handle(4));
+ complex.add_blocker(Simplex(Vertex_handle(1), Vertex_handle(2), Vertex_handle(3), Vertex_handle(4)));
+ // Print result
+ cerr << "initial complex :\n" << complex.to_string();
+ cerr << endl << endl;
+
+ Simplex sigma(Vertex_handle(1), Vertex_handle(2), Vertex_handle(3));
+ complex.remove_star(sigma);
+ cerr << "complex.remove_star(1,2,3):\n" << complex.to_string();
+ cerr << endl << endl;
+
+ // verification
+ bool blocker_removed = !complex.contains_blocker(Simplex(Vertex_handle(1), Vertex_handle(2), Vertex_handle(3), Vertex_handle(4)));
+ bool blocker123_here = complex.contains_blocker(sigma);
+ return blocker_removed && blocker123_here;
}
-bool test_collapse3(){
- Complex complex(5);
- build_complete(4,complex);
- complex.add_vertex();
- complex.add_edge(Vertex_handle(1),Vertex_handle(4));
- complex.add_edge(Vertex_handle(2),Vertex_handle(4));
- complex.add_edge(Vertex_handle(3),Vertex_handle(4));
- complex.add_blocker(Simplex_handle(Vertex_handle(1),Vertex_handle(2),Vertex_handle(3),Vertex_handle(4)));
- // Print result
- cerr << "initial complex:\n"<< complex.to_string();
- cerr <<endl<<endl;
-
- complex.remove_star(static_cast<Vertex_handle>(2));
- cerr << "complex after remove star of 2:\n"<< complex.to_string();
-
- bool blocker134_here = complex.contains_blocker(Simplex_handle(Vertex_handle(1),Vertex_handle(3),Vertex_handle(4)));
- bool blocker1234_here = complex.contains_blocker(Simplex_handle(Vertex_handle(1),Vertex_handle(2),Vertex_handle(3),Vertex_handle(4)));
- return blocker134_here && !blocker1234_here;
+bool test_collapse3() {
+ Complex complex(5);
+ build_complete(4, complex);
+ complex.add_vertex();
+ complex.add_edge_without_blockers(Vertex_handle(1), Vertex_handle(4));
+ complex.add_edge_without_blockers(Vertex_handle(2), Vertex_handle(4));
+ complex.add_edge_without_blockers(Vertex_handle(3), Vertex_handle(4));
+ complex.add_blocker(Simplex(Vertex_handle(1), Vertex_handle(2), Vertex_handle(3), Vertex_handle(4)));
+ // Print result
+ cerr << "initial complex:\n" << complex.to_string();
+ cerr << endl << endl;
+
+ complex.remove_star(static_cast<Vertex_handle> (2));
+ cerr << "complex after remove star of 2:\n" << complex.to_string();
+
+ bool blocker134_here = complex.contains_blocker(Simplex(Vertex_handle(1), Vertex_handle(3), Vertex_handle(4)));
+ bool blocker1234_here = complex.contains_blocker(Simplex(Vertex_handle(1), Vertex_handle(2), Vertex_handle(3), Vertex_handle(4)));
+ return blocker134_here && !blocker1234_here;
}
-bool test_add_simplex(){
- Complex complex(5);
- build_complete(4,complex);
- complex.add_blocker(Simplex_handle(Vertex_handle(0),Vertex_handle(1),Vertex_handle(2)));
- // Print result
- cerr << "initial complex:\n"<< complex.to_string();
- cerr <<endl<<endl;
-
- complex.add_simplex(Simplex_handle(Vertex_handle(0),Vertex_handle(1),Vertex_handle(2),Vertex_handle(3)));
- cerr << "complex after add_simplex:\n"<< complex.to_string();
-
- return complex.num_blockers()==0;
+bool test_add_simplex() {
+ Complex complex(4);
+ build_complete(4, complex);
+ complex.add_blocker(Simplex(Vertex_handle(0), Vertex_handle(1), Vertex_handle(3)));
+ cerr << "initial complex:\n" << complex.to_string();
+ cerr << endl << endl;
+
+ complex.add_simplex(Simplex(Vertex_handle(0), Vertex_handle(1), Vertex_handle(3)));
+ cerr << "complex after add_simplex:\n" << complex.to_string();
+ return complex.num_blockers() == 1
+ && complex.contains_blocker(Simplex(Vertex_handle(0), Vertex_handle(1), Vertex_handle(2), Vertex_handle(3)));
}
-bool test_add_simplex2(){
- Complex complex;
- build_complete(4,complex);
- // Print result
- cerr << "initial complex:\n"<< complex.to_string();
- cerr <<endl<<endl;
+bool test_add_simplex2() {
+ Complex complex;
+ build_complete(4, complex);
+ // Print result
+ cerr << "initial complex:\n" << complex.to_string();
+ cerr << endl << endl;
- Complex copy(complex.num_vertices());
+ Complex copy(complex.num_vertices());
- std::vector<Simplex_handle> simplices(complex.simplex_range().begin(),complex.simplex_range().end());
- sort(simplices.begin(),simplices.end(),[&](const Simplex_handle& s1,const Simplex_handle& s2){
- return s1.dimension()<s2.dimension();
- });
- for(const auto & simplex : simplices){
- if(!copy.contains(simplex) && simplex.dimension()==1)
- copy.add_edge(simplex.first_vertex(),simplex.last_vertex());
- if(!copy.contains(simplex) && simplex.dimension()>1)
- copy.add_simplex(simplex);
- }
+ std::vector<Simplex> simplices(complex.complex_simplex_range().begin(), complex.complex_simplex_range().end());
+ sort(simplices.begin(), simplices.end(), [&](const Simplex& s1, const Simplex & s2) {
+ return s1.dimension() < s2.dimension();
+ });
+ for (const auto & simplex : simplices) {
+ if (!copy.contains(simplex) && simplex.dimension() == 1)
+ copy.add_edge_without_blockers(simplex.first_vertex(), simplex.last_vertex());
+ if (!copy.contains(simplex) && simplex.dimension() > 1)
+ copy.add_simplex(simplex);
+ }
- cerr << "complex after add_simplex:\n"<< copy.to_string();
+ cerr << "complex after add_simplex:\n" << copy.to_string();
- return complex.num_blockers()==copy.num_blockers() &&
- complex.num_edges()==copy.num_edges() &&
- complex.num_vertices()==copy.num_vertices();
+ return complex.num_blockers() == copy.num_blockers() &&
+ complex.num_edges() == copy.num_edges() &&
+ complex.num_vertices() == copy.num_vertices();
}
+bool test_add_simplex3() {
+ Complex complex(5);
+ build_complete(5, complex);
+ complex.remove_edge(Vertex_handle(3), Vertex_handle(4));
+ Simplex sigma(Vertex_handle(0), Vertex_handle(1), Vertex_handle(2));
+ complex.add_blocker(sigma);
+ // Print result
+ cerr << "initial complex:\n" << complex.to_string();
+ cerr << endl << endl;
+ complex.add_simplex(sigma);
+ //should create two blockers 0123 and 0124
+ cerr << "complex after adding simplex 012:\n" << complex.to_string();
+ return complex.num_blockers() == 2
+ && complex.contains_blocker(Simplex(Vertex_handle(0), Vertex_handle(1), Vertex_handle(2), Vertex_handle(3)))
+ && complex.contains_blocker(Simplex(Vertex_handle(0), Vertex_handle(1), Vertex_handle(2), Vertex_handle(4)));
+}
-
-bool test_remove_popable_blockers(){
- Complex complex;
- build_complete(4,complex);
- complex.add_vertex();
- complex.add_edge(Vertex_handle(3),Vertex_handle(4));
- complex.add_edge(Vertex_handle(2),Vertex_handle(4));
- Simplex_handle sigma1=Simplex_handle(Vertex_handle(1),Vertex_handle(2),Vertex_handle(3));
- Simplex_handle sigma2=Simplex_handle(Vertex_handle(2),Vertex_handle(3),Vertex_handle(4));
-
- complex.add_blocker(sigma1);
- complex.add_blocker(sigma2);
- cerr << "complex complex"<< complex.to_string();
- cerr <<endl<<endl;
- cerr << "complex.RemovePopableBlockers();"<<endl;
- complex.remove_popable_blockers();
- cerr << "complex complex"<< complex.to_string();
- cerr <<endl<<endl;
-
- bool test1 = (complex.num_blockers()==1);
-
-
- // test 2
- complex.clear();
- build_complete(4,complex);
- complex.add_vertex();
- complex.add_vertex();
- complex.add_edge(Vertex_handle(3),Vertex_handle(4));
- complex.add_edge(Vertex_handle(2),Vertex_handle(4));
- complex.add_edge(Vertex_handle(2),Vertex_handle(5));
- complex.add_edge(Vertex_handle(3),Vertex_handle(5));
- complex.add_edge(Vertex_handle(4),Vertex_handle(5));
- sigma1=Simplex_handle(Vertex_handle(1),Vertex_handle(2),Vertex_handle(3));
- sigma2=Simplex_handle(Vertex_handle(2),Vertex_handle(3),Vertex_handle(4));
-
- complex.add_blocker(sigma1);
- complex.add_blocker(sigma2);
- cerr << "complex complex"<< complex.to_string();
- cerr <<endl<<endl; cerr << "complex.RemovePopableBlockers();"<<endl;
- complex.remove_popable_blockers();
- cerr << "complex complex"<< complex.to_string();
-
- cerr <<endl<<endl;
- bool test2 = (complex.num_blockers()==0);
- return test1&&test2;
+bool test_add_simplex4() {
+ int n = 6;
+ Complex complex(n);
+
+ // add all simplex 0..n without i
+ for (int i = 0; i < n; i++) {
+ Simplex s;
+ for (int k = 0; k < n; k++)
+ s.add_vertex(Vertex_handle(k));
+ s.remove_vertex(Vertex_handle(i));
+ complex.add_simplex(s);
+
+ //at step i there is only blocker 0..i
+ if (i < 2 && complex.num_blockers() > 0)
+ return false;
+ if (i >= 2 && complex.num_blockers() != 1) {
+ Simplex b;
+ for (int k = 0; k < i; k++)
+ b.add_vertex(Vertex_handle(i));
+ if (!complex.contains_blocker(b))
+ return false;
+ }
+ TESTVALUE(complex.blockers_to_string());
+ }
+ Simplex s;
+ for (int k = 0; k < n; k++)
+ s.add_vertex(Vertex_handle(k));
+ return complex.num_blockers() == 1 && complex.contains_blocker(s);
}
+bool test_add_edge() {
+ Complex complex(4);
+ for (unsigned i = 0u; i < 4; i++)
+ complex.add_edge(Vertex_handle(i), Vertex_handle((i + 1) % 4));
+
+ // Print result
+ cerr << "initial complex:\n" << complex.to_string();
+ cerr << endl << endl;
+ complex.add_edge(Vertex_handle(1), Vertex_handle(3));
+ //should create two blockers 013 and 012
+ cerr << "complex after adding edge 13:\n" << complex.to_string();
+ return complex.num_blockers() == 2
+ && complex.contains_blocker(Simplex(Vertex_handle(0), Vertex_handle(1), Vertex_handle(3)))
+ && complex.contains_blocker(Simplex(Vertex_handle(1), Vertex_handle(2), Vertex_handle(3)));
+}
+bool test_remove_popable_blockers() {
+ Complex complex;
+ build_complete(4, complex);
+ complex.add_vertex();
+ complex.add_edge_without_blockers(Vertex_handle(3), Vertex_handle(4));
+ complex.add_edge_without_blockers(Vertex_handle(2), Vertex_handle(4));
+ Simplex sigma1 = Simplex(Vertex_handle(1), Vertex_handle(2), Vertex_handle(3));
+ Simplex sigma2 = Simplex(Vertex_handle(2), Vertex_handle(3), Vertex_handle(4));
+
+ complex.add_blocker(sigma1);
+ complex.add_blocker(sigma2);
+ cerr << "complex complex" << complex.to_string();
+ cerr << endl << endl;
+ cerr << "complex.RemovePopableBlockers();" << endl;
+ complex.remove_popable_blockers();
+ cerr << "complex complex" << complex.to_string();
+ cerr << endl << endl;
+
+ bool test1 = (complex.num_blockers() == 1);
+
+
+ // test 2
+ complex.clear();
+ build_complete(4, complex);
+ complex.add_vertex();
+ complex.add_vertex();
+ complex.add_edge_without_blockers(Vertex_handle(3), Vertex_handle(4));
+ complex.add_edge_without_blockers(Vertex_handle(2), Vertex_handle(4));
+ complex.add_edge_without_blockers(Vertex_handle(2), Vertex_handle(5));
+ complex.add_edge_without_blockers(Vertex_handle(3), Vertex_handle(5));
+ complex.add_edge_without_blockers(Vertex_handle(4), Vertex_handle(5));
+ sigma1 = Simplex(Vertex_handle(1), Vertex_handle(2), Vertex_handle(3));
+ sigma2 = Simplex(Vertex_handle(2), Vertex_handle(3), Vertex_handle(4));
+
+ complex.add_blocker(sigma1);
+ complex.add_blocker(sigma2);
+ cerr << "complex complex" << complex.to_string();
+ cerr << endl << endl;
+ cerr << "complex.RemovePopableBlockers();" << endl;
+ complex.remove_popable_blockers();
+ cerr << "complex complex" << complex.to_string();
+
+ cerr << endl << endl;
+ bool test2 = (complex.num_blockers() == 0);
+ return test1&&test2;
+}
-int main (int argc, char *argv[])
-{
- Tests tests_simplifiable_complex;
- tests_simplifiable_complex.add("Test contraction 1",test_contraction1);
- tests_simplifiable_complex.add("Test contraction 2",test_contraction2);
- tests_simplifiable_complex.add("Test Link condition 1",test_link_condition1);
- tests_simplifiable_complex.add("Test remove popable blockers",test_remove_popable_blockers);
+int main(int argc, char *argv[]) {
+ Tests tests_simplifiable_complex;
+ tests_simplifiable_complex.add("Test contraction 1", test_contraction1);
+ tests_simplifiable_complex.add("Test contraction 2", test_contraction2);
+ tests_simplifiable_complex.add("Test Link condition 1", test_link_condition1);
+ tests_simplifiable_complex.add("Test remove popable blockers", test_remove_popable_blockers);
- tests_simplifiable_complex.add("Test collapse 0",test_collapse0);
- tests_simplifiable_complex.add("Test collapse 1",test_collapse1);
- tests_simplifiable_complex.add("Test collapse 2",test_collapse2);
- tests_simplifiable_complex.add("Test collapse 3",test_collapse3);
+ tests_simplifiable_complex.add("Test collapse 0", test_collapse0);
+ tests_simplifiable_complex.add("Test collapse 1", test_collapse1);
+ tests_simplifiable_complex.add("Test collapse 2", test_collapse2);
+ tests_simplifiable_complex.add("Test collapse 3", test_collapse3);
- tests_simplifiable_complex.add("Test add simplex",test_add_simplex);
- tests_simplifiable_complex.add("Test add simplex2",test_add_simplex2);
+ tests_simplifiable_complex.add("Test add edge",test_add_edge);
+ tests_simplifiable_complex.add("Test add simplex", test_add_simplex);
+ tests_simplifiable_complex.add("Test add simplex2", test_add_simplex2);
+ tests_simplifiable_complex.add("Test add simplex3",test_add_simplex3);
+ tests_simplifiable_complex.add("Test add simplex4",test_add_simplex4);
- tests_simplifiable_complex.run();
+ tests_simplifiable_complex.run();
- if(tests_simplifiable_complex.run())
- return EXIT_SUCCESS;
- else
- return EXIT_FAILURE;
+ if (tests_simplifiable_complex.run())
+ return EXIT_SUCCESS;
+ else
+ return EXIT_FAILURE;
}
diff --git a/src/Skeleton_blocker/test/TestSkeletonBlockerComplex.cpp b/src/Skeleton_blocker/test/TestSkeletonBlockerComplex.cpp
index 319e3c43..71b1833b 100644
--- a/src/Skeleton_blocker/test/TestSkeletonBlockerComplex.cpp
+++ b/src/Skeleton_blocker/test/TestSkeletonBlockerComplex.cpp
@@ -42,911 +42,911 @@ using namespace skbl;
typedef Skeleton_blocker_complex<Skeleton_blocker_simple_traits> Complex;
typedef Complex::Vertex_handle Vertex_handle;
typedef Complex::Root_vertex_handle Root_vertex_handle;
-typedef Complex::Simplex_handle Simplex_handle;
+typedef Complex::Simplex Simplex;
typedef Complex::Root_simplex_handle Root_simplex_handle;
-typedef Simplex_handle::Simplex_vertex_const_iterator Simplex_vertex_const_iterator;
+typedef Simplex::Simplex_vertex_const_iterator Simplex_vertex_const_iterator;
typedef Complex::Edge_handle Edge_handle;
// true if v in complex
-bool assert_vertex(Complex &complex,Vertex_handle v){
- //assert(complex.contains(v));
- return complex.contains(static_cast<Simplex_handle>(v));
-}
-
-bool assert_simplex(Complex &complex,Root_vertex_handle a,Root_vertex_handle b,Root_vertex_handle c){
- return true;
- // AddressSimplex simplex((a),(b),(c));
- // return complex.contains(&simplex);
-}
-// true iff the blocker (a,b,c) is in complex
-bool assert_blocker(Complex &complex,Root_vertex_handle a,Root_vertex_handle b,Root_vertex_handle c){
- return true;
- //return complex.contains_blocker((a),(b),(c));
+bool assert_vertex(Complex &complex, Vertex_handle v) {
+ //assert(complex.contains(v));
+ return complex.contains(static_cast<Simplex> (v));
}
-// true iff the blocker (a,b,c,d) is in complex
-bool assert_blocker(Complex &complex,Root_vertex_handle a,Root_vertex_handle b,Root_vertex_handle c,Root_vertex_handle d){
- return true;
- //Simplex blocker (a,b,c,d);
- //return complex.contains_blocker(&blocker);
-}
-
-
-
-void build_complete(int n,Complex& complex){
- complex.clear();
- for(int i=0;i<n;i++)
- complex.add_vertex();
-
- // for(int i=n-1;i>=0;i--)
- // for(int j=i-1;j>=0;j--)
- // complex.add_edge(Vertex_handle(i),Vertex_handle(j));
-
- for(int i=0;i<n;i++)
- for(int j=0;j<i;j++)
- complex.add_edge(Vertex_handle(i),Vertex_handle(j));
-}
-
-
-bool test_simplex(){
- // PRINT("test simplex");
- Simplex_handle simplex(Vertex_handle(0),Vertex_handle(1),Vertex_handle(2),Vertex_handle(3));
- for (auto i = simplex.begin() ; i != simplex.end() ; ++i){
- PRINT(*i);
- auto j = i;
- for (++j ;
- j != simplex.end() ;
- ++j){
- PRINT(*j);
- }
- }
- return simplex.dimension()==3;
-}
-
-
-bool test_iterator_vertices1(){
- int n = 10;
- Complex complex(10);
- cerr << "complex.num_vertices():"<<complex.num_vertices()<<endl;
- int num_vertex_seen = 0;
- for(auto vi :complex.vertex_range()){
- cerr << "vertex:"<<vi<<endl;
- ++num_vertex_seen;
- }
- return num_vertex_seen == n;
-}
-
-bool test_iterator_vertices2(){
- int n = 10;
- Complex complex(10);
- build_complete(10,complex);
- cerr << "complex.num_vertices():"<<complex.num_vertices()<<endl;
- cerr << "complex.num_edges():"<<complex.num_edges()<<endl;
- int num_vertex_seen = 0;
- for(auto vi :complex.vertex_range(Vertex_handle(2))){
- cerr << "vertex:"<<vi<<endl;
- ++num_vertex_seen;
- }
- std::cerr<<"num_vertex_seen:"<<num_vertex_seen<<std::endl;
- return num_vertex_seen == (n-1);
-}
-
-
-
-bool test_iterator_edge(){
- const int n = 10;
- Complex complex(n);
- for(int i=0;i<n;i++)
- for(int j=0;j<i;j++)
- complex.add_edge(Vertex_handle(i),Vertex_handle(j));
- complex.remove_edge(Vertex_handle(2),Vertex_handle(3));
- complex.remove_edge(Vertex_handle(3),Vertex_handle(5));
- cerr << "complex.num_edges():"<<complex.num_edges()<<endl;
- int num_edges_seen = 0;
- for(auto edge : complex.edge_range()){
- cerr << "edge :"<<complex[edge]<<endl;
- ++num_edges_seen;
- }
-
- return num_edges_seen == n*(n-1)/2-2;
-}
-
-bool test_iterator_edge2(){
- const int n = 10;
- Complex complex(n);
- for(int i=0;i<n;i++)
- for(int j=0;j<i;j++)
- complex.add_edge(Vertex_handle(i),Vertex_handle(j));
- complex.remove_edge(Vertex_handle(2),Vertex_handle(3));
- complex.remove_edge(Vertex_handle(3),Vertex_handle(5));
- cerr << "complex.num_edges():"<<complex.num_edges()<<endl;
- int num_neigbors_seen = 0;
- for(auto neighbor : complex.vertex_range(Vertex_handle(2))){
- cerr << "neighbor"<<neighbor<<endl;
- ++num_neigbors_seen;
- }
- return num_neigbors_seen==8;
-}
-
-
-
-bool test_iterator_edge3(){
- const int n = 10;
- Complex complex(n);
- for(int i=0;i<n;i++)
- for(int j=0;j<i;j++)
- complex.add_edge(Vertex_handle(i),Vertex_handle(j));
- complex.remove_edge(Vertex_handle(2),Vertex_handle(3));
- complex.remove_edge(Vertex_handle(3),Vertex_handle(5));
- cerr << "complex.num_edges():"<<complex.num_edges()<<endl;
- int num_neigbors_seen = 0;
- for(auto edge : complex.edge_range(Vertex_handle(2))){
- std::cerr << edge<< std::endl;
- ++num_neigbors_seen;
- }
- return num_neigbors_seen==8;
-}
-
-
-
-bool test_iterator_triangles(){
- const int n = 7;
- Complex complex(n);
- //create a "ring" around '0'
- for(int i=1;i<n;i++)
- complex.add_edge(Vertex_handle(0),Vertex_handle(i));
- for(int i=1;i<n-1;i++)
- complex.add_edge(Vertex_handle(i),Vertex_handle(i+1));
- complex.add_edge(Vertex_handle(1),Vertex_handle(6));
-
- PRINT(complex.to_string());
-
- int num_triangles_seen=0;
- //for (auto t : complex.triangle_range(5)){
- TEST("triangles around 5 (should be 2 of them):");
- for (auto t : complex.triangle_range(Vertex_handle(5))){
- PRINT(t);
- ++num_triangles_seen;
- }
- bool test = (num_triangles_seen==2);
-
- num_triangles_seen=0;
- TEST("triangles around 0 (should be 6 of them):");
- for (auto t : complex.triangle_range(Vertex_handle(0))){
- PRINT(t);
- ++num_triangles_seen;
- }
- test = test&&(num_triangles_seen==6);
-
- // we now add another triangle
- complex.add_vertex();
- complex.add_edge(Vertex_handle(4),Vertex_handle(7));
- complex.add_edge(Vertex_handle(3),Vertex_handle(7));
- complex.add_blocker(Simplex_handle(Vertex_handle(0),Vertex_handle(1),Vertex_handle(6)));
- num_triangles_seen=0;
-
- TEST("triangles (should be 6 of them):");
- num_triangles_seen=0;
- for (auto t : complex.triangle_range()){
- PRINT(t);
- ++num_triangles_seen;
- }
- test = test&&(num_triangles_seen==6);
- PRINT(num_triangles_seen);
-
- return test;
+bool assert_simplex(Complex &complex, Root_vertex_handle a, Root_vertex_handle b, Root_vertex_handle c) {
+ return true;
+ // AddressSimplex simplex((a),(b),(c));
+ // return complex.contains(&simplex);
}
+// true iff the blocker (a,b,c) is in complex
-//#include "combinatorics/Skeleton_blocker/iterators/Skeleton_blockers_simplices_iterators.h"
-
-bool test_iterator_simplices(){
- Complex complex(6);
- complex.add_edge(Vertex_handle(0),Vertex_handle(1));
- complex.add_edge(Vertex_handle(1),Vertex_handle(2));
- complex.add_edge(Vertex_handle(2),Vertex_handle(0));
- complex.add_edge(Vertex_handle(1),Vertex_handle(3));
- complex.add_edge(Vertex_handle(2),Vertex_handle(3));
- complex.add_edge(Vertex_handle(2),Vertex_handle(5));
- complex.add_edge(Vertex_handle(3),Vertex_handle(5));
- complex.add_edge(Vertex_handle(2),Vertex_handle(4));
- complex.add_edge(Vertex_handle(4),Vertex_handle(5));
- complex.add_edge(Vertex_handle(3),Vertex_handle(4));
-
- complex.add_blocker(Simplex_handle(Vertex_handle(2),Vertex_handle(3),Vertex_handle(4),Vertex_handle(5)));
-
- bool correct_number_simplices = true;
-
- std::map<Vertex_handle,unsigned> expected_num_simplices;
-
- expected_num_simplices[Vertex_handle(0)] = 4;
- expected_num_simplices[Vertex_handle(1)] = 6;
- expected_num_simplices[Vertex_handle(2)] = 11;
- expected_num_simplices[Vertex_handle(3)] = 9;
- expected_num_simplices[Vertex_handle(4)] = 7;
- expected_num_simplices[Vertex_handle(5)] = 7;
-
- for(auto pair : expected_num_simplices){
- unsigned num_simplices_around = 0;
- for(const auto& simplex : complex.simplex_range(pair.first)){
- simplex.dimension();
- DBGVALUE(simplex);
- ++num_simplices_around;
- }
-
- correct_number_simplices = correct_number_simplices && (num_simplices_around == pair.second);
-
- DBGMSG("current vertex:",pair.first);
- DBGMSG("expected_num_simplices:",pair.second);
- DBGMSG("found:",num_simplices_around);
- }
- return correct_number_simplices;
+bool assert_blocker(Complex &complex, Root_vertex_handle a, Root_vertex_handle b, Root_vertex_handle c) {
+ return true;
+ //return complex.contains_blocker((a),(b),(c));
}
+// true iff the blocker (a,b,c,d) is in complex
-
-bool test_iterator_simplices2(){
- Complex complex(2);
- complex.add_edge(Vertex_handle(0),Vertex_handle(1));
-
- for(const auto& s:complex.triangle_range()){
- s.dimension();
- return false; // there are no triangles
- }
-
- unsigned num_simplices = 0 ;
-
-
- DBGVALUE(complex.to_string());
-
- for(const auto& simplex : complex.simplex_range(Vertex_handle(0))){
- simplex.dimension();
- DBGVALUE(simplex);
- }
-
-
- for(const auto& simplex : complex.simplex_range()){
- DBGVALUE(simplex);
- simplex.dimension();
- ++num_simplices;
- }
- bool correct_number_simplices = (num_simplices == 3);
- return correct_number_simplices;
+bool assert_blocker(Complex &complex, Root_vertex_handle a, Root_vertex_handle b, Root_vertex_handle c, Root_vertex_handle d) {
+ return true;
+ //Simplex blocker (a,b,c,d);
+ //return complex.contains_blocker(&blocker);
+}
+
+void build_complete(int n, Complex& complex) {
+ complex.clear();
+ for (int i = 0; i < n; i++)
+ complex.add_vertex();
+
+ // for(int i=n-1;i>=0;i--)
+ // for(int j=i-1;j>=0;j--)
+ // complex.add_edge_without_blockers(Vertex_handle(i),Vertex_handle(j));
+
+ for (int i = 0; i < n; i++)
+ for (int j = 0; j < i; j++)
+ complex.add_edge_without_blockers(Vertex_handle(i), Vertex_handle(j));
+}
+
+bool test_simplex() {
+ // PRINT("test simplex");
+ Simplex simplex(Vertex_handle(0), Vertex_handle(1), Vertex_handle(2), Vertex_handle(3));
+ for (auto i = simplex.begin(); i != simplex.end(); ++i) {
+ PRINT(*i);
+ auto j = i;
+ for (++j;
+ j != simplex.end();
+ ++j) {
+ PRINT(*j);
+ }
+ }
+ return simplex.dimension() == 3;
+}
+
+bool test_num_simplices() {
+ int n = 4;
+ Complex complex;
+ build_complete(n, complex);
+ size_t sum = 0;
+ for (int i = 0; i < n; i++) {
+ PRINT(complex.num_simplices(i));
+ sum += complex.num_simplices(i);
+ }
+ return
+ complex.num_vertices() == n &&
+ complex.num_edges() == 6 &&
+ sum == 15 &&
+ complex.num_simplices() == 15;
+}
+
+
+bool test_iterator_vertices1() {
+ int n = 10;
+ Complex complex(10);
+ cerr << "complex.num_vertices():" << complex.num_vertices() << endl;
+ int num_vertex_seen = 0;
+ for (auto vi : complex.vertex_range()) {
+ cerr << "vertex:" << vi << endl;
+ ++num_vertex_seen;
+ }
+ return num_vertex_seen == n;
+}
+
+bool test_iterator_vertices2() {
+ int n = 10;
+ Complex complex;
+ build_complete(10, complex);
+ cerr << "complex.num_vertices():" << complex.num_vertices() << endl;
+ cerr << "complex.num_edges():" << complex.num_edges() << endl;
+ int num_vertex_seen = 0;
+ for (auto vi : complex.vertex_range(Vertex_handle(2))) {
+ cerr << "vertex:" << vi << endl;
+ ++num_vertex_seen;
+ }
+ std::cerr << "num_vertex_seen:" << num_vertex_seen << std::endl;
+ return num_vertex_seen == (n - 1);
+}
+
+bool test_iterator_edge() {
+ const int n = 10;
+ Complex complex(n);
+ for (int i = 0; i < n; i++)
+ for (int j = 0; j < i; j++)
+ complex.add_edge_without_blockers(Vertex_handle(i), Vertex_handle(j));
+ complex.remove_edge(Vertex_handle(2), Vertex_handle(3));
+ complex.remove_edge(Vertex_handle(3), Vertex_handle(5));
+ cerr << "complex.num_edges():" << complex.num_edges() << endl;
+ int num_edges_seen = 0;
+ for (auto edge : complex.edge_range()) {
+ cerr << "edge :" << complex[edge] << endl;
+ ++num_edges_seen;
+ }
+
+ return num_edges_seen == n * (n - 1) / 2 - 2;
+}
+
+bool test_iterator_edge2() {
+ const int n = 10;
+ Complex complex(n);
+ for (int i = 0; i < n; i++)
+ for (int j = 0; j < i; j++)
+ complex.add_edge_without_blockers(Vertex_handle(i), Vertex_handle(j));
+ complex.remove_edge(Vertex_handle(2), Vertex_handle(3));
+ complex.remove_edge(Vertex_handle(3), Vertex_handle(5));
+ cerr << "complex.num_edges():" << complex.num_edges() << endl;
+ int num_neigbors_seen = 0;
+ for (auto neighbor : complex.vertex_range(Vertex_handle(2))) {
+ cerr << "neighbor" << neighbor << endl;
+ ++num_neigbors_seen;
+ }
+ return num_neigbors_seen == 8;
+}
+
+bool test_iterator_edge3() {
+ const int n = 10;
+ Complex complex(n);
+ for (int i = 0; i < n; i++)
+ for (int j = 0; j < i; j++)
+ complex.add_edge_without_blockers(Vertex_handle(i), Vertex_handle(j));
+ complex.remove_edge(Vertex_handle(2), Vertex_handle(3));
+ complex.remove_edge(Vertex_handle(3), Vertex_handle(5));
+ cerr << "complex.num_edges():" << complex.num_edges() << endl;
+ int num_neigbors_seen = 0;
+ for (auto edge : complex.edge_range(Vertex_handle(2))) {
+ std::cerr << edge << std::endl;
+ ++num_neigbors_seen;
+ }
+ return num_neigbors_seen == 8;
+}
+
+bool test_iterator_triangles() {
+ const int n = 7;
+ Complex complex(n);
+ //create a "ring" around '0'
+ for (int i = 1; i < n; i++)
+ complex.add_edge_without_blockers(Vertex_handle(0), Vertex_handle(i));
+ for (int i = 1; i < n - 1; i++)
+ complex.add_edge_without_blockers(Vertex_handle(i), Vertex_handle(i + 1));
+ complex.add_edge_without_blockers(Vertex_handle(1), Vertex_handle(6));
+
+ PRINT(complex.to_string());
+
+ int num_triangles_seen = 0;
+ //for (auto t : complex.triangle_range(5)){
+ TEST("triangles around 5 (should be 2 of them):");
+ for (auto t : complex.triangle_range(Vertex_handle(5))) {
+ PRINT(t);
+ ++num_triangles_seen;
+ }
+ bool test = (num_triangles_seen == 2);
+
+ num_triangles_seen = 0;
+ TEST("triangles around 0 (should be 6 of them):");
+ for (auto t : complex.triangle_range(Vertex_handle(0))) {
+ PRINT(t);
+ ++num_triangles_seen;
+ }
+ test = test && (num_triangles_seen == 6);
+
+ // we now add another triangle
+ complex.add_vertex();
+ complex.add_edge_without_blockers(Vertex_handle(4), Vertex_handle(7));
+ complex.add_edge_without_blockers(Vertex_handle(3), Vertex_handle(7));
+ complex.add_blocker(Simplex(Vertex_handle(0), Vertex_handle(1), Vertex_handle(6)));
+ num_triangles_seen = 0;
+
+ TEST("triangles (should be 6 of them):");
+ num_triangles_seen = 0;
+ for (auto t : complex.triangle_range()) {
+ PRINT(t);
+ ++num_triangles_seen;
+ }
+ test = test && (num_triangles_seen == 6);
+ PRINT(num_triangles_seen);
+
+ return test;
}
-bool test_iterator_simplices3(){
- Complex complex(3);
- complex.add_edge(Vertex_handle(0),Vertex_handle(1));
- complex.add_edge(Vertex_handle(1),Vertex_handle(2));
- complex.add_edge(Vertex_handle(2),Vertex_handle(0));
- complex.add_blocker(Simplex_handle(Vertex_handle(0),Vertex_handle(1),Vertex_handle(2)));
-
- unsigned num_simplices = 0 ;
-
- for(const auto& simplex : complex.simplex_range(Vertex_handle(0))){
- simplex.dimension();
- DBGVALUE(simplex);
- }
-
+//#include "combinatorics/Skeleton_blocker/iterators/Skeleton_blockers_simplices_iterators.h"
- for(const auto& simplex : complex.simplex_range()){
- DBGVALUE(simplex);
- simplex.dimension();
- ++num_simplices;
- }
- bool correct_number_simplices = (num_simplices == 6);
- return correct_number_simplices;
+bool test_iterator_simplices() {
+ Complex complex(6);
+ complex.add_edge_without_blockers(Vertex_handle(0), Vertex_handle(1));
+ complex.add_edge_without_blockers(Vertex_handle(1), Vertex_handle(2));
+ complex.add_edge_without_blockers(Vertex_handle(2), Vertex_handle(0));
+ complex.add_edge_without_blockers(Vertex_handle(1), Vertex_handle(3));
+ complex.add_edge_without_blockers(Vertex_handle(2), Vertex_handle(3));
+ complex.add_edge_without_blockers(Vertex_handle(2), Vertex_handle(5));
+ complex.add_edge_without_blockers(Vertex_handle(3), Vertex_handle(5));
+ complex.add_edge_without_blockers(Vertex_handle(2), Vertex_handle(4));
+ complex.add_edge_without_blockers(Vertex_handle(4), Vertex_handle(5));
+ complex.add_edge_without_blockers(Vertex_handle(3), Vertex_handle(4));
+
+ complex.add_blocker(Simplex(Vertex_handle(2), Vertex_handle(3), Vertex_handle(4), Vertex_handle(5)));
+
+ bool correct_number_simplices = true;
+
+ std::map<Vertex_handle, unsigned> expected_num_simplices;
+
+ expected_num_simplices[Vertex_handle(0)] = 4;
+ expected_num_simplices[Vertex_handle(1)] = 6;
+ expected_num_simplices[Vertex_handle(2)] = 11;
+ expected_num_simplices[Vertex_handle(3)] = 9;
+ expected_num_simplices[Vertex_handle(4)] = 7;
+ expected_num_simplices[Vertex_handle(5)] = 7;
+
+ for (auto pair : expected_num_simplices) {
+ unsigned num_simplices_around = 0;
+ for (const auto& simplex : complex.star_simplex_range(pair.first)) {
+ simplex.dimension();
+ DBGVALUE(simplex);
+ ++num_simplices_around;
+ }
+
+ correct_number_simplices = correct_number_simplices && (num_simplices_around == pair.second);
+
+ DBGMSG("current vertex:", pair.first);
+ DBGMSG("expected_num_simplices:", pair.second);
+ DBGMSG("found:", num_simplices_around);
+ }
+ return correct_number_simplices;
+}
+
+bool test_iterator_simplices2() {
+ Complex complex(2);
+ complex.add_edge_without_blockers(Vertex_handle(0), Vertex_handle(1));
+
+ for (const auto& s : complex.triangle_range()) {
+ s.dimension();
+ return false; // there are no triangles
+ }
+
+ unsigned num_simplices = 0;
+
+
+ DBGVALUE(complex.to_string());
+
+ for (const auto& simplex : complex.star_simplex_range(Vertex_handle(0))) {
+ simplex.dimension();
+ DBGVALUE(simplex);
+ }
+
+
+ for (const auto& simplex : complex.complex_simplex_range()) {
+ DBGVALUE(simplex);
+ simplex.dimension();
+ ++num_simplices;
+ }
+ bool correct_number_simplices = (num_simplices == 3);
+ return correct_number_simplices;
+}
+
+bool test_iterator_simplices3() {
+ Complex complex(3);
+ complex.add_edge_without_blockers(Vertex_handle(0), Vertex_handle(1));
+ complex.add_edge_without_blockers(Vertex_handle(1), Vertex_handle(2));
+ complex.add_edge_without_blockers(Vertex_handle(2), Vertex_handle(0));
+ complex.add_blocker(Simplex(Vertex_handle(0), Vertex_handle(1), Vertex_handle(2)));
+
+ unsigned num_simplices = 0;
+
+ for (const auto& simplex : complex.star_simplex_range(Vertex_handle(0))) {
+ simplex.dimension();
+ DBGVALUE(simplex);
+ }
+
+
+ for (const auto& simplex : complex.complex_simplex_range()) {
+ DBGVALUE(simplex);
+ simplex.dimension();
+ ++num_simplices;
+ }
+ bool correct_number_simplices = (num_simplices == 6);
+ return correct_number_simplices;
+}
+
+bool test_iterator_simplices4() {
+ Complex empty_complex;
+ for (auto v : empty_complex.vertex_range()) {
+ (void) v;
+ }
+ for (auto e : empty_complex.edge_range()) {
+ empty_complex[e];
+ }
+ for (auto t : empty_complex.triangle_range()) {
+ t.dimension();
+ }
+ for (auto s : empty_complex.complex_simplex_range()) {
+ s.dimension();
+ }
+ return true;
}
-bool test_iterator_simplices4(){
- Complex empty_complex;
- for(auto v : empty_complex.vertex_range()){
- (void) v;
- }
- for(auto e : empty_complex.edge_range()){
- empty_complex[e];
- }
- for(auto t : empty_complex.triangle_range()){
- t.dimension();
- }
- for(auto s : empty_complex.simplex_range()){
- s.dimension();
- }
- return true;
+bool test_iterator_coboundary() {
+ Complex c;
+ build_complete(4, c);
+ c.remove_edge(Vertex_handle(1), Vertex_handle(3));
+ PRINT(c.to_string());
+ Simplex s02(Vertex_handle(0), Vertex_handle(2));
+ int n = 0;
+ std::set<Simplex> expected;
+ expected.insert(Simplex(Vertex_handle(0), Vertex_handle(1), Vertex_handle(2)));
+ expected.insert(Simplex(Vertex_handle(0), Vertex_handle(2), Vertex_handle(3)));
+ for (const auto & s : c.coboundary_range(s02)) {
+ PRINT(s);
+ if (expected.find(s) == expected.end())
+ return false;
+ ++n;
+ }
+ return n == 2;
}
-
template<typename Map>
-auto blocker_range(Map map) -> decltype( map | boost::adaptors::map_values){
- return map| boost::adaptors::map_values ;
-}
-
-
-bool test_iterator_blockers(){
- Complex complex;
- Simplex_handle alpha;
- Simplex_handle vertex_set_expected;
- // Build the complexes
- for (int i=0;i<20;i++){
- complex.add_vertex();
- }
- for (int i=10;i<15;i++){
- for (int j=i+1;j<15;j++)
- complex.add_edge(Vertex_handle(i),Vertex_handle(j));
- }
-
- complex.add_blocker(Simplex_handle(Vertex_handle(10),Vertex_handle(11),Vertex_handle(12)));
- complex.add_blocker(Simplex_handle(Vertex_handle(2),Vertex_handle(1),Vertex_handle(10)));
- complex.add_blocker(Simplex_handle(Vertex_handle(10),Vertex_handle(9),Vertex_handle(15)));
- complex.add_blocker(Simplex_handle(Vertex_handle(1),Vertex_handle(9),Vertex_handle(8)));
-
- // Print result
- int num_blockers=0;
- for(auto blockers : complex.blocker_range(Vertex_handle(10))){
- TESTVALUE(*blockers) ;
- num_blockers++;
- }
- bool test = (num_blockers==3);
-
- num_blockers=0;
- for (auto blockers : complex.blocker_range()){
- TESTVALUE(*blockers) ;
- num_blockers++;
- }
- test = test && (num_blockers==4) ;
-
- return test;
-}
-
-
-bool test_link0(){
-
- enum { a, b, c, d, n };
- Complex complex(n);
- complex.add_edge(Vertex_handle(b),Vertex_handle(c));complex.add_edge(Vertex_handle(c),Vertex_handle(d));
- Simplex_handle alpha = Simplex_handle(Vertex_handle(c));
- Skeleton_blocker_link_complex<Complex> L(complex,alpha);
-
- auto L2 = complex.link(alpha);
- if(L!=L2) return false;
-
- PRINT(L.num_vertices());
- PRINT(L.to_string());
-
- bool test1 = L.contains_vertex(*L.get_address(Root_vertex_handle(b)));
- bool test2 = L.contains_vertex(*L.get_address(Root_vertex_handle(d)));
- bool test3 = L.num_edges()==0;
- bool test4 = L.num_blockers()==0;
- return test1&&test2&&test3&&test4;
-
-}
-
-bool test_link1(){
- Complex complex;
-
-
- // Build the complexes
- for (int i=0;i<20;i++){
- complex.add_vertex();
- }
- for (int i=10;i<15;i++){
- for (int j=i+1;j<15;j++)
- complex.add_edge(Vertex_handle(i),Vertex_handle(j));
- }
- Simplex_handle alpha(Vertex_handle(12),Vertex_handle(14));
- Skeleton_blocker_link_complex<Complex> L(complex,alpha);
- // Complexes built
-
- auto L2 = complex.link(alpha);
- if(L!=L2) return false;
-
- // verification
- bool test1 = L.contains_vertex(*L.get_address(Root_vertex_handle(10)));
- bool test2 = L.contains_vertex(*L.get_address(Root_vertex_handle(11)));
- bool test3 = L.contains_vertex(*L.get_address(Root_vertex_handle(13)));
- bool test4 = L.num_edges()==3;
- bool test5 = L.num_blockers()==0;
- Root_simplex_handle simplex;
- simplex.add_vertex(Root_vertex_handle(10));
- simplex.add_vertex(Root_vertex_handle(11));
- simplex.add_vertex(Root_vertex_handle(13));
- bool test6(L.get_simplex_address(simplex));
- bool test7 = L.contains(*(L.get_simplex_address(simplex)));
- cerr <<"----> Ocomplex \n";
- return test1&&test2&&test3&&test4&&test5&&test6&&test7 ;
-
-}
-
-
-bool test_link2(){
- Complex complex;
-
- Simplex_handle alpha;
- Simplex_handle vertex_set_expected;
- // Build the complexes
- for (int i=0;i<20;i++){
- complex.add_vertex();
- }
- for (int i=10;i<15;i++){
- for (int j=i+1;j<15;j++)
- complex.add_edge(Vertex_handle(i),Vertex_handle(j));
- }
- complex.add_blocker(Simplex_handle(Vertex_handle(10),Vertex_handle(11),Vertex_handle(13)));
- alpha = Simplex_handle(Vertex_handle(12),Vertex_handle(14));
- Skeleton_blocker_link_complex<Complex> L(complex,alpha);
- // Complexes built
-
- // Print result
- cerr << "complex complex"<< complex.to_string();
- cerr <<endl<<endl;
- cerr << "L= Link_complex("<<alpha<<") : \n"<<L.to_string();
-
- auto L2 = complex.link(alpha);
- if(L!=L2) return false;
-
-
- // verification
- bool test1 = L.contains_vertex(*L.get_address(Root_vertex_handle(10)));
- bool test2 = L.contains_vertex(*L.get_address(Root_vertex_handle(11)));
- bool test3 = L.contains_vertex(*L.get_address(Root_vertex_handle(13)));
- bool test4 = L.num_edges()==3;
- bool test5 = L.num_blockers()==1;
- Root_simplex_handle simplex;
- simplex.add_vertex(Root_vertex_handle(10));
- simplex.add_vertex(Root_vertex_handle(11));
- simplex.add_vertex(Root_vertex_handle(13));
- bool test6 = L.contains_blocker(*(L.get_simplex_address(simplex)));
- cerr <<"----> Ocomplex \n";
- return test1&&test2&&test3&&test4&&test5&&test6 ;
-}
-
-bool test_link3(){
- Complex complex;
-
- Simplex_handle alpha;
- Simplex_handle vertex_set_expected;
- // Build the complexes
- for (int i=0;i<20;i++){
- complex.add_vertex();
- }
- for (int i=10;i<15;i++){
- for (int j=i+1;j<15;j++)
- complex.add_edge(Vertex_handle(i),Vertex_handle(j));
- }
- complex.add_blocker(Simplex_handle(Vertex_handle(10),Vertex_handle(11),Vertex_handle(12)));
- alpha = Simplex_handle(Vertex_handle(12),Vertex_handle(14));
- Skeleton_blocker_link_complex<Complex> L(complex,alpha);
- // Complexes built
-
- // Print result
- cerr << "complex complex"<< complex.to_string();
- cerr <<endl<<endl;
- cerr << "L= Link_complex("<<alpha<<") : \n"<<L.to_string();
-
- auto L2 = complex.link(alpha);
- if(L!=L2) return false;
-
-
- // verification
- bool test = assert_vertex(L,*L.get_address(Root_vertex_handle(10)));
- test = test&& assert_vertex(L,*L.get_address(Root_vertex_handle(11)));
- test = test&& assert_vertex(L,*L.get_address(Root_vertex_handle(13)));
- test = test&& L.num_edges()==2;
- test = test&&L.contains_edge(*L.get_address(Root_vertex_handle(10)),*L.get_address(Root_vertex_handle(13)));
- test=test&&L.contains_edge(*L.get_address(Root_vertex_handle(13)),*L.get_address(Root_vertex_handle(11)));
- test=test&&L.num_blockers()==0;
- return test;
-}
-
-bool test_link4(){
- Complex complex;
-
- // Build the complexes
- for (int i=0;i<20;i++){
- complex.add_vertex();
- }
- for (int i=10;i<15;i++){
- for (int j=i+1;j<15;j++)
- complex.add_edge(Vertex_handle(i),Vertex_handle(j));
- }
- complex.add_blocker(Simplex_handle(Vertex_handle(10),Vertex_handle(11),Vertex_handle(12),Vertex_handle(13)));
- Simplex_handle alpha(Vertex_handle(12),Vertex_handle(14));
- Skeleton_blocker_link_complex<Complex> L(complex,alpha);
- // Complexes built
-
- // verification
- bool test1 = L.contains_vertex(*L.get_address(Root_vertex_handle(10)));
- bool test2 = L.contains_vertex(*L.get_address(Root_vertex_handle(11)));
- bool test3 = L.contains_vertex(*L.get_address(Root_vertex_handle(13)));
- bool test4 = L.num_edges()==3;
- bool test5 = L.num_blockers()==1;
- Root_simplex_handle simplex;
- simplex.add_vertex(Root_vertex_handle(10));
- simplex.add_vertex(Root_vertex_handle(11));
- simplex.add_vertex(Root_vertex_handle(13));
- bool test6 = L.contains_blocker(*(L.get_simplex_address(simplex)));
- cerr <<"----> Ocomplex \n";
- return test1&&test2&&test3&&test4&&test5&&test6 ;
-
-}
-
-bool test_link5(){
- Complex complex(0,new Print_complex_visitor<Vertex_handle>());
- // Build the complexes
- build_complete(4,complex);
- complex.add_blocker(Simplex_handle(Vertex_handle(0),Vertex_handle(1),Vertex_handle(2),Vertex_handle(3)));
-
- Simplex_handle alpha(Vertex_handle(0),Vertex_handle(1),Vertex_handle(2));
+auto blocker_range(Map map) -> decltype(map | boost::adaptors::map_values) {
+ return map | boost::adaptors::map_values;
+}
+
+bool test_iterator_blockers() {
+ Complex complex;
+ Simplex alpha;
+ Simplex vertex_set_expected;
+ // Build the complexes
+ for (int i = 0; i < 20; i++) {
+ complex.add_vertex();
+ }
+ for (int i = 10; i < 15; i++) {
+ for (int j = i + 1; j < 15; j++)
+ complex.add_edge_without_blockers(Vertex_handle(i), Vertex_handle(j));
+ }
+
+ complex.add_blocker(Simplex(Vertex_handle(10), Vertex_handle(11), Vertex_handle(12)));
+ complex.add_blocker(Simplex(Vertex_handle(2), Vertex_handle(1), Vertex_handle(10)));
+ complex.add_blocker(Simplex(Vertex_handle(10), Vertex_handle(9), Vertex_handle(15)));
+ complex.add_blocker(Simplex(Vertex_handle(1), Vertex_handle(9), Vertex_handle(8)));
+
+ // Print result
+ int num_blockers = 0;
+ for (auto blockers : complex.blocker_range(Vertex_handle(10))) {
+ TESTVALUE(*blockers);
+ num_blockers++;
+ }
+ bool test = (num_blockers == 3);
+
+ num_blockers = 0;
+ for (auto blockers : complex.blocker_range()) {
+ TESTVALUE(*blockers);
+ num_blockers++;
+ }
+ test = test && (num_blockers == 4);
+
+ return test;
+}
+
+bool test_link0() {
+
+ enum {
+ a, b, c, d, n
+ };
+ Complex complex(n);
+ complex.add_edge_without_blockers(Vertex_handle(b), Vertex_handle(c));
+ complex.add_edge_without_blockers(Vertex_handle(c), Vertex_handle(d));
+ Simplex alpha = Simplex(Vertex_handle(c));
+ Skeleton_blocker_link_complex<Complex> L(complex, alpha);
+
+ auto L2 = complex.link(alpha);
+ if (L != L2) return false;
+
+ PRINT(L.num_vertices());
+ PRINT(L.to_string());
+
+ bool test1 = L.contains_vertex(*L.get_address(Root_vertex_handle(b)));
+ bool test2 = L.contains_vertex(*L.get_address(Root_vertex_handle(d)));
+ bool test3 = L.num_edges() == 0;
+ bool test4 = L.num_blockers() == 0;
+ return test1 && test2 && test3&&test4;
+
+}
+
+bool test_link1() {
+ Complex complex;
+
+
+ // Build the complexes
+ for (int i = 0; i < 20; i++) {
+ complex.add_vertex();
+ }
+ for (int i = 10; i < 15; i++) {
+ for (int j = i + 1; j < 15; j++)
+ complex.add_edge_without_blockers(Vertex_handle(i), Vertex_handle(j));
+ }
+ Simplex alpha(Vertex_handle(12), Vertex_handle(14));
+ Skeleton_blocker_link_complex<Complex> L(complex, alpha);
+ // Complexes built
+
+ auto L2 = complex.link(alpha);
+ if (L != L2) return false;
+
+ // verification
+ bool test1 = L.contains_vertex(*L.get_address(Root_vertex_handle(10)));
+ bool test2 = L.contains_vertex(*L.get_address(Root_vertex_handle(11)));
+ bool test3 = L.contains_vertex(*L.get_address(Root_vertex_handle(13)));
+ bool test4 = L.num_edges() == 3;
+ bool test5 = L.num_blockers() == 0;
+ Root_simplex_handle simplex;
+ simplex.add_vertex(Root_vertex_handle(10));
+ simplex.add_vertex(Root_vertex_handle(11));
+ simplex.add_vertex(Root_vertex_handle(13));
+ bool test6(L.get_simplex_address(simplex));
+ bool test7 = L.contains(*(L.get_simplex_address(simplex)));
+ cerr << "----> Ocomplex \n";
+ return test1 && test2 && test3 && test4 && test5 && test6&&test7;
+
+}
+
+bool test_link2() {
+ Complex complex;
+
+ Simplex alpha;
+ Simplex vertex_set_expected;
+ // Build the complexes
+ for (int i = 0; i < 20; i++) {
+ complex.add_vertex();
+ }
+ for (int i = 10; i < 15; i++) {
+ for (int j = i + 1; j < 15; j++)
+ complex.add_edge_without_blockers(Vertex_handle(i), Vertex_handle(j));
+ }
+ complex.add_blocker(Simplex(Vertex_handle(10), Vertex_handle(11), Vertex_handle(13)));
+ alpha = Simplex(Vertex_handle(12), Vertex_handle(14));
+ Skeleton_blocker_link_complex<Complex> L(complex, alpha);
+ // Complexes built
+
+ // Print result
+ cerr << "complex complex" << complex.to_string();
+ cerr << endl << endl;
+ cerr << "L= Link_complex(" << alpha << ") : \n" << L.to_string();
+
+ auto L2 = complex.link(alpha);
+ if (L != L2) return false;
+
+
+ // verification
+ bool test1 = L.contains_vertex(*L.get_address(Root_vertex_handle(10)));
+ bool test2 = L.contains_vertex(*L.get_address(Root_vertex_handle(11)));
+ bool test3 = L.contains_vertex(*L.get_address(Root_vertex_handle(13)));
+ bool test4 = L.num_edges() == 3;
+ bool test5 = L.num_blockers() == 1;
+ Root_simplex_handle simplex;
+ simplex.add_vertex(Root_vertex_handle(10));
+ simplex.add_vertex(Root_vertex_handle(11));
+ simplex.add_vertex(Root_vertex_handle(13));
+ bool test6 = L.contains_blocker(*(L.get_simplex_address(simplex)));
+ cerr << "----> Ocomplex \n";
+ return test1 && test2 && test3 && test4 && test5&&test6;
+}
+
+bool test_link3() {
+ Complex complex;
+
+ Simplex alpha;
+ Simplex vertex_set_expected;
+ // Build the complexes
+ for (int i = 0; i < 20; i++) {
+ complex.add_vertex();
+ }
+ for (int i = 10; i < 15; i++) {
+ for (int j = i + 1; j < 15; j++)
+ complex.add_edge_without_blockers(Vertex_handle(i), Vertex_handle(j));
+ }
+ complex.add_blocker(Simplex(Vertex_handle(10), Vertex_handle(11), Vertex_handle(12)));
+ alpha = Simplex(Vertex_handle(12), Vertex_handle(14));
+ Skeleton_blocker_link_complex<Complex> L(complex, alpha);
+ // Complexes built
+
+ // Print result
+ cerr << "complex complex" << complex.to_string();
+ cerr << endl << endl;
+ cerr << "L= Link_complex(" << alpha << ") : \n" << L.to_string();
+
+ auto L2 = complex.link(alpha);
+ if (L != L2) return false;
+
+
+ // verification
+ bool test = assert_vertex(L, *L.get_address(Root_vertex_handle(10)));
+ test = test && assert_vertex(L, *L.get_address(Root_vertex_handle(11)));
+ test = test && assert_vertex(L, *L.get_address(Root_vertex_handle(13)));
+ test = test && L.num_edges() == 2;
+ test = test && L.contains_edge(*L.get_address(Root_vertex_handle(10)), *L.get_address(Root_vertex_handle(13)));
+ test = test && L.contains_edge(*L.get_address(Root_vertex_handle(13)), *L.get_address(Root_vertex_handle(11)));
+ test = test && L.num_blockers() == 0;
+ return test;
+}
+
+bool test_link4() {
+ Complex complex;
+
+ // Build the complexes
+ for (int i = 0; i < 20; i++) {
+ complex.add_vertex();
+ }
+ for (int i = 10; i < 15; i++) {
+ for (int j = i + 1; j < 15; j++)
+ complex.add_edge_without_blockers(Vertex_handle(i), Vertex_handle(j));
+ }
+ complex.add_blocker(Simplex(Vertex_handle(10), Vertex_handle(11), Vertex_handle(12), Vertex_handle(13)));
+ Simplex alpha(Vertex_handle(12), Vertex_handle(14));
+ Skeleton_blocker_link_complex<Complex> L(complex, alpha);
+ // Complexes built
+
+ // verification
+ bool test1 = L.contains_vertex(*L.get_address(Root_vertex_handle(10)));
+ bool test2 = L.contains_vertex(*L.get_address(Root_vertex_handle(11)));
+ bool test3 = L.contains_vertex(*L.get_address(Root_vertex_handle(13)));
+ bool test4 = L.num_edges() == 3;
+ bool test5 = L.num_blockers() == 1;
+ Root_simplex_handle simplex;
+ simplex.add_vertex(Root_vertex_handle(10));
+ simplex.add_vertex(Root_vertex_handle(11));
+ simplex.add_vertex(Root_vertex_handle(13));
+ bool test6 = L.contains_blocker(*(L.get_simplex_address(simplex)));
+ cerr << "----> Ocomplex \n";
+ return test1 && test2 && test3 && test4 && test5&&test6;
+
+}
+
+bool test_link5() {
+ Complex complex(0);
+ // Build the complexes
+ build_complete(4, complex);
+ complex.add_blocker(Simplex(Vertex_handle(0), Vertex_handle(1), Vertex_handle(2), Vertex_handle(3)));
+
+ Simplex alpha(Vertex_handle(0), Vertex_handle(1), Vertex_handle(2));
+
+
+ Skeleton_blocker_link_complex<Complex> L(complex, alpha); // Complexes built
+
+ // Print result
+ PRINT(complex.to_string());
+ cerr << endl << endl;
+ PRINT(L.to_string());
+
+ // verification
+ return L.num_vertices() == 0;
+}
+
+bool test_link6() {
+ Complex complex(0);
+ // Build the complexes
+ build_complete(4, complex);
+ complex.add_blocker(Simplex(Vertex_handle(0), Vertex_handle(1), Vertex_handle(2)));
+ Simplex alpha(Vertex_handle(0), Vertex_handle(1), Vertex_handle(2));
- Skeleton_blocker_link_complex<Complex> L(complex,alpha); // Complexes built
+ Skeleton_blocker_link_complex<Complex> link_blocker_alpha;
- // Print result
- PRINT(complex.to_string());
- cerr <<endl<<endl;
- PRINT(L.to_string());
+ build_link_of_blocker(complex, alpha, link_blocker_alpha);
+
+ // Print result
+ PRINT(complex.to_string());
+ cerr << endl << endl;
+ PRINT(link_blocker_alpha.to_string());
- // verification
- return L.num_vertices()==0;
+ // verification
+ return link_blocker_alpha.num_vertices() == 1;
}
-bool test_link6(){
- Complex complex(0,new Print_complex_visitor<Vertex_handle>());
- // Build the complexes
- build_complete(4,complex);
- complex.add_blocker(Simplex_handle(Vertex_handle(0),Vertex_handle(1),Vertex_handle(2)));
+bool test_link7() {
+ Complex complex(0);
+ // Build the complexes
+ build_complete(6, complex);
+ complex.add_vertex();
+ complex.add_vertex();
+ for (int i = 3; i < 6; ++i) {
+ complex.add_edge_without_blockers(Vertex_handle(i), Vertex_handle(6));
+ complex.add_edge_without_blockers(Vertex_handle(i), Vertex_handle(7));
+ }
+ complex.add_edge_without_blockers(Vertex_handle(6), Vertex_handle(7));
+ complex.add_blocker(Simplex(Vertex_handle(0), Vertex_handle(1), Vertex_handle(2)));
+ complex.add_blocker(Simplex(Vertex_handle(3), Vertex_handle(4), Vertex_handle(5)));
- Simplex_handle alpha(Vertex_handle(0),Vertex_handle(1),Vertex_handle(2));
+ Simplex alpha(Vertex_handle(3), Vertex_handle(4), Vertex_handle(5));
- Skeleton_blocker_link_complex<Complex> link_blocker_alpha;
+ Skeleton_blocker_link_complex<Complex> link_blocker_alpha;
- build_link_of_blocker(complex,alpha,link_blocker_alpha);
+ build_link_of_blocker(complex, alpha, link_blocker_alpha);
- // Print result
- PRINT(complex.to_string());
- cerr <<endl<<endl;
- PRINT(link_blocker_alpha.to_string());
+ //the result should be the edge {6,7} plus the blocker {0,1,2}
- // verification
- return link_blocker_alpha.num_vertices()==1;
-}
-
-
-bool test_link7(){
- Complex complex(0,new Print_complex_visitor<Vertex_handle>());
- // Build the complexes
- build_complete(6,complex);
- complex.add_vertex();
- complex.add_vertex();
- for(int i = 3; i<6; ++i){
- complex.add_edge(Vertex_handle(i),Vertex_handle(6));
- complex.add_edge(Vertex_handle(i),Vertex_handle(7));
- }
- complex.add_edge(Vertex_handle(6),Vertex_handle(7));
- complex.add_blocker(Simplex_handle(Vertex_handle(0),Vertex_handle(1),Vertex_handle(2)));
- complex.add_blocker(Simplex_handle(Vertex_handle(3),Vertex_handle(4),Vertex_handle(5)));
-
- Simplex_handle alpha(Vertex_handle(3),Vertex_handle(4),Vertex_handle(5));
-
- Skeleton_blocker_link_complex<Complex> link_blocker_alpha;
-
- build_link_of_blocker(complex,alpha,link_blocker_alpha);
+ // Print result
+ PRINT(complex.to_string());
+ cerr << endl << endl;
+ DBGVALUE(link_blocker_alpha.to_string());
- //the result should be the edge {6,7} plus the blocker {0,1,2}
+ Skeleton_blocker_link_complex<Complex> link_blocker_alpha_cpy = link_blocker_alpha;
- // Print result
- PRINT(complex.to_string());
- cerr <<endl<<endl;
- DBGVALUE(link_blocker_alpha.to_string());
+ DBGVALUE(link_blocker_alpha_cpy.to_string());
- Skeleton_blocker_link_complex<Complex> link_blocker_alpha_cpy = link_blocker_alpha;
+ bool equal_complexes =
+ (link_blocker_alpha.num_vertices() == link_blocker_alpha_cpy.num_vertices())
+ &&(link_blocker_alpha.num_blockers() == link_blocker_alpha_cpy.num_blockers())
+ &&(link_blocker_alpha.num_edges() == link_blocker_alpha_cpy.num_edges())
+ ;
+ DBGVALUE((link_blocker_alpha.num_blockers() == link_blocker_alpha_cpy.num_blockers()));
+ DBGVALUE((link_blocker_alpha.num_blockers()));
+ DBGVALUE((link_blocker_alpha_cpy.num_blockers()));
- DBGVALUE(link_blocker_alpha_cpy.to_string());
+ DBGVALUE(equal_complexes);
- bool equal_complexes =
- (link_blocker_alpha.num_vertices() == link_blocker_alpha_cpy.num_vertices())
- &&(link_blocker_alpha.num_blockers() == link_blocker_alpha_cpy.num_blockers())
- &&(link_blocker_alpha.num_edges() == link_blocker_alpha_cpy.num_edges())
- ;
- DBGVALUE((link_blocker_alpha.num_blockers() == link_blocker_alpha_cpy.num_blockers()));
- DBGVALUE((link_blocker_alpha.num_blockers() ));
- DBGVALUE(( link_blocker_alpha_cpy.num_blockers()));
-
- DBGVALUE(equal_complexes);
-
- // verification
- return link_blocker_alpha.num_vertices()==5 && link_blocker_alpha.num_edges()==4 && link_blocker_alpha.num_blockers()==1 && equal_complexes;
+ // verification
+ return link_blocker_alpha.num_vertices() == 5 && link_blocker_alpha.num_edges() == 4 && link_blocker_alpha.num_blockers() == 1 && equal_complexes;
}
-
-
-
-
-
-
-
template<typename SimplexHandle>
-void add_triangle_edges(int a,int b,int c,list<SimplexHandle>& simplices){
- typedef SimplexHandle Simplex_handle;
- typedef typename SimplexHandle::Vertex_handle Vertex_handle;
+void add_triangle_edges(int a, int b, int c, list<SimplexHandle>& simplices) {
+ typedef SimplexHandle Simplex;
+ typedef typename SimplexHandle::Vertex_handle Vertex_handle;
- simplices.push_back(Simplex_handle(Vertex_handle(a),Vertex_handle(b) ));
- simplices.push_back(Simplex_handle(Vertex_handle(b),Vertex_handle(c) ));
- simplices.push_back(Simplex_handle(Vertex_handle(c),Vertex_handle(a) ));
+ simplices.push_back(Simplex(Vertex_handle(a), Vertex_handle(b)));
+ simplices.push_back(Simplex(Vertex_handle(b), Vertex_handle(c)));
+ simplices.push_back(Simplex(Vertex_handle(c), Vertex_handle(a)));
}
template<typename SimplexHandle>
-void add_triangle(int a,int b,int c,list<SimplexHandle>& simplices){
- typedef SimplexHandle Simplex_handle;
- typedef typename SimplexHandle::Vertex_handle Vertex_handle;
- simplices.push_back(Simplex_handle(Vertex_handle(a),Vertex_handle(b),Vertex_handle(c)));
-}
-
-bool test_constructor(){
- list <Simplex_handle> simplices;
-
- simplices.push_back(Simplex_handle(Vertex_handle(0)));
- simplices.push_back(Simplex_handle(Vertex_handle(1)));
- simplices.push_back(Simplex_handle(Vertex_handle(2)));
- simplices.push_back(Simplex_handle(Vertex_handle(3)));
- simplices.push_back(Simplex_handle(Vertex_handle(4)));
- simplices.push_back(Simplex_handle(Vertex_handle(5)));
-
- simplices.push_back(Simplex_handle(Vertex_handle(3),Vertex_handle(5) ));
-
- add_triangle_edges(0,1,5,simplices);
- add_triangle_edges(1,2,3,simplices);
- add_triangle_edges(2,3,4,simplices);
- add_triangle_edges(1,3,4,simplices);
- add_triangle_edges(1,2,4,simplices);
-
-
- add_triangle(0,1,5,simplices);
- add_triangle(1,2,3,simplices);
- add_triangle(1,3,4,simplices);
- add_triangle(1,2,4,simplices);
- add_triangle(2,3,4,simplices);
-
- Complex complex(simplices.begin(),simplices.end());
-
- PRINT(complex.to_string());
-
- return ( complex.num_vertices()==6&&complex.num_edges()==10&& complex.num_blockers()==2);
-}
-
-
-list<Simplex_handle> subfaces(Simplex_handle top_face){
- list<Simplex_handle> res;
- if(top_face.dimension()==-1) return res;
- if(top_face.dimension()==0) {
- res.push_back(top_face);
- return res;
- }
- else{
- Vertex_handle first_vertex = top_face.first_vertex();
- top_face.remove_vertex(first_vertex);
- res = subfaces(top_face);
- list<Simplex_handle> copy = res;
- for(auto& simplex : copy){
- simplex.add_vertex(first_vertex);
- }
- res.push_back(Simplex_handle(first_vertex));
- res.splice(res.end(),copy);
- return res;
- }
-}
-
-
-bool test_constructor2(){
- Simplex_handle simplex;
- for(int i =0 ; i < 5;++i)
- simplex.add_vertex(static_cast<Vertex_handle>(i));
-
- list <Simplex_handle> simplices(subfaces(simplex));
- simplices.remove(simplex);
-
- Complex complex(simplices.begin(),simplices.end());
-
- PRINT(complex.to_string());
-
- for(auto b : complex.const_blocker_range()){
- cout << "b:"<<b<<endl;
- }
-
- return ( complex.num_vertices()==5&&complex.num_edges()==10&& complex.num_blockers()==1);
+void add_triangle(int a, int b, int c, list<SimplexHandle>& simplices) {
+ typedef SimplexHandle Simplex;
+ typedef typename SimplexHandle::Vertex_handle Vertex_handle;
+ simplices.push_back(Simplex(Vertex_handle(a), Vertex_handle(b), Vertex_handle(c)));
}
+bool test_constructor() {
+ list <Simplex> simplices;
-bool test_constructor3(){
- typedef Vertex_handle Vh;
- typedef Simplex_handle Sh;
- std::vector<Simplex_handle> simplices;
- auto subf(subfaces(Sh(Vh(0),Vh(1),Vh(2))));
- subf.pop_back(); //remove max face -> now a blocker 012
- simplices.insert(simplices.begin(),subf.begin(),subf.end());
- DBGCONT(simplices);
- Complex complex(simplices.begin(),simplices.end());
-
- DBGVALUE(complex.to_string());
+ simplices.push_back(Simplex(Vertex_handle(0)));
+ simplices.push_back(Simplex(Vertex_handle(1)));
+ simplices.push_back(Simplex(Vertex_handle(2)));
+ simplices.push_back(Simplex(Vertex_handle(3)));
+ simplices.push_back(Simplex(Vertex_handle(4)));
+ simplices.push_back(Simplex(Vertex_handle(5)));
- if(complex.num_blockers()!=1) return false;
- Sh expected_blocker(Vh(0),Vh(1),Vh(2));
- for(auto b : complex.const_blocker_range())
- if(*b!=expected_blocker) return false;
+ simplices.push_back(Simplex(Vertex_handle(3), Vertex_handle(5)));
+ add_triangle_edges(0, 1, 5, simplices);
+ add_triangle_edges(1, 2, 3, simplices);
+ add_triangle_edges(2, 3, 4, simplices);
+ add_triangle_edges(1, 3, 4, simplices);
+ add_triangle_edges(1, 2, 4, simplices);
- return complex.num_vertices()==3 && complex.num_blockers()==1;
-}
-
-bool test_constructor4(){
- typedef Vertex_handle Vh;
- typedef Simplex_handle Sh;
- std::vector<Simplex_handle> simplices;
- auto subf(subfaces(Sh(Vh(0),Vh(1),Vh(2),Vh(3))));
- simplices.insert(simplices.begin(),subf.begin(),subf.end());
- simplices.push_back(Sh(Vh(4)));
- simplices.push_back(Sh(Vh(4),Vh(1)));
- simplices.push_back(Sh(Vh(4),Vh(0)));
+ add_triangle(0, 1, 5, simplices);
+ add_triangle(1, 2, 3, simplices);
+ add_triangle(1, 3, 4, simplices);
+ add_triangle(1, 2, 4, simplices);
+ add_triangle(2, 3, 4, simplices);
- DBGCONT(simplices);
- Complex complex(simplices.begin(),simplices.end());
+ Complex complex(simplices.begin(), simplices.end());
- DBGVALUE(complex.to_string());
- if(complex.num_blockers()!=1) return false;
- Sh expected_blocker(Vh(0),Vh(1),Vh(4));
- for(auto b : complex.const_blocker_range())
- if(*b!=expected_blocker) return false;
+ PRINT(complex.to_string());
- return complex.num_vertices()==5 && complex.num_blockers()==1 && complex.num_edges()==8;
+ return ( complex.num_vertices() == 6 && complex.num_edges() == 10 && complex.num_blockers() == 2);
}
-
-
-bool test_constructor5(){
- typedef Vertex_handle Vh;
- typedef Simplex_handle Sh;
- std::vector<Simplex_handle> simplices;
- auto subf(subfaces(Sh(Vh(0),Vh(1),Vh(2))));
- simplices.insert(simplices.begin(),subf.begin(),subf.end());
-
- simplices.push_back(Sh(Vh(3)));
- simplices.push_back(Sh(Vh(3),Vh(1)));
- simplices.push_back(Sh(Vh(3),Vh(2)));
- simplices.push_back(Sh(Vh(4)));
- simplices.push_back(Sh(Vh(4),Vh(1)));
- simplices.push_back(Sh(Vh(4),Vh(0)));
- simplices.push_back(Sh(Vh(5)));
- simplices.push_back(Sh(Vh(5),Vh(2)));
- simplices.push_back(Sh(Vh(5),Vh(0)));
-
- DBGCONT(simplices);
- Complex complex(simplices.begin(),simplices.end());
-
- DBGVALUE(complex.to_string());
-
- return complex.num_vertices()==6 && complex.num_blockers()==3 && complex.num_edges()==9;
+list<Simplex> subfaces(Simplex top_face) {
+ list<Simplex> res;
+ if (top_face.dimension() == -1) return res;
+ if (top_face.dimension() == 0) {
+ res.push_back(top_face);
+ return res;
+ } else {
+ Vertex_handle first_vertex = top_face.first_vertex();
+ top_face.remove_vertex(first_vertex);
+ res = subfaces(top_face);
+ list<Simplex> copy = res;
+ for (auto& simplex : copy) {
+ simplex.add_vertex(first_vertex);
+ }
+ res.push_back(Simplex(first_vertex));
+ res.splice(res.end(), copy);
+ return res;
+ }
}
+bool test_constructor2() {
+ Simplex simplex;
+ for (int i = 0; i < 5; ++i)
+ simplex.add_vertex(static_cast<Vertex_handle> (i));
-bool test_constructor6(){
- typedef Vertex_handle Vh;
- typedef Simplex_handle Sh;
- std::vector<Simplex_handle> simplices;
- auto subf(subfaces(Sh(Vh(0),Vh(1),Vh(2),Vh(3))));
- for(auto s:subf){
- Sh s1(Vh(0),Vh(1),Vh(2),Vh(3));
- Sh s2(Vh(1),Vh(2),Vh(3));
- if(s!=s1 && s!=s2) simplices.push_back(s);
- }
+ list <Simplex> simplices(subfaces(simplex));
+ simplices.remove(simplex);
- DBGCONT(simplices);
- Complex complex(simplices.begin(),simplices.end());
+ Complex complex(simplices.begin(), simplices.end());
- DBGVALUE(complex.to_string());
+ PRINT(complex.to_string());
- if(complex.num_blockers()!=1) return false;
- Sh expected_blocker(Vh(1),Vh(2),Vh(3));
- for(auto b : complex.const_blocker_range())
- if(*b!=expected_blocker) return false;
- return complex.num_vertices()==4 && complex.num_blockers()==1 && complex.num_edges()==6;
-}
+ for (auto b : complex.const_blocker_range()) {
+ cout << "b:" << b << endl;
+ }
-
-bool test_constructor7(){
- typedef Vertex_handle Vh;
- typedef Simplex_handle Sh;
- std::vector<Simplex_handle> simplices;
- simplices.push_back(Sh(Vh(0),Vh(1),Vh(2)));
- simplices.push_back(Sh(Vh(1),Vh(2),Vh(3)));
- simplices.push_back(Sh(Vh(3),Vh(0),Vh(2)));
- simplices.push_back(Sh(Vh(3),Vh(0),Vh(1)));
-
- //get complex from top faces
- Complex complex(make_complex_from_top_faces<Complex>(simplices.begin(),simplices.end()));
-
- DBGVALUE(complex.to_string());
-
- if(complex.num_blockers()!=1) return false;
- Sh expected_blocker(Vh(0),Vh(1),Vh(2),Vh(3));
- for(auto b : complex.const_blocker_range())
- if(*b!=expected_blocker) return false;
- return complex.num_vertices()==4 && complex.num_blockers()==1 && complex.num_edges()==6;
+ return ( complex.num_vertices() == 5 && complex.num_edges() == 10 && complex.num_blockers() == 1);
}
+bool test_constructor3() {
+ typedef Vertex_handle Vh;
+ typedef Simplex Sh;
+ std::vector<Simplex> simplices;
+ auto subf(subfaces(Sh(Vh(0), Vh(1), Vh(2))));
+ subf.pop_back(); //remove max face -> now a blocker 012
+ simplices.insert(simplices.begin(), subf.begin(), subf.end());
+ DBGCONT(simplices);
+ Complex complex(simplices.begin(), simplices.end());
-bool test_constructor8(){
- typedef Vertex_handle Vh;
- typedef Simplex_handle Sh;
- std::vector<Simplex_handle> simplices;
- simplices.push_back(Sh(Vh(0),Vh(1)));
- simplices.push_back(Sh(Vh(2),Vh(1)));
- simplices.push_back(Sh(Vh(0),Vh(2)));
- simplices.push_back(Sh(Vh(3),Vh(1)));
- simplices.push_back(Sh(Vh(2),Vh(3)));
+ DBGVALUE(complex.to_string());
- //get complex from top faces
- Complex complex(make_complex_from_top_faces<Complex>(simplices.begin(),simplices.end()));
+ if (complex.num_blockers() != 1) return false;
+ Sh expected_blocker(Vh(0), Vh(1), Vh(2));
+ for (auto b : complex.const_blocker_range())
+ if (*b != expected_blocker) return false;
- DBGVALUE(complex.to_string());
- return complex.num_vertices()==4 && complex.num_blockers()==2 && complex.num_edges()==5;
+ return complex.num_vertices() == 3 && complex.num_blockers() == 1;
}
+bool test_constructor4() {
+ typedef Vertex_handle Vh;
+ typedef Simplex Sh;
+ std::vector<Simplex> simplices;
+ auto subf(subfaces(Sh(Vh(0), Vh(1), Vh(2), Vh(3))));
+ simplices.insert(simplices.begin(), subf.begin(), subf.end());
+ simplices.push_back(Sh(Vh(4)));
+ simplices.push_back(Sh(Vh(4), Vh(1)));
+ simplices.push_back(Sh(Vh(4), Vh(0)));
+ DBGCONT(simplices);
+ Complex complex(simplices.begin(), simplices.end());
+ DBGVALUE(complex.to_string());
+ if (complex.num_blockers() != 1) return false;
+ Sh expected_blocker(Vh(0), Vh(1), Vh(4));
+ for (auto b : complex.const_blocker_range())
+ if (*b != expected_blocker) return false;
-int main (int argc, char *argv[])
-{
- Tests tests_complex;
- tests_complex.add("test simplex",test_simplex);
- tests_complex.add("test_link0",test_link0);
- tests_complex.add("test_link1",test_link1);
- tests_complex.add("test_link2",test_link2);
- tests_complex.add("test_link3",test_link3);
- tests_complex.add("test_link4",test_link4);
- tests_complex.add("test_link5",test_link5);
- tests_complex.add("test_link6",test_link6);
- tests_complex.add("test_link7",test_link7);
-
- tests_complex.add("test iterator vertices 1",test_iterator_vertices1);
- tests_complex.add("test iterator vertices 2",test_iterator_vertices2);
- tests_complex.add("test iterator edges",test_iterator_edge);
- tests_complex.add("test iterator edges 2",test_iterator_edge2);
- tests_complex.add("test iterator edges 3",test_iterator_edge3);
-
- tests_complex.add("test iterator simplices",test_iterator_simplices);
- tests_complex.add("test iterator simplices2",test_iterator_simplices2);
- tests_complex.add("test iterator simplices3",test_iterator_simplices3);
- tests_complex.add("test iterator simplices4",test_iterator_simplices4);
-
-
- tests_complex.add("test iterator blockers",test_iterator_blockers);
- tests_complex.add("test_iterator_triangles",test_iterator_triangles);
-
- tests_complex.add("test_constructor_list_simplices",test_constructor);
- tests_complex.add("test_constructor_list_simplices2",test_constructor2);
- tests_complex.add("test_constructor_list_simplices3",test_constructor3);
- tests_complex.add("test_constructor_list_simplices4",test_constructor4);
- tests_complex.add("test_constructor_list_simplices5",test_constructor5);
- tests_complex.add("test_constructor_list_simplices6",test_constructor6);
- tests_complex.add("test_constructor_list_simplices7",test_constructor7);
- tests_complex.add("test_constructor_list_simplices8",test_constructor8);
-
-
- if(tests_complex.run()){
- return EXIT_SUCCESS;
- }
- else{
- return EXIT_FAILURE;
- }
+ return complex.num_vertices() == 5 && complex.num_blockers() == 1 && complex.num_edges() == 8;
+}
- // test_iterator_simplices();
+bool test_constructor5() {
+ typedef Vertex_handle Vh;
+ typedef Simplex Sh;
+ std::vector<Simplex> simplices;
+ auto subf(subfaces(Sh(Vh(0), Vh(1), Vh(2))));
+ simplices.insert(simplices.begin(), subf.begin(), subf.end());
+
+ simplices.push_back(Sh(Vh(3)));
+ simplices.push_back(Sh(Vh(3), Vh(1)));
+ simplices.push_back(Sh(Vh(3), Vh(2)));
+ simplices.push_back(Sh(Vh(4)));
+ simplices.push_back(Sh(Vh(4), Vh(1)));
+ simplices.push_back(Sh(Vh(4), Vh(0)));
+ simplices.push_back(Sh(Vh(5)));
+ simplices.push_back(Sh(Vh(5), Vh(2)));
+ simplices.push_back(Sh(Vh(5), Vh(0)));
+
+ DBGCONT(simplices);
+ Complex complex(simplices.begin(), simplices.end());
+
+ DBGVALUE(complex.to_string());
+
+ return complex.num_vertices() == 6 && complex.num_blockers() == 3 && complex.num_edges() == 9;
+}
+
+bool test_constructor6() {
+ typedef Vertex_handle Vh;
+ typedef Simplex Sh;
+ std::vector<Simplex> simplices;
+ auto subf(subfaces(Sh(Vh(0), Vh(1), Vh(2), Vh(3))));
+ for (auto s : subf) {
+ Sh s1(Vh(0), Vh(1), Vh(2), Vh(3));
+ Sh s2(Vh(1), Vh(2), Vh(3));
+ if (s != s1 && s != s2) simplices.push_back(s);
+ }
+
+ DBGCONT(simplices);
+ Complex complex(simplices.begin(), simplices.end());
+
+ DBGVALUE(complex.to_string());
+
+ if (complex.num_blockers() != 1) return false;
+ Sh expected_blocker(Vh(1), Vh(2), Vh(3));
+ for (auto b : complex.const_blocker_range())
+ if (*b != expected_blocker) return false;
+ return complex.num_vertices() == 4 && complex.num_blockers() == 1 && complex.num_edges() == 6;
+}
+
+bool test_constructor7() {
+ typedef Vertex_handle Vh;
+ typedef Simplex Sh;
+ std::vector<Simplex> simplices;
+ simplices.push_back(Sh(Vh(0), Vh(1), Vh(2)));
+ simplices.push_back(Sh(Vh(1), Vh(2), Vh(3)));
+ simplices.push_back(Sh(Vh(3), Vh(0), Vh(2)));
+ simplices.push_back(Sh(Vh(3), Vh(0), Vh(1)));
+
+ //get complex from top faces
+ Complex complex(make_complex_from_top_faces<Complex>(simplices.begin(), simplices.end()));
+
+ DBGVALUE(complex.to_string());
+
+ if (complex.num_blockers() != 1) return false;
+ Sh expected_blocker(Vh(0), Vh(1), Vh(2), Vh(3));
+ for (auto b : complex.const_blocker_range())
+ if (*b != expected_blocker) return false;
+ return complex.num_vertices() == 4 && complex.num_blockers() == 1 && complex.num_edges() == 6;
+}
+
+bool test_constructor8() {
+ typedef Vertex_handle Vh;
+ typedef Simplex Sh;
+ std::vector<Simplex> simplices;
+ simplices.push_back(Sh(Vh(0), Vh(1)));
+ simplices.push_back(Sh(Vh(2), Vh(1)));
+ simplices.push_back(Sh(Vh(0), Vh(2)));
+ simplices.push_back(Sh(Vh(3), Vh(1)));
+ simplices.push_back(Sh(Vh(2), Vh(3)));
+
+ //get complex from top faces
+ Complex complex(make_complex_from_top_faces<Complex>(simplices.begin(), simplices.end()));
+
+ DBGVALUE(complex.to_string());
+
+ return complex.num_vertices() == 4 && complex.num_blockers() == 2 && complex.num_edges() == 5;
+}
+
+int main(int argc, char *argv[]) {
+ Tests tests_complex;
+ tests_complex.add("test simplex", test_simplex);
+ tests_complex.add("test_num_simplices", test_num_simplices);
+ tests_complex.add("test_link0", test_link0);
+ tests_complex.add("test_link1", test_link1);
+ tests_complex.add("test_link2", test_link2);
+ tests_complex.add("test_link3", test_link3);
+ tests_complex.add("test_link4", test_link4);
+ tests_complex.add("test_link5", test_link5);
+ tests_complex.add("test_link6", test_link6);
+ tests_complex.add("test_link7", test_link7);
+
+ tests_complex.add("test_constructor_list_simplices", test_constructor);
+ tests_complex.add("test_constructor_list_simplices2", test_constructor2);
+ tests_complex.add("test_constructor_list_simplices3", test_constructor3);
+ tests_complex.add("test_constructor_list_simplices4", test_constructor4);
+ tests_complex.add("test_constructor_list_simplices5", test_constructor5);
+ tests_complex.add("test_constructor_list_simplices6", test_constructor6);
+ tests_complex.add("test_constructor_list_simplices7", test_constructor7);
+ tests_complex.add("test_constructor_list_simplices8", test_constructor8);
+
+ tests_complex.add("test iterator vertices 1", test_iterator_vertices1);
+ tests_complex.add("test iterator vertices 2", test_iterator_vertices2);
+ tests_complex.add("test iterator edges", test_iterator_edge);
+ tests_complex.add("test iterator edges 2", test_iterator_edge2);
+ tests_complex.add("test iterator edges 3", test_iterator_edge3);
+ tests_complex.add("test iterator blockers", test_iterator_blockers);
+ tests_complex.add("test_iterator_triangles", test_iterator_triangles);
+ tests_complex.add("test iterator simplices", test_iterator_simplices);
+ tests_complex.add("test iterator simplices2", test_iterator_simplices2);
+ tests_complex.add("test iterator simplices3", test_iterator_simplices3);
+ tests_complex.add("test iterator simplices4", test_iterator_simplices4);
+ tests_complex.add("test iterator coboundary", test_iterator_coboundary);
+
+ if (tests_complex.run()) {
+ return EXIT_SUCCESS;
+ } else {
+ return EXIT_FAILURE;
+ }
+
+ // test_iterator_simplices();
}
diff --git a/src/cmake/modules/FindTBB.cmake b/src/cmake/modules/FindTBB.cmake
new file mode 100644
index 00000000..414a929b
--- /dev/null
+++ b/src/cmake/modules/FindTBB.cmake
@@ -0,0 +1,433 @@
+# Locate Intel Threading Building Blocks include paths and libraries
+# FindTBB.cmake can be found at https://code.google.com/p/findtbb/
+# Written by Hannes Hofmann <hannes.hofmann _at_ informatik.uni-erlangen.de>
+# Improvements by Gino van den Bergen <gino _at_ dtecta.com>,
+# Florian Uhlig <F.Uhlig _at_ gsi.de>,
+# Jiri Marsik <jiri.marsik89 _at_ gmail.com>
+
+# The MIT License
+#
+# Copyright (c) 2011 Hannes Hofmann
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+
+# GvdB: This module uses the environment variable TBB_ARCH_PLATFORM which defines architecture and compiler.
+# e.g. "ia32/vc8" or "em64t/cc4.1.0_libc2.4_kernel2.6.16.21"
+# TBB_ARCH_PLATFORM is set by the build script tbbvars[.bat|.sh|.csh], which can be found
+# in the TBB installation directory (TBB_INSTALL_DIR).
+#
+# GvdB: Mac OS X distribution places libraries directly in lib directory.
+#
+# For backwards compatibility, you may explicitely set the CMake variables TBB_ARCHITECTURE and TBB_COMPILER.
+# TBB_ARCHITECTURE [ ia32 | em64t | itanium ]
+# which architecture to use
+# TBB_COMPILER e.g. vc9 or cc3.2.3_libc2.3.2_kernel2.4.21 or cc4.0.1_os10.4.9
+# which compiler to use (detected automatically on Windows)
+
+# This module respects
+# TBB_INSTALL_DIR or $ENV{TBB21_INSTALL_DIR} or $ENV{TBB_INSTALL_DIR}
+
+# This module defines
+# TBB_INCLUDE_DIRS, where to find task_scheduler_init.h, etc.
+# TBB_LIBRARY_DIRS, where to find TBB libraries
+# TBB_INSTALL_DIR, the base TBB install directory.
+# TBB_LIBRARIES, all the following TBB libraries (both release and debug versions, using "optimized" and "debug" CMake keywords). Note that if the debug versions are not found, the release versions will be used instead for the debug mode.
+# TBB_RELEASE_LIBRARY, the TBB release library
+# TBB_MALLOC_RELEASE_LIBRARY, the TBB release malloc library
+# TBB_DEBUG_LIBRARY, the TBB debug library
+# TBB_MALLOC_DEBUG_LIBRARY, the TBB debug malloc library
+# TBB_FOUND, If false, don't try to use TBB.
+# TBB_INTERFACE_VERSION, as defined in tbb/tbb_stddef.h
+# TBB_MALLOCPROXY_DEBUG_LIBRARY, the TBB debug malloc_proxy library (not included in TBB_LIBRARIES since it's optionnal)
+# TBB_MALLOCPROXY_RELEASE_LIBRARY, the TBB release malloc_proxy library (not included in TBB_LIBRARIES since it's optionnal)
+
+include(CheckCXXSourceCompiles)
+
+# Usage:
+# try_TBB_with_pthread(<result_var_name> [additional linker args...])
+function(try_TBB_with_pthread result_var)
+ set(TBB_try_ts_source "
+ #include <tbb/enumerable_thread_specific.h>
+ int main() {
+ tbb::enumerable_thread_specific<
+ bool*,
+ tbb::cache_aligned_allocator<bool*>,
+ tbb::ets_key_per_instance> grid;
+ }
+ ")
+ set(CMAKE_REQUIRED_LIBRARIES ${ALL_TBB_LIBRARIES} ${ARGN})
+ set(CMAKE_REQUIRED_INCLUDES ${TBB_INCLUDE_DIR})
+ check_cxx_source_compiles("${TBB_try_ts_source}" ${result_var})
+ set(${result_var} ${${result_var}} PARENT_SCOPE)
+endfunction(try_TBB_with_pthread)
+
+if (WIN32)
+ # has em64t/vc8 em64t/vc9
+ # has ia32/vc7.1 ia32/vc8 ia32/vc9
+ set(_TBB_DEFAULT_INSTALL_DIR "C:/Program Files/Intel/TBB" "C:/Program Files (x86)/Intel/TBB")
+ set(_TBB_LIB_RELEASE_NAME "tbb")
+ set(_TBB_LIB_MALLOC_RELEASE_NAME "${_TBB_LIB_RELEASE_NAME}malloc")
+ set(_TBB_LIB_MALLOCPROXY_RELEASE_NAME "${_TBB_LIB_RELEASE_NAME}malloc_proxy")
+ set(_TBB_LIB_DEBUG_NAME "${_TBB_LIB_RELEASE_NAME}_debug")
+ set(_TBB_LIB_MALLOC_DEBUG_NAME "${_TBB_LIB_MALLOC_RELEASE_NAME}_debug")
+ set(_TBB_LIB_MALLOCPROXY_DEBUG_NAME "${_TBB_LIB_MALLOCPROXY_RELEASE_NAME}_debug")
+ if (MSVC71)
+ set (_TBB_COMPILER "vc7.1")
+ endif(MSVC71)
+ if (MSVC80)
+ set(_TBB_COMPILER "vc8")
+ endif(MSVC80)
+ if (MSVC90)
+ set(_TBB_COMPILER "vc9")
+ endif(MSVC90)
+ if(MSVC10)
+ set(_TBB_COMPILER "vc10")
+ endif(MSVC10)
+ if(MSVC11)
+ set(_TBB_COMPILER "vc11")
+ endif(MSVC11)
+ if(MSVC12)
+ set(_TBB_COMPILER "vc12")
+ endif(MSVC12)
+ #note there was no MSVC13
+ if(MSVC14)
+ if(RUNNING_CGAL_AUTO_TEST)
+ set (TBB_FOUND "NO")
+ return()#binaries for TBB not publicly available when CGAL-4.7 is published
+ endif(RUNNING_CGAL_AUTO_TEST)
+ message(STATUS "[Warning] FindTBB.cmake: TBB 4.4 (latest available when CGAL-4.7 is published) does not provide support for MSVC 2015.")
+ endif(MSVC14)
+ # Todo: add other Windows compilers such as ICL.
+ set(_TBB_ARCHITECTURE ${TBB_ARCHITECTURE})
+endif (WIN32)
+
+if (UNIX)
+ if (APPLE)
+ # MAC
+ set(_TBB_DEFAULT_INSTALL_DIR "/Library/Frameworks/Intel_TBB.framework/Versions")
+ # libs: libtbb.dylib, libtbbmalloc.dylib, *_debug
+ set(_TBB_LIB_RELEASE_NAME "tbb")
+ set(_TBB_LIB_MALLOC_RELEASE_NAME "${_TBB_LIB_RELEASE_NAME}malloc")
+ #set(_TBB_LIB_MALLOCPROXY_RELEASE_NAME "${_TBB_LIB_RELEASE_NAME}malloc_proxy")
+ set(_TBB_LIB_DEBUG_NAME "${_TBB_LIB_RELEASE_NAME}_debug")
+ set(_TBB_LIB_MALLOC_DEBUG_NAME "${_TBB_LIB_MALLOC_RELEASE_NAME}_debug")
+ #set(_TBB_LIB_MALLOCPROXY_DEBUG_NAME "${_TBB_LIB_MALLOCPROXY_RELEASE_NAME}_debug")
+ # default flavor on apple: ia32/cc4.0.1_os10.4.9
+ # Jiri: There is no reason to presume there is only one flavor and
+ # that user's setting of variables should be ignored.
+ if(NOT TBB_COMPILER)
+ set(_TBB_COMPILER "cc4.0.1_os10.4.9")
+ elseif (NOT TBB_COMPILER)
+ set(_TBB_COMPILER ${TBB_COMPILER})
+ endif(NOT TBB_COMPILER)
+ if(NOT TBB_ARCHITECTURE)
+ set(_TBB_ARCHITECTURE "ia32")
+ elseif(NOT TBB_ARCHITECTURE)
+ set(_TBB_ARCHITECTURE ${TBB_ARCHITECTURE})
+ endif(NOT TBB_ARCHITECTURE)
+ else (APPLE)
+ # LINUX
+ set(_TBB_DEFAULT_INSTALL_DIR "/opt/intel/tbb" "/usr/local/include" "/usr/include")
+ set(_TBB_LIB_RELEASE_NAME "tbb")
+ set(_TBB_LIB_MALLOC_RELEASE_NAME "${_TBB_LIB_RELEASE_NAME}malloc")
+ set(_TBB_LIB_MALLOCPROXY_RELEASE_NAME "${_TBB_LIB_RELEASE_NAME}malloc_proxy")
+ set(_TBB_LIB_DEBUG_NAME "${_TBB_LIB_RELEASE_NAME}_debug")
+ set(_TBB_LIB_MALLOC_DEBUG_NAME "${_TBB_LIB_MALLOC_RELEASE_NAME}_debug")
+ set(_TBB_LIB_MALLOCPROXY_DEBUG_NAME "${_TBB_LIB_MALLOCPROXY_RELEASE_NAME}_debug")
+ # has em64t/cc3.2.3_libc2.3.2_kernel2.4.21 em64t/cc3.3.3_libc2.3.3_kernel2.6.5 em64t/cc3.4.3_libc2.3.4_kernel2.6.9 em64t/cc4.1.0_libc2.4_kernel2.6.16.21
+ # has ia32/*
+ # has itanium/*
+ set(_TBB_COMPILER ${TBB_COMPILER})
+ set(_TBB_ARCHITECTURE ${TBB_ARCHITECTURE})
+ endif (APPLE)
+endif (UNIX)
+
+if (CMAKE_SYSTEM MATCHES "SunOS.*")
+# SUN
+# not yet supported
+# has em64t/cc3.4.3_kernel5.10
+# has ia32/*
+endif (CMAKE_SYSTEM MATCHES "SunOS.*")
+
+
+#-- Clear the public variables
+set (TBB_FOUND "NO")
+
+
+#-- Find TBB install dir and set ${_TBB_INSTALL_DIR} and cached ${TBB_INSTALL_DIR}
+# first: use CMake variable TBB_INSTALL_DIR
+if (TBB_INSTALL_DIR)
+ set (_TBB_INSTALL_DIR ${TBB_INSTALL_DIR})
+endif (TBB_INSTALL_DIR)
+# second: use environment variable
+if (NOT _TBB_INSTALL_DIR)
+ if (NOT "$ENV{TBBROOT}" STREQUAL "")
+ set (_TBB_INSTALL_DIR $ENV{TBBROOT})
+ endif (NOT "$ENV{TBBROOT}" STREQUAL "")
+ if (NOT "$ENV{TBB_INSTALL_DIR}" STREQUAL "")
+ set (_TBB_INSTALL_DIR $ENV{TBB_INSTALL_DIR})
+ endif (NOT "$ENV{TBB_INSTALL_DIR}" STREQUAL "")
+ # Intel recommends setting TBB21_INSTALL_DIR
+ if (NOT "$ENV{TBB21_INSTALL_DIR}" STREQUAL "")
+ set (_TBB_INSTALL_DIR $ENV{TBB21_INSTALL_DIR})
+ endif (NOT "$ENV{TBB21_INSTALL_DIR}" STREQUAL "")
+ if (NOT "$ENV{TBB22_INSTALL_DIR}" STREQUAL "")
+ set (_TBB_INSTALL_DIR $ENV{TBB22_INSTALL_DIR})
+ endif (NOT "$ENV{TBB22_INSTALL_DIR}" STREQUAL "")
+ if (NOT "$ENV{TBB30_INSTALL_DIR}" STREQUAL "")
+ set (_TBB_INSTALL_DIR $ENV{TBB30_INSTALL_DIR})
+ endif (NOT "$ENV{TBB30_INSTALL_DIR}" STREQUAL "")
+endif (NOT _TBB_INSTALL_DIR)
+# third: try to find path automatically
+if (NOT _TBB_INSTALL_DIR)
+ if (_TBB_DEFAULT_INSTALL_DIR)
+ set (_TBB_INSTALL_DIR ${_TBB_DEFAULT_INSTALL_DIR})
+ endif (_TBB_DEFAULT_INSTALL_DIR)
+endif (NOT _TBB_INSTALL_DIR)
+# sanity check
+if (NOT _TBB_INSTALL_DIR)
+ message ("ERROR: Unable to find Intel TBB install directory. ${_TBB_INSTALL_DIR}")
+else (NOT _TBB_INSTALL_DIR)
+# finally: set the cached CMake variable TBB_INSTALL_DIR
+if (NOT TBB_INSTALL_DIR)
+ set (TBB_INSTALL_DIR ${_TBB_INSTALL_DIR} CACHE PATH "Intel TBB install directory")
+ mark_as_advanced(TBB_INSTALL_DIR)
+endif (NOT TBB_INSTALL_DIR)
+
+
+#-- A macro to rewrite the paths of the library. This is necessary, because
+# find_library() always found the em64t/vc9 version of the TBB libs
+macro(TBB_CORRECT_LIB_DIR var_name)
+# if (NOT "${_TBB_ARCHITECTURE}" STREQUAL "em64t")
+ string(REPLACE em64t "${_TBB_ARCHITECTURE}" ${var_name} ${${var_name}})
+# endif (NOT "${_TBB_ARCHITECTURE}" STREQUAL "em64t")
+ string(REPLACE ia32 "${_TBB_ARCHITECTURE}" ${var_name} ${${var_name}})
+ string(REPLACE vc7.1 "${_TBB_COMPILER}" ${var_name} ${${var_name}})
+ string(REPLACE vc8 "${_TBB_COMPILER}" ${var_name} ${${var_name}})
+ string(REPLACE vc9 "${_TBB_COMPILER}" ${var_name} ${${var_name}})
+ string(REPLACE vc10 "${_TBB_COMPILER}" ${var_name} ${${var_name}})
+ string(REPLACE vc11 "${_TBB_COMPILER}" ${var_name} ${${var_name}})
+endmacro(TBB_CORRECT_LIB_DIR var_content)
+
+
+#-- Look for include directory and set ${TBB_INCLUDE_DIR}
+set (TBB_INC_SEARCH_DIR ${_TBB_INSTALL_DIR}/include)
+# Jiri: tbbvars now sets the CPATH environment variable to the directory
+# containing the headers.
+# LR: search first with NO_DEFAULT_PATH...
+find_path(TBB_INCLUDE_DIR
+ tbb/task_scheduler_init.h
+ PATHS ${TBB_INC_SEARCH_DIR} ENV CPATH
+ NO_DEFAULT_PATH
+)
+if(NOT TBB_INCLUDE_DIR)
+# LR: ... and then search again with NO_DEFAULT_PATH if nothing was found in
+# hinted paths
+ find_path(TBB_INCLUDE_DIR
+ tbb/task_scheduler_init.h
+ PATHS ${TBB_INC_SEARCH_DIR} ENV CPATH
+ )
+endif()
+mark_as_advanced(TBB_INCLUDE_DIR)
+
+
+#-- Look for libraries
+# GvdB: $ENV{TBB_ARCH_PLATFORM} is set by the build script tbbvars[.bat|.sh|.csh]
+if (NOT $ENV{TBB_ARCH_PLATFORM} STREQUAL "")
+ set (_TBB_LIBRARY_DIR
+ ${_TBB_INSTALL_DIR}/lib/$ENV{TBB_ARCH_PLATFORM}
+ ${_TBB_INSTALL_DIR}/$ENV{TBB_ARCH_PLATFORM}/lib
+ )
+endif (NOT $ENV{TBB_ARCH_PLATFORM} STREQUAL "")
+# Jiri: This block isn't mutually exclusive with the previous one
+# (hence no else), instead I test if the user really specified
+# the variables in question.
+if ((NOT ${TBB_ARCHITECTURE} STREQUAL "") AND (NOT ${TBB_COMPILER} STREQUAL ""))
+ # HH: deprecated
+ message(STATUS "[Warning] FindTBB.cmake: The use of TBB_ARCHITECTURE and TBB_COMPILER is deprecated and may not be supported in future versions. Please set \$ENV{TBB_ARCH_PLATFORM} (using tbbvars.[bat|csh|sh]).")
+ # Jiri: It doesn't hurt to look in more places, so I store the hints from
+ # ENV{TBB_ARCH_PLATFORM} and the TBB_ARCHITECTURE and TBB_COMPILER
+ # variables and search them both.
+ set (_TBB_LIBRARY_DIR "${_TBB_INSTALL_DIR}/${_TBB_ARCHITECTURE}/${_TBB_COMPILER}/lib" ${_TBB_LIBRARY_DIR})
+endif ((NOT ${TBB_ARCHITECTURE} STREQUAL "") AND (NOT ${TBB_COMPILER} STREQUAL ""))
+
+# GvdB: Mac OS X distribution places libraries directly in lib directory.
+list(APPEND _TBB_LIBRARY_DIR ${_TBB_INSTALL_DIR}/lib)
+
+# Jiri: No reason not to check the default paths. From recent versions,
+# tbbvars has started exporting the LIBRARY_PATH and LD_LIBRARY_PATH
+# variables, which now point to the directories of the lib files.
+# It all makes more sense to use the ${_TBB_LIBRARY_DIR} as a HINTS
+# argument instead of the implicit PATHS as it isn't hard-coded
+# but computed by system introspection. Searching the LIBRARY_PATH
+# and LD_LIBRARY_PATH environment variables is now even more important
+# that tbbvars doesn't export TBB_ARCH_PLATFORM and it facilitates
+# the use of TBB built from sources.
+# LR: search first with NO_DEFAULT_PATH...
+find_library(TBB_RELEASE_LIBRARY ${_TBB_LIB_RELEASE_NAME} HINTS ${_TBB_LIBRARY_DIR}
+ PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH NO_DEFAULT_PATH)
+find_library(TBB_MALLOC_RELEASE_LIBRARY ${_TBB_LIB_MALLOC_RELEASE_NAME} HINTS ${_TBB_LIBRARY_DIR}
+ PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH NO_DEFAULT_PATH)
+find_library(TBB_MALLOCPROXY_RELEASE_LIBRARY ${_TBB_LIB_MALLOCPROXY_RELEASE_NAME} HINTS ${_TBB_LIBRARY_DIR}
+ PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH NO_DEFAULT_PATH)
+if(NOT TBB_RELEASE_LIBRARY OR NOT TBB_MALLOC_RELEASE_LIBRARY OR NOT TBB_MALLOCPROXY_RELEASE_LIBRARY)
+# LR: ... and then search again with NO_DEFAULT_PATH if nothing was found
+# in hinted paths
+ find_library(TBB_RELEASE_LIBRARY ${_TBB_LIB_RELEASE_NAME} HINTS ${_TBB_LIBRARY_DIR}
+ PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH)
+ find_library(TBB_MALLOC_RELEASE_LIBRARY ${_TBB_LIB_MALLOC_RELEASE_NAME} HINTS ${_TBB_LIBRARY_DIR}
+ PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH)
+ find_library(TBB_MALLOCPROXY_RELEASE_LIBRARY ${_TBB_LIB_MALLOCPROXY_RELEASE_NAME} HINTS ${_TBB_LIBRARY_DIR}
+ PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH)
+endif()
+
+#Extract path from TBB_RELEASE_LIBRARY name
+get_filename_component(TBB_RELEASE_LIBRARY_DIR ${TBB_RELEASE_LIBRARY} PATH)
+
+#TBB_CORRECT_LIB_DIR(TBB_RELEASE_LIBRARY)
+#TBB_CORRECT_LIB_DIR(TBB_MALLOC_RELEASE_LIBRARY)
+#TBB_CORRECT_LIB_DIR(TBB_MALLOCPROXY_RELEASE_LIBRARY)
+mark_as_advanced(TBB_RELEASE_LIBRARY TBB_MALLOC_RELEASE_LIBRARY TBB_MALLOCPROXY_RELEASE_LIBRARY)
+
+#-- Look for debug libraries
+# Jiri: Changed the same way as for the release libraries.
+find_library(TBB_DEBUG_LIBRARY ${_TBB_LIB_DEBUG_NAME} HINTS ${_TBB_LIBRARY_DIR}
+ PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH NO_DEFAULT_PATH)
+find_library(TBB_MALLOC_DEBUG_LIBRARY ${_TBB_LIB_MALLOC_DEBUG_NAME} HINTS ${_TBB_LIBRARY_DIR}
+ PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH NO_DEFAULT_PATH)
+find_library(TBB_MALLOCPROXY_DEBUG_LIBRARY ${_TBB_LIB_MALLOCPROXY_DEBUG_NAME} HINTS ${_TBB_LIBRARY_DIR}
+ PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH NO_DEFAULT_PATH)
+if(NOT TBB_DEBUG_LIBRARY OR NOT TBB_MALLOC_DEBUG_LIBRARY OR NOT TBB_MALLOCPROXY_DEBUG_LIBRARY)
+ find_library(TBB_DEBUG_LIBRARY ${_TBB_LIB_DEBUG_NAME} HINTS ${_TBB_LIBRARY_DIR}
+ PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH)
+ find_library(TBB_MALLOC_DEBUG_LIBRARY ${_TBB_LIB_MALLOC_DEBUG_NAME} HINTS ${_TBB_LIBRARY_DIR}
+ PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH)
+ find_library(TBB_MALLOCPROXY_DEBUG_LIBRARY ${_TBB_LIB_MALLOCPROXY_DEBUG_NAME} HINTS ${_TBB_LIBRARY_DIR}
+ PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH)
+endif()
+
+# Jiri: Self-built TBB stores the debug libraries in a separate directory.
+# Extract path from TBB_DEBUG_LIBRARY name
+get_filename_component(TBB_DEBUG_LIBRARY_DIR ${TBB_DEBUG_LIBRARY} PATH)
+
+#TBB_CORRECT_LIB_DIR(TBB_DEBUG_LIBRARY)
+#TBB_CORRECT_LIB_DIR(TBB_MALLOC_DEBUG_LIBRARY)
+#TBB_CORRECT_LIB_DIR(TBB_MALLOCPROXY_DEBUG_LIBRARY)
+mark_as_advanced(TBB_DEBUG_LIBRARY TBB_MALLOC_DEBUG_LIBRARY TBB_MALLOCPROXY_DEBUG_LIBRARY)
+
+if (TBB_INCLUDE_DIR)
+ if (TBB_RELEASE_LIBRARY)
+ set (TBB_FOUND "YES")
+
+ # NOTE: Removed because we don't want to link with the malloc_proxy by default
+ #if (NOT "${TBB_MALLOCPROXY_RELEASE_LIBRARY}" STREQUAL "TBB_MALLOCPROXY_RELEASE_LIBRARY-NOTFOUND")
+ # mark_as_advanced(TBB_MALLOCPROXY_RELEASE_LIBRARY)
+ # set (_TBB_MALLOCPROXY optimized ${TBB_MALLOCPROXY_RELEASE_LIBRARY})
+ #endif (NOT "${TBB_MALLOCPROXY_RELEASE_LIBRARY}" STREQUAL "TBB_MALLOCPROXY_RELEASE_LIBRARY-NOTFOUND")
+ #if (NOT "${TBB_MALLOCPROXY_DEBUG_LIBRARY}" STREQUAL "TBB_MALLOCPROXY_DEBUG_LIBRARY-NOTFOUND")
+ # mark_as_advanced(TBB_MALLOCPROXY_DEBUG_LIBRARY)
+ # set (_TBB_MALLOCPROXY ${_TBB_MALLOCPROXY} debug ${TBB_MALLOCPROXY_DEBUG_LIBRARY})
+ #endif (NOT "${TBB_MALLOCPROXY_DEBUG_LIBRARY}" STREQUAL "TBB_MALLOCPROXY_DEBUG_LIBRARY-NOTFOUND")
+
+ # TBB release library
+ set (ALL_TBB_LIBRARIES optimized ${TBB_RELEASE_LIBRARY})
+
+ # TBB debug library found?
+ if (TBB_DEBUG_LIBRARY)
+ list(APPEND ALL_TBB_LIBRARIES debug ${TBB_DEBUG_LIBRARY})
+ else (TBB_DEBUG_LIBRARY)
+ # Otherwise, link with the release library even in debug mode
+ list(APPEND ALL_TBB_LIBRARIES debug ${TBB_RELEASE_LIBRARY})
+ endif (TBB_DEBUG_LIBRARY)
+
+ # TBB malloc - release
+ if (TBB_MALLOC_RELEASE_LIBRARY)
+ list(APPEND ALL_TBB_LIBRARIES optimized ${TBB_MALLOC_RELEASE_LIBRARY})
+
+ # TBB malloc - debug
+ if (TBB_MALLOC_DEBUG_LIBRARY)
+ list(APPEND ALL_TBB_LIBRARIES debug ${TBB_MALLOC_DEBUG_LIBRARY})
+ else (TBB_MALLOC_DEBUG_LIBRARY)
+ list(APPEND ALL_TBB_LIBRARIES debug ${TBB_MALLOC_RELEASE_LIBRARY})
+ endif (TBB_MALLOC_DEBUG_LIBRARY)
+ endif (TBB_MALLOC_RELEASE_LIBRARY)
+
+ if(UNIX AND NOT APPLE)
+ # On Fedora, code using TBB might need -pthread
+
+ # First check without pthread
+ try_TBB_with_pthread(TBB_without_pthread)
+
+ if(NOT TBB_without_pthread)
+ # Then check with -pthread
+ try_TBB_with_pthread(TBB_with_pthread -pthread)
+ if(TBB_with_pthread)
+ list(APPEND ALL_TBB_LIBRARIES general -pthread)
+ endif(TBB_with_pthread)
+ endif(NOT TBB_without_pthread)
+ endif(UNIX AND NOT APPLE)
+
+ set (TBB_LIBRARIES ${ALL_TBB_LIBRARIES}
+ CACHE PATH "TBB libraries" FORCE)
+
+ # Include dirs
+ set (TBB_INCLUDE_DIRS ${TBB_INCLUDE_DIR} CACHE PATH "TBB include directory" FORCE)
+
+ # Library dirs
+ if( "${TBB_DEBUG_LIBRARY_DIR}" STREQUAL "" OR "${TBB_RELEASE_LIBRARY_DIR}" STREQUAL "${TBB_DEBUG_LIBRARY_DIR}" )
+ set (TBB_LIBRARY_DIRS
+ ${TBB_RELEASE_LIBRARY_DIR}
+ CACHE PATH "TBB library directories" FORCE)
+ else( "${TBB_DEBUG_LIBRARY_DIR}" STREQUAL "" OR "${TBB_RELEASE_LIBRARY_DIR}" STREQUAL "${TBB_DEBUG_LIBRARY_DIR}" )
+ set (TBB_LIBRARY_DIRS
+ ${TBB_RELEASE_LIBRARY_DIR} ${TBB_DEBUG_LIBRARY_DIR}
+ CACHE PATH "TBB library directories" FORCE)
+ endif( "${TBB_DEBUG_LIBRARY_DIR}" STREQUAL "" OR "${TBB_RELEASE_LIBRARY_DIR}" STREQUAL "${TBB_DEBUG_LIBRARY_DIR}" )
+
+ message(STATUS "Found Intel TBB")
+ endif (TBB_RELEASE_LIBRARY)
+endif (TBB_INCLUDE_DIR)
+
+if (NOT TBB_FOUND)
+ if(NOT TBB_FIND_QUIETLY)
+ message("ERROR: Intel TBB NOT found! Please define the TBBROOT (or TBB_INSTALL_DIR) and/or TBB_ARCH_PLATFORM environment variables.")
+ message(STATUS "Looked for Threading Building Blocks in ${_TBB_INSTALL_DIR}")
+ endif(NOT TBB_FIND_QUIETLY)
+ SET(TBB_INSTALL_DIR "TBB_INSTALL_DIR_NOT_FOUND" CACHE STRING "Intel TBB install directory")
+ # do only throw fatal, if this pkg is REQUIRED
+ if (TBB_FIND_REQUIRED)
+ message(FATAL_ERROR "Could NOT find TBB library.")
+ endif (TBB_FIND_REQUIRED)
+endif (NOT TBB_FOUND)
+
+endif (NOT _TBB_INSTALL_DIR)
+
+if (TBB_FOUND)
+ set(TBB_INTERFACE_VERSION 0)
+ FILE(READ "${TBB_INCLUDE_DIRS}/tbb/tbb_stddef.h" _TBB_VERSION_CONTENTS)
+ STRING(REGEX REPLACE ".*#define TBB_INTERFACE_VERSION ([0-9]+).*" "\\1" TBB_INTERFACE_VERSION "${_TBB_VERSION_CONTENTS}")
+ set(TBB_INTERFACE_VERSION "${TBB_INTERFACE_VERSION}")
+endif (TBB_FOUND)
+
+set(TBB_USE_FILE "UseTBB")
+
+### ** Emacs settings **
+### Local Variables:
+### cmake-tab-width: 4
+### End:
diff --git a/src/cmake/modules/UseTBB.cmake b/src/cmake/modules/UseTBB.cmake
new file mode 100644
index 00000000..e1ef5dfe
--- /dev/null
+++ b/src/cmake/modules/UseTBB.cmake
@@ -0,0 +1,6 @@
+# This module setups the compiler for using TBB library.
+# It assumes that find_package(TBB) was already called.
+
+include_directories ( ${TBB_INCLUDE_DIRS} )
+link_directories( ${TBB_LIBRARY_DIRS} )
+add_definitions( -DNOMINMAX -DGUDHI_USE_TBB )
diff --git a/src/common/doc/main_page.h b/src/common/doc/main_page.h
index 689e7a4d..41b8ba1e 100644
--- a/src/common/doc/main_page.h
+++ b/src/common/doc/main_page.h
@@ -56,6 +56,7 @@
* The following example requires the <a target="_blank" href="http://gmplib.org/">GNU Multiple Precision Arithmetic
* Library</a> (GMP) and will not be built if GMP is not installed:
* \li Persistent_cohomology/rips_multifield_persistence
+ *
* Having GMP version 4.2 or higher installed is recommended.
*
* \subsection cgal CGAL:
@@ -72,19 +73,15 @@
*
* \subsection demos Demos and examples
* To build the demos and libraries, run the following commands in a terminal:
- * \verbatim
- * cd /path-to-gudhi/
- * mkdir build
- * cd build/
- * cmake ..
- * make
- * \endverbatim
+\verbatim cd /path-to-gudhi/
+mkdir build
+cd build/
+cmake ..
+make \endverbatim
*
* \subsection testsuites Test suites
* To test your build, run the following command in a terminal:
- * \verbatim
- * make test
- * \endverbatim
+ * \verbatim make test \endverbatim
*
* \section Contributions Bug reports and contributions
* Please help us improving the quality of the GUDHI library. You may report bugs or suggestions to:
diff --git a/src/common/include/gudhi/allocator.h b/src/common/include/gudhi/allocator.h
new file mode 100644
index 00000000..4ede14e4
--- /dev/null
+++ b/src/common/include/gudhi/allocator.h
@@ -0,0 +1,55 @@
+/* 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): Marc Glisse
+ *
+ * Copyright (C) 2015 INRIA Saclay - Ile de France
+ *
+ * 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/>.
+ */
+
+#ifndef ALLOCATOR_H_
+#define ALLOCATOR_H_
+
+#include <memory>
+#include <utility>
+
+namespace Gudhi {
+
+/** \private
+ * An allocator that can be used to build an uninitialized vector.
+ */
+template <class T, class Base = std::allocator<T>>
+struct no_init_allocator : Base {
+ typedef std::allocator_traits<Base> Base_traits;
+ template <class U> struct rebind {
+ typedef no_init_allocator<U, typename Base_traits::template rebind_alloc<U>> other;
+ };
+
+ // Inherit constructors.
+ using Base::Base;
+
+ // Do nothing: that's the whole point!
+ template<class P>
+ void construct(P*) noexcept {}
+
+ template<class P, class...U> void construct(P*p, U&&...u) {
+ Base_traits::construct(*(Base*)this, p, std::forward<U>(u)...);
+ }
+};
+
+} // namespace Gudhi
+
+#endif // ALLOCATOR_H_