From 832a6b5d65d25514ce4bd6a7fb6bcaa37856cda3 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Tue, 7 Jul 2015 07:39:29 +0000 Subject: Alpha_shapes removal. Alpha_complex will be added on feature delivery git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/compil_fix@685 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 5e661587777dc5e07ae6ee42f2f5f207189c6a13 --- CMakeLists.txt | 3 --- 1 file changed, 3 deletions(-) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index 02e0c614..7091eef6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,7 +57,6 @@ else() message(STATUS "boost include dirs:" ${Boost_INCLUDE_DIRS}) include_directories(src/common/include/) - include_directories(src/Alpha_shapes/include/) include_directories(src/Bottleneck/include/) include_directories(src/Contraction/include/) include_directories(src/Hasse_complex/include/) @@ -73,8 +72,6 @@ else() add_subdirectory(src/Skeleton_blocker/example) add_subdirectory(src/Contraction/example) add_subdirectory(src/Hasse_complex/example) - add_subdirectory(src/Alpha_shapes/example) - add_subdirectory(src/Alpha_shapes/test) add_subdirectory(src/Bottleneck/example) add_subdirectory(src/Bottleneck/test) -- cgit v1.2.3 From cea027d4c3c688de238ee88b074bc59b7dac22da Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Tue, 7 Jul 2015 09:03:52 +0000 Subject: Add traces for cmake issue on Mac git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/compil_fix@686 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 1557839d804203d796986aa6b61385b336963b13 --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index 7091eef6..d2c07e48 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,6 +55,7 @@ else() LINK_DIRECTORIES(${Boost_LIBRARY_DIRS}) message(STATUS "boost include dirs:" ${Boost_INCLUDE_DIRS}) + message(STATUS "boost library dirs:" ${Boost_LIBRARY_DIRS}) include_directories(src/common/include/) include_directories(src/Bottleneck/include/) -- cgit v1.2.3 From 8259dcb8ae5e21d78b333dddc7bf508907808e95 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Wed, 12 Aug 2015 08:54:44 +0000 Subject: Only one find_package for Boost. Double header inclusion issue. git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@727 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 83ad3a5a97a3c169f6c25ef1ba8fad07f0730a7a --- CMakeLists.txt | 1 - src/CMakeLists.txt | 1 - 2 files changed, 2 deletions(-) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index d2c07e48..6bea06e2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,7 +23,6 @@ set(Boost_USE_STATIC_LIBS ON) set(Boost_USE_MULTITHREADED ON) set(Boost_USE_STATIC_RUNTIME OFF) -find_package(Boost) find_package(GMP) if(GMP_FOUND) find_package(GMPXX) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9f6db2c7..545b0b58 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -19,7 +19,6 @@ set(Boost_USE_STATIC_LIBS ON) set(Boost_USE_MULTITHREADED ON) set(Boost_USE_STATIC_RUNTIME OFF) -find_package(Boost) find_package(GMP) if(GMP_FOUND) find_package(GMPXX) -- cgit v1.2.3 From 69fa48ea8bf9fd9e49363ab405d3e55306be848b Mon Sep 17 00:00:00 2001 From: glisse Date: Mon, 28 Sep 2015 16:41:20 +0000 Subject: Release CAM cells. There are a lot of intrusive containers in there, and I believe that most could be replaced with regular containers. git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@800 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 7246d7db0511ac6bffee2f645c006416a986629d --- CMakeLists.txt | 4 ++-- .../include/gudhi/Persistent_cohomology.h | 11 +++++------ 2 files changed, 7 insertions(+), 8 deletions(-) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index 6bea06e2..047079bc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,7 @@ 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 "${CMAKE_CXX_FLAGS} -O2 -std=c++11 -Wall -Wpedantic -Wno-sign-compare") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -ggdb -O0") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}") endif() @@ -76,7 +76,7 @@ else() add_subdirectory(src/Bottleneck/test) # GudhUI - add_subdirectory(src/GudhUI) + #add_subdirectory(src/GudhUI) # data points generator add_subdirectory(data/points/generator) diff --git a/src/Persistent_cohomology/include/gudhi/Persistent_cohomology.h b/src/Persistent_cohomology/include/gudhi/Persistent_cohomology.h index 05f70c39..efe20151 100644 --- a/src/Persistent_cohomology/include/gudhi/Persistent_cohomology.h +++ b/src/Persistent_cohomology/include/gudhi/Persistent_cohomology.h @@ -266,13 +266,10 @@ class Persistent_cohomology { } ~Persistent_cohomology() { -// Clean the remaining columns in the matrix. - for (auto & cam_ref : cam_) { - cam_ref.col_.clear(); - } -// Clean the transversal lists + // Clean the transversal lists for (auto & transverse_ref : transverse_idx_) { - transverse_ref.second.row_->clear(); + // Release all the cells + transverse_ref.second.row_->clear_and_dispose([&](Cell*p){cell_pool_.destroy(p);}); delete transverse_ref.second.row_; } } @@ -600,6 +597,8 @@ class Persistent_cohomology { Simplex_key key_tmp = dsets_.find_set(curr_col->class_key_); ds_repr_[key_tmp] = &(*(result_insert_cam.first)); result_insert_cam.first->class_key_ = key_tmp; + // intrusive containers don't own their elements, we have to release them manually + curr_col->col_.clear_and_dispose([&](Cell*p){cell_pool_.destroy(p);}); column_pool_.destroy(curr_col); // delete curr_col; } } -- cgit v1.2.3 From fb0a592e87816c30101c2a69e72b59e98d44c2fa Mon Sep 17 00:00:00 2001 From: glisse Date: Mon, 28 Sep 2015 16:43:16 +0000 Subject: Revert CMakeLists.txt changes that were not meant to be committed. git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@801 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 7d2fd6075973bea9816fb140cc4636ce80eb8b8b --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index 047079bc..6bea06e2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,7 @@ 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 -Wno-sign-compare") + 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() @@ -76,7 +76,7 @@ else() add_subdirectory(src/Bottleneck/test) # GudhUI - #add_subdirectory(src/GudhUI) + add_subdirectory(src/GudhUI) # data points generator add_subdirectory(data/points/generator) -- cgit v1.2.3 From 2e582f5a617ed7a4faaafa8930ae7291146a4543 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Tue, 6 Oct 2015 13:44:03 +0000 Subject: GUDHIConfig.cmake and GUDHIVersion.cmake generation generate_version.sh modification to take into account these new files git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@830 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 54d3d4f963fb29c9a142be1c28458ce05215ec79 --- CMakeGUDHIVersion.txt | 6 ++++ CMakeLists.txt | 4 +++ GUDHIVersion.cmake.in | 1 + Version.txt | 1 - scripts/generate_version.sh | 6 ++-- src/CMakeLists.txt | 72 +++++++++++++++++++++++++++++++++++++++------ src/GUDHIConfig.cmake.in | 15 ++++++++++ 7 files changed, 93 insertions(+), 12 deletions(-) create mode 100644 CMakeGUDHIVersion.txt create mode 100644 GUDHIVersion.cmake.in delete mode 100644 Version.txt create mode 100644 src/GUDHIConfig.cmake.in (limited to 'CMakeLists.txt') diff --git a/CMakeGUDHIVersion.txt b/CMakeGUDHIVersion.txt new file mode 100644 index 00000000..19d10535 --- /dev/null +++ b/CMakeGUDHIVersion.txt @@ -0,0 +1,6 @@ +set (GUDHI_MAJOR_VERSION 1) +set (GUDHI_MINOR_VERSION 2) +set (GUDHI_PATCH_VERSION 0) +set(GUDHI_VERSION ${GUDHI_MAJOR_VERSION}.${GUDHI_MINOR_VERSION}.${GUDHI_PATCH_VERSION}) + +message(STATUS "GUDHI version : ${GUDHI_VERSION}") diff --git a/CMakeLists.txt b/CMakeLists.txt index 6bea06e2..91030185 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,10 @@ cmake_minimum_required(VERSION 2.6) project(GUDHIdev) +include(CMakeGUDHIVersion.txt) +# Generate GUDHI official version file +configure_file(GUDHIVersion.cmake.in "${PROJECT_BINARY_DIR}/GUDHIVersion.cmake" @ONLY) + 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/") diff --git a/GUDHIVersion.cmake.in b/GUDHIVersion.cmake.in new file mode 100644 index 00000000..2f433c1c --- /dev/null +++ b/GUDHIVersion.cmake.in @@ -0,0 +1 @@ +@GUDHI_VERSION@ diff --git a/Version.txt b/Version.txt deleted file mode 100644 index 9084fa2f..00000000 --- a/Version.txt +++ /dev/null @@ -1 +0,0 @@ -1.1.0 diff --git a/scripts/generate_version.sh b/scripts/generate_version.sh index e7575282..b1657754 100755 --- a/scripts/generate_version.sh +++ b/scripts/generate_version.sh @@ -4,12 +4,13 @@ #usage bash generate_version.sh -f DIR : generate even if svn is empty and save library in dir # # 23/06/2015 - Remove source, add biblio, and doc +# 06/10/2015 - Replace static Version.txt with generated GUDHIVersion.cmake file # VERSION CHECK ROOT_DIR=.. -VERSION_FILE="$ROOT_DIR/Version.txt" +VERSION_FILE="$ROOT_DIR/GUDHIVersion.cmake" if [ ! -f $VERSION_FILE ]; then - echo "File not found! : $VERSION_FILE" + echo "File not found! : $VERSION_FILE - Please launch cmake first to generate file" exit 1 fi @@ -44,6 +45,7 @@ mkdir "$VERSION_DIR" # TOP LEVEL FILE COPY cp $VERSION_FILE $VERSION_DIR +cp $ROOT_DIR/CMakeGUDHIVersion.txt $VERSION_DIR cp $ROOT_DIR/README $VERSION_DIR cp $ROOT_DIR/Conventions.txt $VERSION_DIR cp $ROOT_DIR/COPYING $VERSION_DIR diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3e21870f..e8297aa8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,16 +1,12 @@ cmake_minimum_required(VERSION 2.6) project(GUDHI) -# Do not forget to version number. -set (GUDHI_MAJOR_VERSION 1) -set (GUDHI_MINOR_VERSION 2) -set (GUDHI_PATCH_VERSION 0) +include("CMakeGUDHIVersion.txt") 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() @@ -40,9 +36,35 @@ else() add_definitions(-DBOOST_ALL_NO_LIB) INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS}) - LINK_DIRECTORIES(${Boost_LIBRARY_DIRS}) - include_directories(include/) - + LINK_DIRECTORIES(${Boost_LIBRARY_DIRS}) + + #--------------------------------------------------------------------------------------- + # GUDHIConfig.cmake 1st part + + # Offer the user the choice of overriding the installation directories - i.e. "cmake -DGUDHI_DIR=~/gudhi/GUDHI_1.2.0 ." + set(INSTALL_LIB_DIR lib CACHE PATH "Installation directory for libraries") + set(INSTALL_BIN_DIR bin CACHE PATH "Installation directory for executables") + set(INSTALL_INCLUDE_DIR include CACHE PATH "Installation directory for header files") + if(WIN32 AND NOT CYGWIN) + set(DEF_INSTALL_CMAKE_DIR CMake) + else() + set(DEF_INSTALL_CMAKE_DIR lib/CMake/GUDHI) + endif() + set(INSTALL_CMAKE_DIR ${DEF_INSTALL_CMAKE_DIR} CACHE PATH "Installation directory for CMake files") + + # Make relative paths absolute (needed later on) + foreach(p LIB BIN INCLUDE CMAKE) + set(var INSTALL_${p}_DIR) + if(NOT IS_ABSOLUTE "${${var}}") + set(${var} "${CMAKE_INSTALL_PREFIX}/${${var}}") + endif() + endforeach() + #--------------------------------------------------------------------------------------- + + #--------------------------------------------------------------------------------------- + # Gudhi compilation part + include_directories(include) + add_subdirectory(example/Simplex_tree) add_subdirectory(example/Persistent_cohomology) add_subdirectory(example/Skeleton_blocker) @@ -55,7 +77,39 @@ else() # data points generator add_subdirectory(data/points/generator) + #--------------------------------------------------------------------------------------- + + #--------------------------------------------------------------------------------------- + # GUDHIConfig.cmake 2nd part + # Export the package for use from the build-tree + # (this registers the build-tree with a global CMake-registry) + export(PACKAGE GUDHI) + + # Create the GUDHIConfig.cmake and GUDHIConfigVersion files + file(RELATIVE_PATH REL_INCLUDE_DIR "${INSTALL_CMAKE_DIR}" "${INSTALL_INCLUDE_DIR}") + # ... for the build tree + set(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/include" "${PROJECT_BINARY_DIR}/include") + configure_file(GUDHIConfig.cmake.in "${PROJECT_BINARY_DIR}/GUDHIConfig.cmake" @ONLY) + # ... for the install tree + set(CONF_INCLUDE_DIRS "\${GUDHI_CMAKE_DIR}/${REL_INCLUDE_DIR}") + configure_file(GUDHIConfig.cmake.in "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/GUDHIConfig.cmake" @ONLY) + # ... for both + configure_file(GUDHIConfigVersion.cmake.in "${PROJECT_BINARY_DIR}/GUDHIConfigVersion.cmake" @ONLY) + + configure_file(GUDHIVersion.cmake.in "${PROJECT_BINARY_DIR}/GUDHIVersion.cmake" @ONLY) + + # Install the GUDHIConfig.cmake and GUDHIConfigVersion.cmake + install(FILES + "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/GUDHIConfig.cmake" + "${PROJECT_BINARY_DIR}/GUDHIConfigVersion.cmake" + DESTINATION "${INSTALL_CMAKE_DIR}" COMPONENT dev) + #--------------------------------------------------------------------------------------- + + #--------------------------------------------------------------------------------------- + # Gudhi installation part - install (DIRECTORY include/gudhi DESTINATION include) + # install the include file on "make install" + install(DIRECTORY include/gudhi DESTINATION include) + #--------------------------------------------------------------------------------------- endif() diff --git a/src/GUDHIConfig.cmake.in b/src/GUDHIConfig.cmake.in new file mode 100644 index 00000000..83aa61e7 --- /dev/null +++ b/src/GUDHIConfig.cmake.in @@ -0,0 +1,15 @@ +# - Config file for the GUDHI package +# It defines the following variables +# GUDHI_INCLUDE_DIRS - include directories for GUDHI +# GUDHI_LIBRARIES - libraries to link against +# GUDHI_EXECUTABLE - the executables + +# Compute paths +get_filename_component(GUDHI_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) +set(GUDHI_INCLUDE_DIRS "@CONF_INCLUDE_DIRS@") + +# Our library dependencies (contains definitions for IMPORTED targets) +include("${GUDHI_CMAKE_DIR}/GUDHITargets.cmake") + +# These are IMPORTED targets created by GUDHITargets.cmake +set(GUDHI_EXECUTABLE mini_simplex_tree) -- cgit v1.2.3 From 384343575eee5fc99440f1f42258b7cb43a3c3a7 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Wed, 7 Oct 2015 07:32:02 +0000 Subject: Let GudhUI in last compilation position as QT is known for modifying CMAKE_CXX_FLAGS git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@836 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: f3bbe579d98a098b4adc89349e619983ceba225b --- CMakeLists.txt | 7 ++++--- src/CMakeLists.txt | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index 91030185..76e55d43 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -79,12 +79,13 @@ else() add_subdirectory(src/Bottleneck/example) add_subdirectory(src/Bottleneck/test) - # GudhUI - add_subdirectory(src/GudhUI) - # data points generator add_subdirectory(data/points/generator) + # Please let GudhUI in last compilation position as QT is known to modify CMAKE_CXX_FLAGS + # GudhUI + add_subdirectory(src/GudhUI) + endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5be629f7..b782b9f3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -51,11 +51,12 @@ else() add_subdirectory(example/Hasse_complex) add_subdirectory(example/Bottleneck) - # GudhUI - add_subdirectory(GudhUI) - # data points generator add_subdirectory(data/points/generator) + + # Please let GudhUI in last compilation position as QT is known to modify CMAKE_CXX_FLAGS + # GudhUI + add_subdirectory(GudhUI) #--------------------------------------------------------------------------------------- #--------------------------------------------------------------------------------------- -- cgit v1.2.3 From 6dd03d72142c98c4348e1b95d538de3b184bbc59 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Thu, 8 Oct 2015 14:09:30 +0000 Subject: cpplint fixes on Contraction + warning fixes + Hide Hasse complex for Gudhi version 1.2.0 git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@841 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: ed7bf90a9ae0b000b995c6ae4bbdaedbb1a65dd5 --- CMakeLists.txt | 3 - src/CMakeLists.txt | 2 - .../CGAL_queue/Modifiable_priority_queue.h | 6 +- .../Contraction/policies/Contraction_visitor.h | 164 +++++------ .../gudhi/Contraction/policies/Cost_policy.h | 76 ++--- .../Contraction/policies/Dummy_valid_contraction.h | 84 +++--- .../gudhi/Contraction/policies/Edge_length_cost.h | 90 +++--- .../Contraction/policies/First_vertex_placement.h | 81 +++--- .../policies/Link_condition_valid_contraction.h | 96 +++--- .../gudhi/Contraction/policies/Middle_placement.h | 87 +++--- .../gudhi/Contraction/policies/Placement_policy.h | 76 ++--- .../policies/Valid_contraction_policy.h | 80 ++--- src/Hasse_complex/example/CMakeLists.txt | 5 - .../example/hasse_complex_from_simplex_tree.cpp | 124 -------- src/Hasse_complex/include/gudhi/Hasse_complex.h | 323 +++++++++++---------- src/Simplex_tree/test/simplex_tree_unit_test.cpp | 3 + .../test/TestSkeletonBlockerComplex.cpp | 2 +- src/common/include/gudhi/Off_reader.h | 2 +- 18 files changed, 598 insertions(+), 706 deletions(-) delete mode 100644 src/Hasse_complex/example/CMakeLists.txt delete mode 100644 src/Hasse_complex/example/hasse_complex_from_simplex_tree.cpp (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index 76e55d43..ae089562 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -75,9 +75,6 @@ else() add_subdirectory(src/Skeleton_blocker/test) add_subdirectory(src/Skeleton_blocker/example) add_subdirectory(src/Contraction/example) - add_subdirectory(src/Hasse_complex/example) - add_subdirectory(src/Bottleneck/example) - add_subdirectory(src/Bottleneck/test) # data points generator add_subdirectory(data/points/generator) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b782b9f3..a84090e9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -48,8 +48,6 @@ else() add_subdirectory(example/Persistent_cohomology) add_subdirectory(example/Skeleton_blocker) add_subdirectory(example/Contraction) - add_subdirectory(example/Hasse_complex) - add_subdirectory(example/Bottleneck) # data points generator add_subdirectory(data/points/generator) diff --git a/src/Contraction/include/gudhi/Contraction/CGAL_queue/Modifiable_priority_queue.h b/src/Contraction/include/gudhi/Contraction/CGAL_queue/Modifiable_priority_queue.h index f4eb59fd..28ae535d 100644 --- a/src/Contraction/include/gudhi/Contraction/CGAL_queue/Modifiable_priority_queue.h +++ b/src/Contraction/include/gudhi/Contraction/CGAL_queue/Modifiable_priority_queue.h @@ -21,10 +21,12 @@ #define CGAL_SURFACE_MESH_SIMPLIFICATION_USE_RELAXED_HEAP -#include // Neeeded by the following Boost header for CHAR_BIT. #include #include +#include // Neeeded by the following Boost header for CHAR_BIT. +#include // for less + namespace CGAL { template , class ID_ = boost::identity_property_map> @@ -94,6 +96,6 @@ class Modifiable_priority_queue { Heap mHeap; }; -} //namespace CGAL +} // namespace CGAL #endif // CONTRACTION_CGAL_MODIFIABLE_PRIORITY_QUEUE_H diff --git a/src/Contraction/include/gudhi/Contraction/policies/Contraction_visitor.h b/src/Contraction/include/gudhi/Contraction/policies/Contraction_visitor.h index b8b1e87a..7ee05aad 100644 --- a/src/Contraction/include/gudhi/Contraction/policies/Contraction_visitor.h +++ b/src/Contraction/include/gudhi/Contraction/policies/Contraction_visitor.h @@ -1,32 +1,32 @@ - /* 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 . - */ - -#ifndef GUDHI_CONTRACTION_VISITOR_H_ -#define GUDHI_CONTRACTION_VISITOR_H_ - -#include "gudhi/Contraction/Edge_profile.h" -#include "boost/optional.hpp" - -namespace Gudhi{ +/* 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 . + */ + +#ifndef CONTRACTION_POLICIES_CONTRACTION_VISITOR_H_ +#define CONTRACTION_POLICIES_CONTRACTION_VISITOR_H_ + +#include +#include + +namespace Gudhi { namespace contraction { @@ -36,66 +36,56 @@ namespace contraction { *@ingroup contr */ template -class Contraction_visitor {//: public Dummy_complex_visitor { -public: - //typedef typename ComplexType::GeometryTrait GT; - typedef EdgeProfile Profile; - typedef double FT; - typedef typename Profile::Complex Complex; - typedef Complex ComplexType; - typedef typename ComplexType::Point Point; - - - virtual ~Contraction_visitor(){}; - - /** - * @brief Called before the edge contraction process starts. - */ - virtual void on_started (ComplexType & complex){} - - /** - * @brief Called when the algorithm stops. - */ - virtual void on_stop_condition_reached (){} - - - /** - * @brief Called during the collecting phase (when a cost is assigned to the edges), for each edge collected. - */ - virtual void on_collected (const Profile &profile, boost::optional< FT > cost){} - - /** - * @brief Called during the processing phase (when edges are contracted), for each edge that is selected. - */ - virtual void on_selected (const Profile &profile, boost::optional< FT > cost, int initial_count, int current_count){} - - - /** - * @brief Called when an edge is about to be contracted and replaced by a vertex whose position is *placement. - */ - virtual void on_contracting(const Profile &profile, boost::optional< Point > placement){ - } - - - - /** - * @brief Called when after an edge has been contracted onto a new point placement. - * A possibility would to remove popable blockers at this point for instance. - */ - virtual void on_contracted(const Profile &profile, boost::optional< Point > placement){ - - } - - - /** - * @brief Called for each selected edge which cannot be contracted because the ValidContractionPredicate is false - */ - virtual void on_non_valid(const Profile &profile){} - +class Contraction_visitor { // : public Dummy_complex_visitor { + public: + // typedef typename ComplexType::GeometryTrait GT; + typedef EdgeProfile Profile; + typedef double FT; + typedef typename Profile::Complex Complex; + typedef Complex ComplexType; + typedef typename ComplexType::Point Point; + + virtual ~Contraction_visitor() { } + + /** + * @brief Called before the edge contraction process starts. + */ + virtual void on_started(ComplexType & complex) { } + + /** + * @brief Called when the algorithm stops. + */ + virtual void on_stop_condition_reached() { } + + /** + * @brief Called during the collecting phase (when a cost is assigned to the edges), for each edge collected. + */ + virtual void on_collected(const Profile &profile, boost::optional< FT > cost) { } + + /** + * @brief Called during the processing phase (when edges are contracted), for each edge that is selected. + */ + virtual void on_selected(const Profile &profile, boost::optional< FT > cost, int initial_count, int current_count) { } + + /** + * @brief Called when an edge is about to be contracted and replaced by a vertex whose position is *placement. + */ + virtual void on_contracting(const Profile &profile, boost::optional< Point > placement) { } + + /** + * @brief Called when after an edge has been contracted onto a new point placement. + * A possibility would to remove popable blockers at this point for instance. + */ + virtual void on_contracted(const Profile &profile, boost::optional< Point > placement) { } + + /** + * @brief Called for each selected edge which cannot be contracted because the ValidContractionPredicate is false + */ + virtual void on_non_valid(const Profile &profile) { } }; } // namespace contraction -} // namespace GUDHI +} // namespace Gudhi -#endif /* GUDHI_CONTRACTION_VISITOR_H_ */ +#endif // CONTRACTION_POLICIES_CONTRACTION_VISITOR_H_ diff --git a/src/Contraction/include/gudhi/Contraction/policies/Cost_policy.h b/src/Contraction/include/gudhi/Contraction/policies/Cost_policy.h index 3cb18c86..f4d343ec 100644 --- a/src/Contraction/include/gudhi/Contraction/policies/Cost_policy.h +++ b/src/Contraction/include/gudhi/Contraction/policies/Cost_policy.h @@ -1,51 +1,53 @@ - /* 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 . - */ - -#ifndef GUDHI_COST_POLICY_H_ -#define GUDHI_COST_POLICY_H_ +/* 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 . + */ + +#ifndef CONTRACTION_POLICIES_COST_POLICY_H_ +#define CONTRACTION_POLICIES_COST_POLICY_H_ #include -namespace Gudhi{ +namespace Gudhi { namespace contraction { /** -*@brief Policy to specify the cost of contracting an edge. + *@brief Policy to specify the cost of contracting an edge. *@ingroup contr -*/ -template< typename EdgeProfile> class Cost_policy{ -public: - typedef typename EdgeProfile::Point Point; - typedef typename EdgeProfile::Graph_vertex Graph_vertex; + */ +template< typename EdgeProfile> +class Cost_policy { + public: + typedef typename EdgeProfile::Point Point; + typedef typename EdgeProfile::Graph_vertex Graph_vertex; - typedef boost::optional Cost_type; + typedef boost::optional Cost_type; - virtual Cost_type operator()(const EdgeProfile& profile, const boost::optional& placement) const =0; - virtual ~Cost_policy(){ - }; + virtual Cost_type operator()(const EdgeProfile& profile, const boost::optional& placement) const = 0; + + virtual ~Cost_policy() { } }; } // namespace contraction -} // namespace GUDHI -#endif /* GUDHI_COST_POLICY_H_ */ +} // namespace Gudhi + +#endif // CONTRACTION_POLICIES_COST_POLICY_H_ diff --git a/src/Contraction/include/gudhi/Contraction/policies/Dummy_valid_contraction.h b/src/Contraction/include/gudhi/Contraction/policies/Dummy_valid_contraction.h index de473944..5d329496 100644 --- a/src/Contraction/include/gudhi/Contraction/policies/Dummy_valid_contraction.h +++ b/src/Contraction/include/gudhi/Contraction/policies/Dummy_valid_contraction.h @@ -1,51 +1,49 @@ - /* 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 . - */ - -#ifndef GUDHI_DUMMY_VALID_CONTRACTION_H_ -#define GUDHI_DUMMY_VALID_CONTRACTION_H_ - -#include "Valid_contraction_policy.h" - -namespace Gudhi{ +/* 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 . + */ + +#ifndef CONTRACTION_POLICIES_DUMMY_VALID_CONTRACTION_H_ +#define CONTRACTION_POLICIES_DUMMY_VALID_CONTRACTION_H_ + +#include + +namespace Gudhi { namespace contraction { - - - /** - *@brief Policy that accept all edge contraction. - */ -template< typename EdgeProfile> class Dummy_valid_contraction : public Valid_contraction_policy{ -public: - typedef typename EdgeProfile::Point Point; - bool operator()(const EdgeProfile& profile,const boost::optional& placement){ - return true; - } +/** + *@brief Policy that accept all edge contraction. + */ +template< typename EdgeProfile> +class Dummy_valid_contraction : public Valid_contraction_policy { + public: + typedef typename EdgeProfile::Point Point; + + bool operator()(const EdgeProfile& profile, const boost::optional& placement) { + return true; + } }; } // namespace contraction -} // namespace GUDHI - - +} // namespace Gudhi -#endif /* GUDHI_DUMMY_VALID_CONTRACTION_H_ */ +#endif // CONTRACTION_POLICIES_DUMMY_VALID_CONTRACTION_H_ diff --git a/src/Contraction/include/gudhi/Contraction/policies/Edge_length_cost.h b/src/Contraction/include/gudhi/Contraction/policies/Edge_length_cost.h index b22ada0d..e4beb220 100644 --- a/src/Contraction/include/gudhi/Contraction/policies/Edge_length_cost.h +++ b/src/Contraction/include/gudhi/Contraction/policies/Edge_length_cost.h @@ -1,56 +1,56 @@ - /* 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 . - */ - -#ifndef GUDHI_EDGE_LENGTH_COST_H_ -#define GUDHI_EDGE_LENGTH_COST_H_ - -#include "Cost_policy.h" - -namespace Gudhi{ +/* 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 . + */ -namespace contraction { +#ifndef CONTRACTION_POLICIES_DUMMY_EDGE_LENGTH_COST_H_ +#define CONTRACTION_POLICIES_DUMMY_EDGE_LENGTH_COST_H_ + +#include +namespace Gudhi { + +namespace contraction { /** * @brief return a cost corresponding to the squared length of the edge */ -template< typename EdgeProfile> class Edge_length_cost : public Cost_policy{ -public: - typedef typename Cost_policy::Cost_type Cost_type; - typedef typename EdgeProfile::Point Point; - Cost_type operator()(const EdgeProfile& profile, const boost::optional& placement) const override{ - double res = 0; - auto p0_coord = profile.p0().begin(); - auto p1_coord = profile.p1().begin(); - for(; p0_coord != profile.p0().end(); p0_coord++, p1_coord++){ - res += (*p0_coord - *p1_coord) * (*p0_coord - *p1_coord); - } - return res; - } - +template< typename EdgeProfile> +class Edge_length_cost : public Cost_policy { + public: + typedef typename Cost_policy::Cost_type Cost_type; + typedef typename EdgeProfile::Point Point; + + Cost_type operator()(const EdgeProfile& profile, const boost::optional& placement) const override { + double res = 0; + auto p0_coord = profile.p0().begin(); + auto p1_coord = profile.p1().begin(); + for (; p0_coord != profile.p0().end(); p0_coord++, p1_coord++) { + res += (*p0_coord - *p1_coord) * (*p0_coord - *p1_coord); + } + return res; + } }; } // namespace contraction -} // namespace GUDHI +} // namespace Gudhi -#endif /* GUDHI_EDGE_LENGTH_COST_H_ */ +#endif // CONTRACTION_POLICIES_DUMMY_EDGE_LENGTH_COST_H_ diff --git a/src/Contraction/include/gudhi/Contraction/policies/First_vertex_placement.h b/src/Contraction/include/gudhi/Contraction/policies/First_vertex_placement.h index 93abac35..1f68db0d 100644 --- a/src/Contraction/include/gudhi/Contraction/policies/First_vertex_placement.h +++ b/src/Contraction/include/gudhi/Contraction/policies/First_vertex_placement.h @@ -1,53 +1,52 @@ - /* 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 . - */ - -#ifndef GUDHI_FIRST_VERTEX_PLACEMENT_H_ -#define GUDHI_FIRST_VERTEX_PLACEMENT_H_ - -#include "Placement_policy.h" - -namespace Gudhi{ +/* 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 . + */ -namespace contraction { +#ifndef CONTRACTION_POLICIES_FIRST_VERTEX_PLACEMENT_H_ +#define CONTRACTION_POLICIES_FIRST_VERTEX_PLACEMENT_H_ + +#include + +namespace Gudhi { +namespace contraction { /** * @brief Places the contracted point onto the first point of the edge */ -template< typename EdgeProfile> class First_vertex_placement : public Placement_policy{ - -public: - typedef typename EdgeProfile::Point Point; - typedef typename EdgeProfile::Edge_handle Edge_handle; +template< typename EdgeProfile> +class First_vertex_placement : public Placement_policy { + public: + typedef typename EdgeProfile::Point Point; + typedef typename EdgeProfile::Edge_handle Edge_handle; - typedef typename Placement_policy::Placement_type Placement_type; + typedef typename Placement_policy::Placement_type Placement_type; - Placement_type operator()(const EdgeProfile& profile) const override{ - return Placement_type(profile.p0()); - } + Placement_type operator()(const EdgeProfile& profile) const override { + return Placement_type(profile.p0()); + } }; -} // namespace contraction -} // namespace GUDHI +} // namespace contraction +} // namespace Gudhi -#endif /* GUDHI_FIRST_VERTEX_PLACEMENT_H_ */ +#endif // CONTRACTION_POLICIES_FIRST_VERTEX_PLACEMENT_H_ diff --git a/src/Contraction/include/gudhi/Contraction/policies/Link_condition_valid_contraction.h b/src/Contraction/include/gudhi/Contraction/policies/Link_condition_valid_contraction.h index c901e629..919df243 100644 --- a/src/Contraction/include/gudhi/Contraction/policies/Link_condition_valid_contraction.h +++ b/src/Contraction/include/gudhi/Contraction/policies/Link_condition_valid_contraction.h @@ -1,54 +1,56 @@ - /* 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 . - */ - -#ifndef GUDHI_LINK_CONDITION_VALID_CONTRACTION_H_ -#define GUDHI_LINK_CONDITION_VALID_CONTRACTION_H_ - -#include "gudhi/Utils.h" -#include "Valid_contraction_policy.h" - - -namespace Gudhi{ +/* 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 . + */ + +#ifndef CONTRACTION_POLICIES_LINK_CONDITION_VALID_CONTRACTION_H_ +#define CONTRACTION_POLICIES_LINK_CONDITION_VALID_CONTRACTION_H_ + +#include +#include + + +namespace Gudhi { namespace contraction { - - /** - *@brief Policy that only accept edges verifying the link condition (and therefore whose contraction preserving homotopy type). - *@ingroup contr - */ -template< typename EdgeProfile> class Link_condition_valid_contraction : public Valid_contraction_policy{ -public: - typedef typename EdgeProfile::Edge_handle Edge_handle; - typedef typename EdgeProfile::Point Point; - //typedef typename EdgeProfile::Edge_handle Edge_handle; - bool operator()(const EdgeProfile& profile,const boost::optional& placement) const override{ - Edge_handle edge(profile.edge_handle()); - DBGMSG("Link_condition_valid_contraction:",profile.complex().link_condition(edge)); - return profile.complex().link_condition(edge); - } +/** + *@brief Policy that only accept edges verifying the link condition (and therefore whose contraction preserving homotopy type). + *@ingroup contr + */ +template< typename EdgeProfile> +class Link_condition_valid_contraction : public Valid_contraction_policy { + public: + typedef typename EdgeProfile::Edge_handle Edge_handle; + typedef typename EdgeProfile::Point Point; + // typedef typename EdgeProfile::Edge_handle Edge_handle; + + bool operator()(const EdgeProfile& profile, const boost::optional& placement) const override { + Edge_handle edge(profile.edge_handle()); + DBGMSG("Link_condition_valid_contraction:", profile.complex().link_condition(edge)); + return profile.complex().link_condition(edge); + } }; + } // namespace contraction -} // namespace GUDHI +} // namespace Gudhi -#endif /* GUDHI_LINK_CONDITION_VALID_CONTRACTION_H_ */ +#endif // CONTRACTION_POLICIES_LINK_CONDITION_VALID_CONTRACTION_H_ diff --git a/src/Contraction/include/gudhi/Contraction/policies/Middle_placement.h b/src/Contraction/include/gudhi/Contraction/policies/Middle_placement.h index 30f0a570..4b59f1b5 100644 --- a/src/Contraction/include/gudhi/Contraction/policies/Middle_placement.h +++ b/src/Contraction/include/gudhi/Contraction/policies/Middle_placement.h @@ -1,52 +1,51 @@ - /* 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 . - */ - -#ifndef GUDHI_MIDDLE_PLACEMENT_H_ -#define GUDHI_MIDDLE_PLACEMENT_H_ - -#include "Placement_policy.h" - - -namespace Gudhi{ +/* 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 . + */ + +#ifndef CONTRACTION_POLICIES_MIDDLE_PLACEMENT_H_ +#define CONTRACTION_POLICIES_MIDDLE_PLACEMENT_H_ + +#include + +namespace Gudhi { namespace contraction { +template< typename EdgeProfile> +class Middle_placement : public Placement_policy { + public: + typedef typename EdgeProfile::Point Point; + typedef typename EdgeProfile::Edge_handle Edge_handle; + typedef typename EdgeProfile::Graph_vertex Graph_vertex; - -template< typename EdgeProfile> class Middle_placement : public Placement_policy{ + typedef typename Placement_policy::Placement_type Placement_type; -public: - typedef typename EdgeProfile::Point Point; - typedef typename EdgeProfile::Edge_handle Edge_handle; - typedef typename EdgeProfile::Graph_vertex Graph_vertex; - - typedef typename Placement_policy::Placement_type Placement_type; - - Placement_type operator()(const EdgeProfile& profile) const override{ - //todo compute the middle - return Placement_type(profile.p0()); - } + Placement_type operator()(const EdgeProfile& profile) const override { + // todo compute the middle + return Placement_type(profile.p0()); + } }; + } // namespace contraction -} // namespace GUDHI -#endif /* GUDHI_MIDDLE_PLACEMENT_H_ */ +} // namespace Gudhi + +#endif // CONTRACTION_POLICIES_MIDDLE_PLACEMENT_H_ diff --git a/src/Contraction/include/gudhi/Contraction/policies/Placement_policy.h b/src/Contraction/include/gudhi/Contraction/policies/Placement_policy.h index 3a804cf0..34ffa49f 100644 --- a/src/Contraction/include/gudhi/Contraction/policies/Placement_policy.h +++ b/src/Contraction/include/gudhi/Contraction/policies/Placement_policy.h @@ -1,49 +1,51 @@ - /* 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 . - */ - -#ifndef GUDHI_PLACEMENT_POLICY_H_ -#define GUDHI_PLACEMENT_POLICY_H_ +/* 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 . + */ + +#ifndef CONTRACTION_POLICIES_PLACEMENT_POLICY_H_ +#define CONTRACTION_POLICIES_PLACEMENT_POLICY_H_ #include namespace Gudhi { + namespace contraction { +/** + *@brief Policy to specify where the merged point had to be placed after an edge contraction. + *@ingroup contr + */ +template< typename EdgeProfile> +class Placement_policy { + public: + typedef typename EdgeProfile::Point Point; + typedef boost::optional Placement_type; - /** - *@brief Policy to specify where the merged point had to be placed after an edge contraction. - *@ingroup contr - */ -template< typename EdgeProfile> class Placement_policy{ -public: - typedef typename EdgeProfile::Point Point; - typedef boost::optional Placement_type; + virtual Placement_type operator()(const EdgeProfile& profile) const = 0; - virtual Placement_type operator()(const EdgeProfile& profile) const=0; - virtual ~Placement_policy(){}; + virtual ~Placement_policy() { } }; - } // namespace contraction -} // namespace GUDHI -#endif /* GUDHI_PLACEMENT_POLICY_H_ */ +} // namespace Gudhi + +#endif // CONTRACTION_POLICIES_PLACEMENT_POLICY_H_ diff --git a/src/Contraction/include/gudhi/Contraction/policies/Valid_contraction_policy.h b/src/Contraction/include/gudhi/Contraction/policies/Valid_contraction_policy.h index bee2ecd7..78d61173 100644 --- a/src/Contraction/include/gudhi/Contraction/policies/Valid_contraction_policy.h +++ b/src/Contraction/include/gudhi/Contraction/policies/Valid_contraction_policy.h @@ -1,47 +1,51 @@ - /* 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 . - */ - -#ifndef GUDHI_VALID_CONTRACTION_POLICY_H_ -#define GUDHI_VALID_CONTRACTION_POLICY_H_ +/* 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 . + */ + +#ifndef CONTRACTION_POLICIES_VALID_CONTRACTION_POLICY_H_ +#define CONTRACTION_POLICIES_VALID_CONTRACTION_POLICY_H_ namespace Gudhi { + namespace contraction { - /** - *@brief Policy to specify if an edge contraction is valid or not. - *@ingroup contr - */ -template< typename EdgeProfile> class Valid_contraction_policy{ -public: - typedef typename EdgeProfile::Point Point; - typedef typename EdgeProfile::Edge_handle Edge_handle; - typedef typename EdgeProfile::Graph_vertex Graph_vertex; - - virtual bool operator()(const EdgeProfile& profile,const boost::optional& placement) const =0; - virtual ~Valid_contraction_policy(){}; +/** + *@brief Policy to specify if an edge contraction is valid or not. + *@ingroup contr + */ +template< typename EdgeProfile> +class Valid_contraction_policy { + public: + typedef typename EdgeProfile::Point Point; + typedef typename EdgeProfile::Edge_handle Edge_handle; + typedef typename EdgeProfile::Graph_vertex Graph_vertex; + + virtual bool operator()(const EdgeProfile& profile, const boost::optional& placement) const = 0; + + virtual ~Valid_contraction_policy() { } }; } // namespace contraction -} // namespace GUDHI + +} // namespace Gudhi -#endif /* GUDHI_VALID_CONTRACTION_POLICY_H_ */ +#endif // CONTRACTION_POLICIES_VALID_CONTRACTION_POLICY_H_ diff --git a/src/Hasse_complex/example/CMakeLists.txt b/src/Hasse_complex/example/CMakeLists.txt deleted file mode 100644 index 564df49d..00000000 --- a/src/Hasse_complex/example/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -cmake_minimum_required(VERSION 2.6) -project(GUDHIHasseComplexExample) - -add_executable ( hasse_complex_from_simplex_tree hasse_complex_from_simplex_tree.cpp ) -add_test(hasse_complex_from_simplex_tree ${CMAKE_CURRENT_BINARY_DIR}/hasse_complex_from_simplex_tree) diff --git a/src/Hasse_complex/example/hasse_complex_from_simplex_tree.cpp b/src/Hasse_complex/example/hasse_complex_from_simplex_tree.cpp deleted file mode 100644 index 1de43ab7..00000000 --- a/src/Hasse_complex/example/hasse_complex_from_simplex_tree.cpp +++ /dev/null @@ -1,124 +0,0 @@ -/* 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): Vincent Rouvreau - * - * Copyright (C) 2014 INRIA Saclay (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 . - */ - -#include -#include -#include "gudhi/graph_simplicial_complex.h" -#include "gudhi/Simplex_tree.h" - -using namespace Gudhi; - -typedef std::vector< Vertex_handle > typeVectorVertex; -typedef std::pair typeSimplex; -typedef std::pair< Simplex_tree<>::Simplex_handle, bool > typePairSimplexBool; -typedef Simplex_tree<> typeST; - -int main(int argc, char * const argv[]) { - // TEST OF INSERTION - std::cout << "********************************************************************" << std::endl; - std::cout << "TEST OF INSERTION" << std::endl; - typeST st; - - // ++ FIRST - std::cout << " - INSERT (2,1,0)" << std::endl; - typeVectorVertex SimplexVector1; - SimplexVector1.push_back(2); - SimplexVector1.push_back(1); - SimplexVector1.push_back(0); - st.insert_simplex_and_subfaces(SimplexVector1, 0.3); - - // ++ SECOND - std::cout << " - INSERT 3" << std::endl; - typeVectorVertex SimplexVector2; - SimplexVector2.push_back(3); - st.insert_simplex_and_subfaces(SimplexVector2, 0.1); - - // ++ THIRD - std::cout << " - INSERT (0,3)" << std::endl; - typeVectorVertex SimplexVector3; - SimplexVector3.push_back(3); - SimplexVector3.push_back(0); - st.insert_simplex_and_subfaces(SimplexVector3, 0.2); - - // ++ FOURTH - std::cout << " - INSERT (1,0) (already inserted)" << std::endl; - typeVectorVertex SimplexVector4; - SimplexVector4.push_back(1); - SimplexVector4.push_back(0); - st.insert_simplex_and_subfaces(SimplexVector4, 0.2); - - // ++ FIFTH - std::cout << " - INSERT (3,4,5)" << std::endl; - typeVectorVertex SimplexVector5; - SimplexVector5.push_back(3); - SimplexVector5.push_back(4); - SimplexVector5.push_back(5); - st.insert_simplex_and_subfaces(SimplexVector5, 0.3); - - // ++ SIXTH - std::cout << " - INSERT (0,1,6,7)" << std::endl; - typeVectorVertex SimplexVector6; - SimplexVector6.push_back(0); - SimplexVector6.push_back(1); - SimplexVector6.push_back(6); - SimplexVector6.push_back(7); - st.insert_simplex_and_subfaces(SimplexVector6, 0.4); - - /* Inserted simplex: */ - /* 1 6 */ - /* o---o */ - /* /X\7/ 4 */ - /* o---o---o---o */ - /* 2 0 3\X/ */ - /* o */ - /* 5 */ - - /* In other words: */ - /* A facet [2,1,0] */ - /* An edge [0,3] */ - /* A facet [3,4,5] */ - /* A cell [0,1,6,7] */ - /* A cell [4,5,8,9] */ - /* A facet [9,10,11] */ - /* An edge [11,6] */ - /* An edge [10,12,2] */ - - // ++ GENERAL VARIABLE SET - st.set_filtration(0.4); // Max filtration value - st.set_dimension(3); // Max dimension = 3 -> (0,1,6,7) - - std::cout << "The complex contains " << st.num_simplices() << " simplices - " << st.num_vertices() << " vertices " << std::endl; - std::cout << " - dimension " << st.dimension() << " - filtration " << st.filtration() << std::endl; - std::cout << std::endl << std::endl << "Iterator on Simplices in the filtration, with [filtration value]:" << std::endl; - std::cout << "**************************************************************" << std::endl; - - for( auto f_simplex : st.filtration_simplex_range() ) - { - std::cout << " " << "[" << st.filtration(f_simplex) << "] "; - for( auto vertex : st.simplex_vertex_range(f_simplex) ) - { - std::cout << (int)vertex; - } - } - - return 0; -} diff --git a/src/Hasse_complex/include/gudhi/Hasse_complex.h b/src/Hasse_complex/include/gudhi/Hasse_complex.h index 427d9916..c3a84c02 100644 --- a/src/Hasse_complex/include/gudhi/Hasse_complex.h +++ b/src/Hasse_complex/include/gudhi/Hasse_complex.h @@ -1,208 +1,233 @@ - /* 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 - * - * Copyright (C) 2014 INRIA Sophia Antipolis-Méditerranée (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 . - */ - -#ifndef GUDHI_HASSE_DIAGRAM_H -#define GUDHI_HASSE_DIAGRAM_H +/* 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 + * + * Copyright (C) 2014 INRIA Sophia Antipolis-Méditerranée (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 . + */ + +#ifndef HASSE_COMPLEX_H_ +#define HASSE_COMPLEX_H_ -#include #include -namespace Gudhi{ +#include + +namespace Gudhi { template < class HasseCpx > -struct Hasse_simplex -{ -//Complex_ds must verify that cpx->key(sh) is the order of sh in the filtration +struct Hasse_simplex { + // Complex_ds must verify that cpx->key(sh) is the order of sh in the filtration + template< class Complex_ds > - Hasse_simplex ( Complex_ds & cpx - , typename Complex_ds::Simplex_handle sh ) - : key_(cpx.key(sh)) - , filtration_(cpx.filtration(sh)) - , boundary_() - { - boundary_.reserve(cpx.dimension(sh)+1); - for( auto b_sh : cpx.boundary_simplex_range(sh) ) - { boundary_.push_back( cpx.key(b_sh) ); } + Hasse_simplex(Complex_ds & cpx + , typename Complex_ds::Simplex_handle sh) + : key_(cpx.key(sh)) + , filtration_(cpx.filtration(sh)) + , boundary_() { + boundary_.reserve(cpx.dimension(sh) + 1); + for (auto b_sh : cpx.boundary_simplex_range(sh)) { + boundary_.push_back(cpx.key(b_sh)); + } } - Hasse_simplex ( typename HasseCpx::Simplex_key key + Hasse_simplex(typename HasseCpx::Simplex_key key , typename HasseCpx::Filtration_value fil , std::vector boundary) - : key_(key) - , filtration_(fil) - , boundary_(boundary) {} + : key_(key) + , filtration_(fil) + , boundary_(boundary) { } - typename HasseCpx::Simplex_key key_; - typename HasseCpx::Filtration_value filtration_; + typename HasseCpx::Simplex_key key_; + typename HasseCpx::Filtration_value filtration_; std::vector boundary_; }; - - -/** \brief Data structure representing a Hasse diagram, i.e. - * a complex where all codimension 1 incidence - * relations are explicitly encoded. - * - * \implements FilteredComplex - * \ingroup simplex_tree - */ -template < typename FiltrationValue = double - , typename SimplexKey = int - , typename VertexHandle = int - > -class Hasse_complex -{ -public: - - typedef Hasse_simplex Hasse_simp; - typedef FiltrationValue Filtration_value; - typedef SimplexKey Simplex_key; - typedef int Simplex_handle; //index in vector complex_ - - typedef boost::counting_iterator< Simplex_handle > Filtration_simplex_iterator; - typedef boost::iterator_range Filtration_simplex_range; - - typedef typename std::vector< Simplex_handle >::iterator Boundary_simplex_iterator; - typedef boost::iterator_range Boundary_simplex_range; - - typedef typename std::vector< Simplex_handle >::iterator Skeleton_simplex_iterator; - typedef boost::iterator_range< Skeleton_simplex_iterator > Skeleton_simplex_range; - - -/* only dimension 0 skeleton_simplex_range(...) */ - Skeleton_simplex_range skeleton_simplex_range( int dim = 0 ) { - if(dim != 0) { std::cerr << "Dimension must be 0 \n"; } - return Skeleton_simplex_range(vertices_.begin(),vertices_.end()); +/** \private + * \brief Data structure representing a Hasse diagram, i.e. + * a complex where all codimension 1 incidence + * relations are explicitly encoded. + * + * \implements FilteredComplex + * \ingroup simplex_tree + */ +template < typename FiltrationValue = double +, typename SimplexKey = int +, typename VertexHandle = int +> +class Hasse_complex { + public: + + typedef Hasse_simplex Hasse_simp; + typedef FiltrationValue Filtration_value; + typedef SimplexKey Simplex_key; + typedef int Simplex_handle; //index in vector complex_ + + typedef boost::counting_iterator< Simplex_handle > Filtration_simplex_iterator; + typedef boost::iterator_range Filtration_simplex_range; + + typedef typename std::vector< Simplex_handle >::iterator Boundary_simplex_iterator; + typedef boost::iterator_range Boundary_simplex_range; + + typedef typename std::vector< Simplex_handle >::iterator Skeleton_simplex_iterator; + typedef boost::iterator_range< Skeleton_simplex_iterator > Skeleton_simplex_range; + + /* only dimension 0 skeleton_simplex_range(...) */ + Skeleton_simplex_range skeleton_simplex_range(int dim = 0) { + if (dim != 0) { + std::cerr << "Dimension must be 0 \n"; + } + return Skeleton_simplex_range(vertices_.begin(), vertices_.end()); } template < class Complex_ds > Hasse_complex(Complex_ds & cpx) - : complex_() - , vertices_() - , threshold_(cpx.filtration()) - , num_vertices_() - , dim_max_(cpx.dimension()) - { + : complex_() + , 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) { vertices_.push_back(idx); } - ++idx; + for (auto cpx_sh : cpx.filtration_simplex_range()) { + complex_.push_back(Hasse_simp(cpx, cpx_sh)); + if (dimension(idx) == 0) { + vertices_.push_back(idx); + } + ++idx; } } Hasse_complex() - : complex_() - , vertices_() - , threshold_(0) - , num_vertices_(0) - , dim_max_(-1) {} - - size_t num_simplices() { return complex_.size(); } + : complex_() + , vertices_() + , threshold_(0) + , num_vertices_(0) + , dim_max_(-1) { } + + size_t num_simplices() { + return complex_.size(); + } - Filtration_simplex_range filtration_simplex_range() - { return Filtration_simplex_range( Filtration_simplex_iterator(0) - , Filtration_simplex_iterator(complex_.size()) ); } + Filtration_simplex_range filtration_simplex_range() { + return Filtration_simplex_range(Filtration_simplex_iterator(0) + , Filtration_simplex_iterator(complex_.size())); + } - Simplex_key key( Simplex_handle sh ) { return complex_[sh].key_; } + Simplex_key key(Simplex_handle sh) { + return complex_[sh].key_; + } - Simplex_key null_key() { return -1; } + Simplex_key null_key() { + return -1; + } - Simplex_handle simplex( Simplex_key key ) - { - if(key == null_key()) return null_simplex(); + Simplex_handle simplex(Simplex_key key) { + if (key == null_key()) return null_simplex(); return key; } - Simplex_handle null_simplex() { return -1; } + Simplex_handle null_simplex() { + return -1; + } - Filtration_value filtration( Simplex_handle sh ) { - if( sh == null_simplex() ) { return filtration(); } + Filtration_value filtration(Simplex_handle sh) { + if (sh == null_simplex()) { + return filtration(); + } return complex_[sh].filtration_; } - Filtration_value filtration() { return threshold_; } + Filtration_value filtration() { + return threshold_; + } + + int dimension(Simplex_handle sh) { + if (complex_[sh].boundary_.empty()) return 0; + return complex_[sh].boundary_.size() - 1; + } - int dimension ( Simplex_handle sh ) { - if(complex_[sh].boundary_.empty()) return 0; - return complex_[sh].boundary_.size()-1; + int dimension() { + return dim_max_; } - int dimension () { return dim_max_; } - std::pair endpoints( Simplex_handle sh ) - { return std::pair( complex_[sh].boundary_[0] - , complex_[sh].boundary_[1] ) ;} + std::pair endpoints(Simplex_handle sh) { + return std::pair(complex_[sh].boundary_[0] + , complex_[sh].boundary_[1]); + } - void assign_key( Simplex_handle sh, Simplex_key key) { complex_[sh].key_ = key; } + void assign_key(Simplex_handle sh, Simplex_key key) { + complex_[sh].key_ = key; + } - Boundary_simplex_range boundary_simplex_range ( Simplex_handle sh ) - { return Boundary_simplex_range( complex_[sh].boundary_.begin() - , complex_[sh].boundary_.end() ); } + Boundary_simplex_range boundary_simplex_range(Simplex_handle sh) { + return Boundary_simplex_range(complex_[sh].boundary_.begin() + , complex_[sh].boundary_.end()); + } - void display_simplex(Simplex_handle sh) - { + void display_simplex(Simplex_handle sh) { std::cout << dimension(sh) << " "; - for(auto sh_b : boundary_simplex_range(sh)) std::cout << sh_b << " "; + for (auto sh_b : boundary_simplex_range(sh)) std::cout << sh_b << " "; std::cout << " " << filtration(sh) << " key=" << key(sh); } - void initialize_filtration() - { + void initialize_filtration() { Simplex_key key = 0; - for(auto & h_simp : complex_) { h_simp.key_ = key; ++key; } + for (auto & h_simp : complex_) { + h_simp.key_ = key; + ++key; + } } - std::vector< Hasse_simp > complex_; + std::vector< Hasse_simp > complex_; std::vector vertices_; - Filtration_value threshold_; - size_t num_vertices_; - int dim_max_; + Filtration_value threshold_; + size_t num_vertices_; + int dim_max_; }; template< typename T1, typename T2, typename T3 > -std::istream& operator>> ( std::istream & is - , Hasse_complex< T1, T2, T3 > & hcpx ) -{ +std::istream& operator>>(std::istream & is + , Hasse_complex< T1, T2, T3 > & hcpx) { assert(hcpx.num_simplices() == 0); size_t num_simp; is >> num_simp; - hcpx.complex_.reserve(num_simp); - - std::vector< typename Hasse_complex::Simplex_key > boundary; - typename Hasse_complex::Filtration_value fil; - typename Hasse_complex::Filtration_value max_fil = 0 ; - int max_dim = -1; - int key = 0 ; - while(read_hasse_simplex( is, boundary, fil )) //read all simplices in the file as a list of vertices + hcpx.complex_.reserve(num_simp); + + std::vector< typename Hasse_complex::Simplex_key > boundary; + typename Hasse_complex::Filtration_value fil; + typename Hasse_complex::Filtration_value max_fil = 0; + int max_dim = -1; + int key = 0; + while (read_hasse_simplex(is, boundary, fil)) //read all simplices in the file as a list of vertices { - //insert every simplex in the simplex tree - hcpx.complex_.push_back( Hasse_simplex< Hasse_complex >(key,fil,boundary)); + // insert every simplex in the simplex tree + hcpx.complex_.push_back(Hasse_simplex< Hasse_complex >(key, fil, boundary)); - if(max_dim < hcpx.dimension(key)) { max_dim = hcpx.dimension(key); } - if(hcpx.dimension(key) == 0) { hcpx.vertices_.push_back(key); } - if(max_fil < fil) { max_fil = fil; } + if (max_dim < hcpx.dimension(key)) { + max_dim = hcpx.dimension(key); + } + if (hcpx.dimension(key) == 0) { + hcpx.vertices_.push_back(key); + } + if (max_fil < fil) { + max_fil = fil; + } ++key; boundary.clear(); @@ -214,6 +239,6 @@ std::istream& operator>> ( std::istream & is return is; } -} // namespace GUDHI +} // namespace Gudhi -#endif // GUDHI_HASSE_DIAGRAM_H +#endif // HASSE_COMPLEX_H_ diff --git a/src/Simplex_tree/test/simplex_tree_unit_test.cpp b/src/Simplex_tree/test/simplex_tree_unit_test.cpp index 1539ad2b..fff00d77 100644 --- a/src/Simplex_tree/test/simplex_tree_unit_test.cpp +++ b/src/Simplex_tree/test/simplex_tree_unit_test.cpp @@ -108,6 +108,7 @@ BOOST_AUTO_TEST_CASE(simplex_tree_from_file) { // Size of simplex int size = 0; for (auto vertex : st.simplex_vertex_range(f_simplex)) { + // Remove warning (void) vertex; size++; } @@ -164,6 +165,8 @@ void set_and_test_simplex_tree_dim_fil(typeST& simplexTree, int vectorSize, cons // Another way to count simplices: size_t num_simp = 0; for (auto f_simplex : simplexTree.complex_simplex_range()) { + // Remove warning + (void) f_simplex; num_simp++; } diff --git a/src/Skeleton_blocker/test/TestSkeletonBlockerComplex.cpp b/src/Skeleton_blocker/test/TestSkeletonBlockerComplex.cpp index 3dc38572..319e3c43 100644 --- a/src/Skeleton_blocker/test/TestSkeletonBlockerComplex.cpp +++ b/src/Skeleton_blocker/test/TestSkeletonBlockerComplex.cpp @@ -343,7 +343,7 @@ bool test_iterator_simplices3(){ bool test_iterator_simplices4(){ Complex empty_complex; for(auto v : empty_complex.vertex_range()){ - v; + (void) v; } for(auto e : empty_complex.edge_range()){ empty_complex[e]; diff --git a/src/common/include/gudhi/Off_reader.h b/src/common/include/gudhi/Off_reader.h index b70e7897..81b9e634 100644 --- a/src/common/include/gudhi/Off_reader.h +++ b/src/common/include/gudhi/Off_reader.h @@ -166,7 +166,7 @@ class Off_reader { iss >> num_face_vertices; std::vector face; face.assign(std::istream_iterator(iss), std::istream_iterator()); - if (!face.size() == off_info_.num_vertices) return false; + if (face.size() != off_info_.dim) return false; visitor.maximal_face(face); } return true; -- cgit v1.2.3