From 053a5a2f77f4747d45bc781c90b44791d6131488 Mon Sep 17 00:00:00 2001 From: glisse Date: Wed, 30 Sep 2015 20:17:19 +0000 Subject: In is_before_in_filtration, access the filtration values directly without checking for null_simplex. git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@811 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: cff7635e067a691764ca250067997b8b48cb6420 --- src/Simplex_tree/include/gudhi/Simplex_tree.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/Simplex_tree') diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index 914247b5..96565ff1 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -908,8 +908,9 @@ class Simplex_tree { : st_(st) { } bool operator()(const Simplex_handle sh1, const Simplex_handle sh2) const { - if (st_->filtration(sh1) != st_->filtration(sh2)) { - return st_->filtration(sh1) < st_->filtration(sh2); + // Not using st_->filtration(sh1) because it uselessly tests for null_simplex. + if (sh1->second.filtration() != sh2->second.filtration()) { + return sh1->second.filtration() < sh2->second.filtration(); } // is sh1 a proper subface of sh2 return st_->reverse_lexicographic_order(sh1, sh2); -- cgit v1.2.3 From a19368075090f5409dc12081df944f90353eb5df Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 2 Oct 2015 16:00:28 +0000 Subject: Doxygen to be made from user version. Hypergenerator fix. Add definitions for debug traces. git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@821 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 5625aaab792264df86d7d442a2e6ff9886cf5d24 --- data/points/generator/CMakeLists.txt | 2 +- data/points/generator/hypergenerator.cpp | 9 ++- scripts/generate_version.sh | 20 +++---- src/Doxyfile | 8 +-- src/GudhUI/CMakeLists.txt | 17 ++++-- src/Persistent_cohomology/example/CMakeLists.txt | 7 ++- src/Simplex_tree/test/simplex_tree_unit_test.cpp | 74 ++++++++++++++++++++++-- 7 files changed, 108 insertions(+), 29 deletions(-) (limited to 'src/Simplex_tree') diff --git a/data/points/generator/CMakeLists.txt b/data/points/generator/CMakeLists.txt index 0f2674c4..0d045450 100644 --- a/data/points/generator/CMakeLists.txt +++ b/data/points/generator/CMakeLists.txt @@ -21,6 +21,6 @@ if(CGAL_FOUND) add_test(hypergenerator_in_cube_50000_2 ${CMAKE_CURRENT_BINARY_DIR}/hypergenerator in cube inCube.off 50000 3) endif() else() - message(WARNING "CGAL version: ${CGAL_VERSION} is too old to compile Alpha shapes feature. Version 4.6.0 is required.") + message(WARNING "CGAL version: ${CGAL_VERSION} is too old to compile hypergenerator. Version 4.6.0 is required.") endif () endif() diff --git a/data/points/generator/hypergenerator.cpp b/data/points/generator/hypergenerator.cpp index f4ea6b07..32ef450d 100644 --- a/data/points/generator/hypergenerator.cpp +++ b/data/points/generator/hypergenerator.cpp @@ -86,8 +86,13 @@ int main(int argc, char **argv) { } std::ofstream diagram_out(argv[3]); - diagram_out << "OFF" << std::endl; - diagram_out << points_number << " 0 0" << std::endl; + if (dimension == 3) { + diagram_out << "OFF" << std::endl; + diagram_out << points_number << " 0 0" << std::endl; + } else { + diagram_out << "nOFF" << std::endl; + diagram_out << dimension << " " << points_number << " 0 0" << std::endl; + } if (diagram_out.is_open()) { // Instanciate a random point generator diff --git a/scripts/generate_version.sh b/scripts/generate_version.sh index 4d28cf53..e7575282 100755 --- a/scripts/generate_version.sh +++ b/scripts/generate_version.sh @@ -2,6 +2,8 @@ #usage bash generate_version.sh : dont generate if svn st non empty #usage bash generate_version.sh -f : generate even if svn is empty #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 # VERSION CHECK ROOT_DIR=.. VERSION_FILE="$ROOT_DIR/Version.txt" @@ -48,11 +50,13 @@ cp $ROOT_DIR/COPYING $VERSION_DIR cp -R $ROOT_DIR/data $VERSION_DIR cp $ROOT_DIR/src/CMakeLists.txt $VERSION_DIR cp $ROOT_DIR/src/Doxyfile $VERSION_DIR +cp -R $ROOT_DIR/biblio $VERSION_DIR # PACKAGE LEVEL COPY PACKAGE_INC_DIR="/include" -PACKAGE_SRC_DIR="/source" +#PACKAGE_SRC_DIR="/source" PACKAGE_EX_DIR="/example" +PACKAGE_DOC_DIR="/doc" for package in `ls $ROOT_DIR/src/` do echo $package @@ -77,20 +81,16 @@ do fi cp -R $ROOT_DIR/src/$package$PACKAGE_INC_DIR/* $VERSION_DIR$PACKAGE_INC_DIR/ fi - if [ -d "$ROOT_DIR/src/$package$PACKAGE_SRC_DIR" ] - then - if [ ! -d "$VERSION_DIR$PACKAGE_SRC_DIR" ] - then - # MUST CREATE DIRECTORY ON FIRST LOOP - mkdir $VERSION_DIR$PACKAGE_INC_DIR - fi - cp -R $ROOT_DIR/src/$package$PACKAGE_SRC_DIR/* $VERSION_DIR$PACKAGE_SRC_DIR/ - fi if [ -d "$ROOT_DIR/src/$package$PACKAGE_EX_DIR" ] then mkdir -p $VERSION_DIR$PACKAGE_EX_DIR/$package cp -R $ROOT_DIR/src/$package$PACKAGE_EX_DIR/* $VERSION_DIR$PACKAGE_EX_DIR/$package fi + if [ -d "$ROOT_DIR/src/$package$PACKAGE_DOC_DIR" ] + then + mkdir -p $VERSION_DIR$PACKAGE_DOC_DIR/$package + cp -R $ROOT_DIR/src/$package$PACKAGE_DOC_DIR/* $VERSION_DIR$PACKAGE_DOC_DIR/$package + fi fi fi done diff --git a/src/Doxyfile b/src/Doxyfile index 62412627..85c496a8 100644 --- a/src/Doxyfile +++ b/src/Doxyfile @@ -672,7 +672,7 @@ LAYOUT_FILE = # search path. Do not use file names with spaces, bibtex cannot handle them. See # also \cite for info how to create references. -CITE_BIB_FILES = ../biblio/bibliography.bib +CITE_BIB_FILES = biblio/bibliography.bib #--------------------------------------------------------------------------- # Configuration options related to warning and progress messages @@ -831,9 +831,9 @@ EXAMPLE_RECURSIVE = NO # that contain images that are to be included in the documentation (see the # \image command). -IMAGE_PATH = Skeleton_blocker/doc/ \ - common/doc/ \ - Contraction/doc/ +IMAGE_PATH = doc/Skeleton_blocker/ \ + doc/common/ \ + doc/Contraction/ # The INPUT_FILTER tag can be used to specify a program that doxygen should diff --git a/src/GudhUI/CMakeLists.txt b/src/GudhUI/CMakeLists.txt index 9348868a..e896f42c 100644 --- a/src/GudhUI/CMakeLists.txt +++ b/src/GudhUI/CMakeLists.txt @@ -6,10 +6,6 @@ find_package(Qt4) find_package(QGLViewer) find_package(OpenGL) -message("CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}") -message("CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG}") -message("CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE}") - if ( CGAL_FOUND AND QT4_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND ) set( QT_USE_QTXML TRUE ) set( QT_USE_QTMAIN TRUE ) @@ -23,6 +19,19 @@ if ( CGAL_FOUND AND QT4_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND ) include(${QT_USE_FILE}) include(${CGAL_USE_FILE}) + +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() + +message("CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}") +message("CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG}") +message("CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE}") include_directories (${QGLVIEWER_INCLUDE_DIR}) include_directories(.) diff --git a/src/Persistent_cohomology/example/CMakeLists.txt b/src/Persistent_cohomology/example/CMakeLists.txt index 9487cce6..3276989d 100644 --- a/src/Persistent_cohomology/example/CMakeLists.txt +++ b/src/Persistent_cohomology/example/CMakeLists.txt @@ -28,8 +28,11 @@ if (NOT MSVC) target_link_libraries(performance_rips_persistence ${Boost_SYSTEM_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY} ${GMPXX_LIBRARIES} ${GMP_LIBRARIES}) if(CGAL_FOUND) - # uncomment to display debug traces - # add_definitions(-DDEBUG_TRACES) + if (CMAKE_BUILD_TYPE MATCHES Debug) + # For programs to be more verbose + add_definitions(-DDEBUG_TRACES) + endif() + add_executable(alpha_shapes_persistence alpha_shapes_persistence.cpp) target_link_libraries(alpha_shapes_persistence ${Boost_SYSTEM_LIBRARY} ${GMPXX_LIBRARIES} ${GMP_LIBRARIES} ${CGAL_LIBRARY}) add_test(alpha_shapes_persistence_2_0_5 ${CMAKE_CURRENT_BINARY_DIR}/alpha_shapes_persistence ${CMAKE_SOURCE_DIR}/data/points/bunny_5000 2 0.5) diff --git a/src/Simplex_tree/test/simplex_tree_unit_test.cpp b/src/Simplex_tree/test/simplex_tree_unit_test.cpp index 5733dda1..1539ad2b 100644 --- a/src/Simplex_tree/test/simplex_tree_unit_test.cpp +++ b/src/Simplex_tree/test/simplex_tree_unit_test.cpp @@ -359,59 +359,121 @@ 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) { std::cout << "********************************************************************" << std::endl; std::cout << "TEST OF RECURSIVE INSERTION" << std::endl; typeST st; + typePairSimplexBool returnValue; + int position = 0; // ++ FIRST std::cout << " - INSERT (2,1,0)" << std::endl; typeVectorVertex SimplexVector1{2, 1, 0}; BOOST_CHECK(SimplexVector1.size() == 3); - st.insert_simplex_and_subfaces(SimplexVector1); + returnValue = st.insert_simplex_and_subfaces(SimplexVector1); BOOST_CHECK(st.num_vertices() == (size_t) 3); // +3 (2, 1 and 0 are not existing) + // Check it is well inserted + BOOST_CHECK(true == returnValue.second); + position = 0; + std::sort(SimplexVector1.begin(), SimplexVector1.end(), sort_in_decr_order); + for (auto vertex : st.simplex_vertex_range(returnValue.first)) { + // Check returned Simplex_handle + std::cout << "vertex = " << vertex << " | vector[" << position << "] = " << SimplexVector1[position] << std::endl; + BOOST_CHECK(vertex == SimplexVector1[position]); + position++; + } + // ++ SECOND std::cout << " - INSERT 3" << std::endl; typeVectorVertex SimplexVector2{3}; BOOST_CHECK(SimplexVector2.size() == 1); - st.insert_simplex_and_subfaces(SimplexVector2); + returnValue = st.insert_simplex_and_subfaces(SimplexVector2); BOOST_CHECK(st.num_vertices() == (size_t) 4); // +1 (3 is not existing) + // Check it is well inserted + BOOST_CHECK(true == returnValue.second); + position = 0; + std::sort(SimplexVector2.begin(), SimplexVector2.end(), sort_in_decr_order); + for (auto vertex : st.simplex_vertex_range(returnValue.first)) { + // Check returned Simplex_handle + std::cout << "vertex = " << vertex << " | vector[" << position << "] = " << SimplexVector2[position] << std::endl; + BOOST_CHECK(vertex == SimplexVector2[position]); + position++; + } + // ++ THIRD std::cout << " - INSERT (0,3)" << std::endl; typeVectorVertex SimplexVector3{3, 0}; BOOST_CHECK(SimplexVector3.size() == 2); - st.insert_simplex_and_subfaces(SimplexVector3); + returnValue = st.insert_simplex_and_subfaces(SimplexVector3); BOOST_CHECK(st.num_vertices() == (size_t) 4); // Not incremented (all are existing) + // Check it is well inserted + BOOST_CHECK(true == returnValue.second); + position = 0; + std::sort(SimplexVector3.begin(), SimplexVector3.end(), sort_in_decr_order); + for (auto vertex : st.simplex_vertex_range(returnValue.first)) { + // Check returned Simplex_handle + std::cout << "vertex = " << vertex << " | vector[" << position << "] = " << SimplexVector3[position] << std::endl; + BOOST_CHECK(vertex == SimplexVector3[position]); + position++; + } + // ++ FOURTH std::cout << " - INSERT (1,0) (already inserted)" << std::endl; typeVectorVertex SimplexVector4{1, 0}; BOOST_CHECK(SimplexVector4.size() == 2); - st.insert_simplex_and_subfaces(SimplexVector4); + returnValue = st.insert_simplex_and_subfaces(SimplexVector4); BOOST_CHECK(st.num_vertices() == (size_t) 4); // Not incremented (all are existing) + // Check it was not inserted (already there from {2,1,0} insertion) + BOOST_CHECK(false == returnValue.second); + // ++ FIFTH std::cout << " - INSERT (3,4,5)" << std::endl; typeVectorVertex SimplexVector5{3, 4, 5}; BOOST_CHECK(SimplexVector5.size() == 3); - st.insert_simplex_and_subfaces(SimplexVector5); + returnValue = st.insert_simplex_and_subfaces(SimplexVector5); BOOST_CHECK(st.num_vertices() == (size_t) 6); + // Check it is well inserted + BOOST_CHECK(true == returnValue.second); + position = 0; + std::sort(SimplexVector5.begin(), SimplexVector5.end(), sort_in_decr_order); + for (auto vertex : st.simplex_vertex_range(returnValue.first)) { + // Check returned Simplex_handle + std::cout << "vertex = " << vertex << " | vector[" << position << "] = " << SimplexVector5[position] << std::endl; + BOOST_CHECK(vertex == SimplexVector5[position]); + position++; + } + // ++ SIXTH std::cout << " - INSERT (0,1,6,7)" << std::endl; typeVectorVertex SimplexVector6{0, 1, 6, 7}; BOOST_CHECK(SimplexVector6.size() == 4); - st.insert_simplex_and_subfaces(SimplexVector6); + returnValue = st.insert_simplex_and_subfaces(SimplexVector6); BOOST_CHECK(st.num_vertices() == (size_t) 8); // +2 (6 and 7 are not existing - 0 and 1 are already existing) + // Check it is well inserted + BOOST_CHECK(true == returnValue.second); + position = 0; + std::sort(SimplexVector6.begin(), SimplexVector6.end(), sort_in_decr_order); + for (auto vertex : st.simplex_vertex_range(returnValue.first)) { + // Check returned Simplex_handle + std::cout << "vertex = " << vertex << " | vector[" << position << "] = " << SimplexVector6[position] << std::endl; + BOOST_CHECK(vertex == SimplexVector6[position]); + position++; + } + /* Inserted simplex: */ /* 1 6 */ /* o---o */ -- cgit v1.2.3 From e6962acc2045831e8b2f1b0b4f10717b4c89971c Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Mon, 5 Oct 2015 09:04:17 +0000 Subject: cpplint fixes git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@822 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 1cab7ed83b02fd90ab57550ad5363dc36f8b8d05 --- src/Simplex_tree/example/mini_simplex_tree.cpp | 11 +- src/Simplex_tree/example/simple_simplex_tree.cpp | 27 +- .../example/simplex_tree_from_alpha_shapes_3.cpp | 440 ++++++++++----------- .../example/simplex_tree_from_file.cpp | 108 ++--- .../gudhi/Simplex_tree/Simplex_tree_iterators.h | 6 +- .../Simplex_tree_node_explicit_storage.h | 8 +- .../gudhi/Simplex_tree/Simplex_tree_siblings.h | 14 +- .../include/gudhi/Simplex_tree/indexing_tag.h | 6 +- src/common/include/gudhi/Clock.h | 151 ++++--- src/common/include/gudhi/Off_reader.h | 289 +++++++------- src/common/include/gudhi/Point.h | 286 +++++++------- src/common/include/gudhi/Simple_object_pool.h | 57 ++- src/common/include/gudhi/Test.h | 156 ++++---- src/common/include/gudhi/Utils.h | 74 ++-- src/common/include/gudhi/distance_functions.h | 64 +-- .../include/gudhi/graph_simplicial_complex.h | 121 +++--- src/common/include/gudhi/reader_utils.h | 179 +++++---- 17 files changed, 1015 insertions(+), 982 deletions(-) (limited to 'src/Simplex_tree') diff --git a/src/Simplex_tree/example/mini_simplex_tree.cpp b/src/Simplex_tree/example/mini_simplex_tree.cpp index 08d626d3..7e48aaaf 100644 --- a/src/Simplex_tree/example/mini_simplex_tree.cpp +++ b/src/Simplex_tree/example/mini_simplex_tree.cpp @@ -58,11 +58,12 @@ int main() { auto edge02 = {0, 2}; ST::Simplex_handle e = st.find(edge02); - assert(st.filtration(e) == 0); // We are not using filtrations so everything has value 0 - for(ST::Simplex_handle t : st.cofaces_simplex_range(e, 1)) // Only coface is 012 - { - for(ST::Vertex_handle v : st.simplex_vertex_range(t)) // v in { 0, 1, 2 } + // We are not using filtrations so everything has value 0 + assert(st.filtration(e) == 0); + for (ST::Simplex_handle t : st.cofaces_simplex_range(e, 1)) { + // Only coface is 012 + for (ST::Vertex_handle v : st.simplex_vertex_range(t)) // v in { 0, 1, 2 } std::cout << v; std::cout << '\n'; - } + } } diff --git a/src/Simplex_tree/example/simple_simplex_tree.cpp b/src/Simplex_tree/example/simple_simplex_tree.cpp index a2e1f0e9..5146b906 100644 --- a/src/Simplex_tree/example/simple_simplex_tree.cpp +++ b/src/Simplex_tree/example/simple_simplex_tree.cpp @@ -20,9 +20,12 @@ * along with this program. If not, see . */ +#include +#include + #include -#include "gudhi/graph_simplicial_complex.h" -#include "gudhi/Simplex_tree.h" +#include // for pair +#include using namespace Gudhi; @@ -38,7 +41,7 @@ int main(int argc, char * const argv[]) { // TEST OF INSERTION std::cout << "********************************************************************" << std::endl; std::cout << "EXAMPLE OF SIMPLE INSERTION" << std::endl; - //Construct the Simplex Tree + // Construct the Simplex Tree Simplex_tree<> simplexTree; /* Simplex to be inserted: */ @@ -159,8 +162,8 @@ int main(int argc, char * const argv[]) { // ++ TENTH std::cout << " * INSERT 0 (already inserted)" << std::endl; typeVectorVertex tenthSimplexVector = { 0 }; - returnValue = - simplexTree.insert_simplex(tenthSimplexVector, Filtration_value(FOURTH_FILTRATION_VALUE)); // With a different filtration value + // With a different filtration value + returnValue = simplexTree.insert_simplex(tenthSimplexVector, Filtration_value(FOURTH_FILTRATION_VALUE)); if (returnValue.second == true) { std::cout << " + 0 INSERTED" << std::endl; @@ -181,18 +184,18 @@ int main(int argc, char * const argv[]) { } // ++ GENERAL VARIABLE SET - simplexTree.set_filtration(FOURTH_FILTRATION_VALUE); // Max filtration value - simplexTree.set_dimension(2); // Max dimension = 2 -> (2,1,0) + simplexTree.set_filtration(FOURTH_FILTRATION_VALUE); // Max filtration value + simplexTree.set_dimension(2); // Max dimension = 2 -> (2,1,0) - std::cout << "********************************************************************" << std::endl; + std::cout << "********************************************************************\n"; // Display the Simplex_tree - Can not be done in the middle of 2 inserts - std::cout << "* The complex contains " << simplexTree.num_simplices() << " simplices" << std::endl; - std::cout << " - dimension " << simplexTree.dimension() << " - filtration " << simplexTree.filtration() << std::endl; - std::cout << "* Iterator on Simplices in the filtration, with [filtration value]:" << std::endl; + std::cout << "* The complex contains " << simplexTree.num_simplices() << " simplices\n"; + std::cout << " - dimension " << simplexTree.dimension() << " - filtration " << simplexTree.filtration() << "\n"; + std::cout << "* Iterator on Simplices in the filtration, with [filtration value]:\n"; for (auto f_simplex : simplexTree.filtration_simplex_range()) { std::cout << " " << "[" << simplexTree.filtration(f_simplex) << "] "; for (auto vertex : simplexTree.simplex_vertex_range(f_simplex)) { - std::cout << (int) vertex << " "; + std::cout << static_cast(vertex) << " "; } std::cout << std::endl; } 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 5f797e93..45efe3ed 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 @@ -1,24 +1,28 @@ - /* 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 . - */ +/* 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 #include #include @@ -27,32 +31,34 @@ #include #include - -#include "gudhi/graph_simplicial_complex.h" -#include "gudhi/Simplex_tree.h" -#include +#include +#include // for tuple<> +#include +#include // for pair<> +#include +#include // Alpha_shape_3 templates type definitions typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; -typedef CGAL::Alpha_shape_vertex_base_3 Vb; -typedef CGAL::Alpha_shape_cell_base_3 Fb; -typedef CGAL::Triangulation_data_structure_3 Tds; -typedef CGAL::Delaunay_triangulation_3 Triangulation_3; -typedef CGAL::Alpha_shape_3 Alpha_shape_3; +typedef CGAL::Alpha_shape_vertex_base_3 Vb; +typedef CGAL::Alpha_shape_cell_base_3 Fb; +typedef CGAL::Triangulation_data_structure_3 Tds; +typedef CGAL::Delaunay_triangulation_3 Triangulation_3; +typedef CGAL::Alpha_shape_3 Alpha_shape_3; // From file type definition -typedef Kernel::Point_3 Point; +typedef Kernel::Point_3 Point; // filtration with alpha values needed type definition typedef Alpha_shape_3::FT Alpha_value_type; -typedef CGAL::Object Object; +typedef CGAL::Object Object; typedef CGAL::Dispatch_output_iterator< - CGAL::cpp11::tuple, - CGAL::cpp11::tuple >, std::back_insert_iterator< std::vector > - > > Dispatch; -typedef Alpha_shape_3::Cell_handle Cell_handle; -typedef Alpha_shape_3::Facet Facet; -typedef Alpha_shape_3::Edge Edge; +CGAL::cpp11::tuple, +CGAL::cpp11::tuple >, + std::back_insert_iterator< std::vector > > > Dispatch; +typedef Alpha_shape_3::Cell_handle Cell_handle; +typedef Alpha_shape_3::Facet Facet; +typedef Alpha_shape_3::Edge Edge; typedef std::list Vertex_list; // gudhi type definition @@ -61,225 +67,209 @@ typedef std::map Alpha_shape typedef std::pair Alpha_shape_simplex_tree_pair; typedef std::vector< Simplex_tree_vertex > Simplex_tree_vector_vertex; -//#define DEBUG_TRACES - -Vertex_list from (const Cell_handle& ch) -{ - Vertex_list the_list; - for (auto i = 0; i < 4; i++) - { +Vertex_list from(const Cell_handle& ch) { + Vertex_list the_list; + for (auto i = 0; i < 4; i++) { #ifdef DEBUG_TRACES - std::cout << "from cell[" << i << "]=" << ch->vertex(i)->point() << std::endl; -#endif // DEBUG_TRACES - the_list.push_back(ch->vertex(i)); - } - return the_list; + std::cout << "from cell[" << i << "]=" << ch->vertex(i)->point() << std::endl; +#endif // DEBUG_TRACES + the_list.push_back(ch->vertex(i)); + } + return the_list; } -Vertex_list from (const Facet& fct) -{ - Vertex_list the_list; - for (auto i = 0; i < 4; i++) - { - if (fct.second != i) - { + +Vertex_list from(const Facet& fct) { + Vertex_list the_list; + for (auto i = 0; i < 4; i++) { + if (fct.second != i) { #ifdef DEBUG_TRACES - std::cout << "from facet=[" << i << "]" << fct.first->vertex(i)->point() << std::endl; -#endif // DEBUG_TRACES - the_list.push_back(fct.first->vertex(i)); - } - } - return the_list; + std::cout << "from facet=[" << i << "]" << fct.first->vertex(i)->point() << std::endl; +#endif // DEBUG_TRACES + the_list.push_back(fct.first->vertex(i)); + } + } + return the_list; } -Vertex_list from (const Edge& edg) -{ - Vertex_list the_list; - for (auto i = 0; i < 4; i++) - { - if ((edg.second == i) ||(edg.third == i)) - { + +Vertex_list from(const Edge& edg) { + Vertex_list the_list; + for (auto i = 0; i < 4; i++) { + if ((edg.second == i) || (edg.third == i)) { #ifdef DEBUG_TRACES - std::cout << "from edge[" << i << "]=" << edg.first->vertex(i)->point() << std::endl; -#endif // DEBUG_TRACES - the_list.push_back(edg.first->vertex(i)); - } - } - return the_list; + std::cout << "from edge[" << i << "]=" << edg.first->vertex(i)->point() << std::endl; +#endif // DEBUG_TRACES + the_list.push_back(edg.first->vertex(i)); + } + } + return the_list; } -Vertex_list from (const Alpha_shape_3::Vertex_handle& vh) -{ - Vertex_list the_list; + +Vertex_list from(const Alpha_shape_3::Vertex_handle& vh) { + Vertex_list the_list; #ifdef DEBUG_TRACES - std::cout << "from vertex=" << vh->point() << std::endl; -#endif // DEBUG_TRACES - the_list.push_back(vh); - return the_list; + std::cout << "from vertex=" << vh->point() << std::endl; +#endif // DEBUG_TRACES + the_list.push_back(vh); + return the_list; } +int main(int argc, char * const argv[]) { + // program args management + if (argc != 2) { + std::cerr << "Usage: " << argv[0] + << " path_to_file_graph \n"; + return 0; + } -int main (int argc, char * const argv[]) -{ - // program args management - if (argc != 2) { - std::cerr << "Usage: " << argv[0] - << " path_to_file_graph \n"; - return 0; // ----- >> - } - - // Read points from file - std::string filegraph = argv[1]; - std::list lp; - std::ifstream is(filegraph.c_str()); - int n; - is >> n; + // Read points from file + std::string filegraph = argv[1]; + std::list lp; + std::ifstream is(filegraph.c_str()); + int n; + is >> n; #ifdef DEBUG_TRACES - std::cout << "Reading " << n << " points " << std::endl; -#endif // DEBUG_TRACES - Point p; - for( ; n>0 ; n--) { - is >> p; - lp.push_back(p); - } + std::cout << "Reading " << n << " points " << std::endl; +#endif // DEBUG_TRACES + Point p; + for (; n > 0; n--) { + is >> p; + lp.push_back(p); + } - // alpha shape construction from points. CGAL has a strange behavior in REGULARIZED mode. - Alpha_shape_3 as(lp.begin(),lp.end(),0,Alpha_shape_3::GENERAL); + // alpha shape construction from points. CGAL has a strange behavior in REGULARIZED mode. + Alpha_shape_3 as(lp.begin(), lp.end(), 0, Alpha_shape_3::GENERAL); #ifdef DEBUG_TRACES - std::cout << "Alpha shape computed in GENERAL mode" << std::endl; -#endif // DEBUG_TRACES + std::cout << "Alpha shape computed in GENERAL mode" << std::endl; +#endif // DEBUG_TRACES - // filtration with alpha values from alpha shape - std::vector the_objects; - std::vector the_alpha_values; + // filtration with alpha values from alpha shape + std::vector the_objects; + std::vector the_alpha_values; - Dispatch disp = CGAL::dispatch_output( std::back_inserter(the_objects), std::back_inserter(the_alpha_values)); + Dispatch disp = CGAL::dispatch_output(std::back_inserter(the_objects), + std::back_inserter(the_alpha_values)); - as.filtration_with_alpha_values(disp); + as.filtration_with_alpha_values(disp); #ifdef DEBUG_TRACES - std::cout << "filtration_with_alpha_values returns : " << the_objects.size() << " objects" << std::endl; -#endif // DEBUG_TRACES + std::cout << "filtration_with_alpha_values returns : " << the_objects.size() << " objects" << std::endl; +#endif // DEBUG_TRACES - Alpha_shape_3::size_type count_vertices = 0; - Alpha_shape_3::size_type count_edges = 0; - Alpha_shape_3::size_type count_facets = 0; - Alpha_shape_3::size_type count_cells = 0; + Alpha_shape_3::size_type count_vertices = 0; + Alpha_shape_3::size_type count_edges = 0; + Alpha_shape_3::size_type count_facets = 0; + Alpha_shape_3::size_type count_cells = 0; - // Loop on objects vector - Vertex_list vertex_list; - Gudhi::Simplex_tree<> simplex_tree; - Alpha_shape_simplex_tree_map map_cgal_simplex_tree; - std::vector::iterator the_alpha_value_iterator = the_alpha_values.begin(); - for(auto object_iterator: the_objects) - { - // Retrieve Alpha shape vertex list from object - if (const Cell_handle* cell = CGAL::object_cast(&object_iterator)) - { - vertex_list = from(*cell); - count_cells++; - } - else if (const Facet* facet = CGAL::object_cast(&object_iterator)) - { - vertex_list = from(*facet); - count_facets++; - } - else if (const Edge* edge = CGAL::object_cast(&object_iterator)) - { - vertex_list = from(*edge); - count_edges++; - } - else if (const Alpha_shape_3::Vertex_handle* vertex = CGAL::object_cast(&object_iterator)) - { - count_vertices++; - vertex_list = from(*vertex); - } - // Construction of the vector of simplex_tree vertex from list of alpha_shapes vertex - Simplex_tree_vector_vertex the_simplex_tree; - for (auto the_alpha_shape_vertex:vertex_list) - { - Alpha_shape_simplex_tree_map::iterator the_map_iterator = map_cgal_simplex_tree.find(the_alpha_shape_vertex); - if (the_map_iterator == map_cgal_simplex_tree.end()) - { - // alpha shape not found - Simplex_tree_vertex vertex = map_cgal_simplex_tree.size(); + // Loop on objects vector + Vertex_list vertex_list; + Gudhi::Simplex_tree<> simplex_tree; + Alpha_shape_simplex_tree_map map_cgal_simplex_tree; + std::vector::iterator the_alpha_value_iterator = the_alpha_values.begin(); + for (auto object_iterator : the_objects) { + // Retrieve Alpha shape vertex list from object + if (const Cell_handle * cell = CGAL::object_cast(&object_iterator)) { + vertex_list = from(*cell); + count_cells++; + } else if (const Facet * facet = CGAL::object_cast(&object_iterator)) { + vertex_list = from(*facet); + count_facets++; + } else if (const Edge * edge = CGAL::object_cast(&object_iterator)) { + vertex_list = from(*edge); + count_edges++; + } else if (const Alpha_shape_3::Vertex_handle * vertex = + CGAL::object_cast(&object_iterator)) { + count_vertices++; + vertex_list = from(*vertex); + } + // Construction of the vector of simplex_tree vertex from list of alpha_shapes vertex + Simplex_tree_vector_vertex the_simplex_tree; + for (auto the_alpha_shape_vertex : vertex_list) { + Alpha_shape_simplex_tree_map::iterator the_map_iterator = map_cgal_simplex_tree.find(the_alpha_shape_vertex); + if (the_map_iterator == map_cgal_simplex_tree.end()) { + // alpha shape not found + Simplex_tree_vertex vertex = map_cgal_simplex_tree.size(); #ifdef DEBUG_TRACES - std::cout << "vertex [" << the_alpha_shape_vertex->point() << "] not found - insert_simplex " << vertex << std::endl; -#endif // DEBUG_TRACES - the_simplex_tree.push_back(vertex); - map_cgal_simplex_tree.insert(Alpha_shape_simplex_tree_pair(the_alpha_shape_vertex,vertex)); - } else - { - // alpha shape found - Simplex_tree_vertex vertex = the_map_iterator->second; + std::cout << "vertex [" << the_alpha_shape_vertex->point() << "] not found - insert_simplex " << vertex << "\n"; +#endif // DEBUG_TRACES + the_simplex_tree.push_back(vertex); + map_cgal_simplex_tree.insert(Alpha_shape_simplex_tree_pair(the_alpha_shape_vertex, vertex)); + } else { + // alpha shape found + Simplex_tree_vertex vertex = the_map_iterator->second; #ifdef DEBUG_TRACES - std::cout << "vertex [" << the_alpha_shape_vertex->point() << "] found in " << vertex << std::endl; -#endif // DEBUG_TRACES - the_simplex_tree.push_back(vertex); - } - } - // Construction of the simplex_tree + std::cout << "vertex [" << the_alpha_shape_vertex->point() << "] found in " << vertex << std::endl; +#endif // DEBUG_TRACES + the_simplex_tree.push_back(vertex); + } + } + // Construction of the simplex_tree #ifdef DEBUG_TRACES - std::cout << "filtration = " << *the_alpha_value_iterator << std::endl; -#endif // DEBUG_TRACES - simplex_tree.insert_simplex(the_simplex_tree, std::sqrt(*the_alpha_value_iterator)); - if (the_alpha_value_iterator != the_alpha_values.end()) - ++the_alpha_value_iterator; - else - std::cout << "This shall not happen" << std::endl; - } + std::cout << "filtration = " << *the_alpha_value_iterator << std::endl; +#endif // DEBUG_TRACES + simplex_tree.insert_simplex(the_simplex_tree, std::sqrt(*the_alpha_value_iterator)); + if (the_alpha_value_iterator != the_alpha_values.end()) + ++the_alpha_value_iterator; + else + std::cerr << "This shall not happen" << std::endl; + } #ifdef DEBUG_TRACES - std::cout << "vertices \t\t" << count_vertices << std::endl; - std::cout << "edges \t\t" << count_edges << std::endl; - std::cout << "facets \t\t" << count_facets << std::endl; - std::cout << "cells \t\t" << count_cells << std::endl; + std::cout << "vertices \t\t" << count_vertices << std::endl; + std::cout << "edges \t\t" << count_edges << std::endl; + std::cout << "facets \t\t" << count_facets << std::endl; + std::cout << "cells \t\t" << count_cells << std::endl; - std::cout << "Information of the Simplex Tree: " << std::endl; - std::cout << " Number of vertices = " << simplex_tree.num_vertices() << " "; - std::cout << " Number of simplices = " << simplex_tree.num_simplices() << std::endl << std::endl; -#endif // DEBUG_TRACES + std::cout << "Information of the Simplex Tree:\n"; + std::cout << " Number of vertices = " << simplex_tree.num_vertices() << " "; + std::cout << " Number of simplices = " << simplex_tree.num_simplices() << std::endl << std::endl; +#endif // DEBUG_TRACES #ifdef DEBUG_TRACES - std::cout << "Iterator on vertices: " << std::endl; - for( auto vertex : simplex_tree.complex_vertex_range() ) - { std::cout << vertex << " "; } -#endif // DEBUG_TRACES + std::cout << "Iterator on vertices: \n"; + for (auto vertex : simplex_tree.complex_vertex_range()) { + std::cout << vertex << " "; + } +#endif // DEBUG_TRACES - std::cout << simplex_tree << std::endl; + std::cout << simplex_tree << std::endl; #ifdef DEBUG_TRACES - std::cout << std::endl << std::endl << "Iterator on simplices: " << std::endl; - for( auto simplex : simplex_tree.complex_simplex_range() ) - { - std::cout << " "; - for( auto vertex : simplex_tree.simplex_vertex_range(simplex) ) { std::cout << vertex << " "; } - std::cout << std::endl; - } -#endif // DEBUG_TRACES + std::cout << std::endl << std::endl << "Iterator on simplices:\n"; + for (auto simplex : simplex_tree.complex_simplex_range()) { + std::cout << " "; + for (auto vertex : simplex_tree.simplex_vertex_range(simplex)) { + std::cout << vertex << " "; + } + std::cout << std::endl; + } +#endif // DEBUG_TRACES #ifdef DEBUG_TRACES - std::cout << std::endl << std::endl << "Iterator on Simplices in the filtration, with [filtration value]:" << std::endl; - for( auto f_simplex : simplex_tree.filtration_simplex_range() ) - { std::cout << " " << "[" << simplex_tree.filtration(f_simplex) << "] "; - for( auto vertex : simplex_tree.simplex_vertex_range(f_simplex) ) - { std::cout << vertex << " "; } - std::cout << std::endl; - } -#endif // DEBUG_TRACES + std::cout << std::endl << std::endl << "Iterator on Simplices in the filtration, with [filtration value]:\n"; + for (auto f_simplex : simplex_tree.filtration_simplex_range()) { + std::cout << " " << "[" << simplex_tree.filtration(f_simplex) << "] "; + for (auto vertex : simplex_tree.simplex_vertex_range(f_simplex)) { + std::cout << vertex << " "; + } + std::cout << std::endl; + } +#endif // DEBUG_TRACES #ifdef DEBUG_TRACES - std::cout << std::endl << std::endl << "Iterator on Simplices in the filtration, and their boundary simplices:" << std::endl; - for( auto f_simplex : simplex_tree.filtration_simplex_range() ) - { - std::cout << " " << "[" << simplex_tree.filtration(f_simplex) << "] "; - for( auto vertex : simplex_tree.simplex_vertex_range(f_simplex) ) - { std::cout << vertex << " "; } - std::cout << std::endl; + std::cout << std::endl << std::endl << "Iterator on Simplices in the filtration, and their boundary simplices:\n"; + for (auto f_simplex : simplex_tree.filtration_simplex_range()) { + std::cout << " " << "[" << simplex_tree.filtration(f_simplex) << "] "; + for (auto vertex : simplex_tree.simplex_vertex_range(f_simplex)) { + std::cout << vertex << " "; + } + std::cout << std::endl; - for( auto b_simplex : simplex_tree.boundary_simplex_range(f_simplex) ) - { - std::cout << " " << "[" << simplex_tree.filtration(b_simplex) << "] "; - for( auto vertex : simplex_tree.simplex_vertex_range(b_simplex) ) - { std::cout << vertex << " "; } - std::cout << std::endl; - } - } -#endif // DEBUG_TRACES + for (auto b_simplex : simplex_tree.boundary_simplex_range(f_simplex)) { + std::cout << " " << "[" << simplex_tree.filtration(b_simplex) << "] "; + for (auto vertex : simplex_tree.simplex_vertex_range(b_simplex)) { + std::cout << vertex << " "; + } + std::cout << std::endl; + } + } +#endif // DEBUG_TRACES - return 0; + return 0; } diff --git a/src/Simplex_tree/example/simplex_tree_from_file.cpp b/src/Simplex_tree/example/simplex_tree_from_file.cpp index 20e8f067..58085014 100644 --- a/src/Simplex_tree/example/simplex_tree_from_file.cpp +++ b/src/Simplex_tree/example/simplex_tree_from_file.cpp @@ -1,59 +1,62 @@ - /* 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 . - */ +/* 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 . + */ + +#include +#include #include #include -#include "gudhi/reader_utils.h" -#include "gudhi/Simplex_tree.h" +#include using namespace Gudhi; -int main (int argc, char * const argv[]) -{ +int main(int argc, char * const argv[]) { if (argc != 3) { std::cerr << "Usage: " << argv[0] - << " path_to_file_graph max_dim \n"; + << " path_to_file_graph max_dim \n"; return 0; } - std::string filegraph = argv[1]; - int max_dim = atoi(argv[2]); + std::string filegraph = argv[1]; + int max_dim = atoi(argv[2]); clock_t start, end; - //Construct the Simplex Tree + // Construct the Simplex Tree Simplex_tree<> st; start = clock(); auto g = read_graph(filegraph); - st.insert_graph (g); //insert the graph in the simplex tree as 1-skeleton + // insert the graph in the simplex tree as 1-skeleton + st.insert_graph(g); end = clock(); std::cout << "Insert the 1-skeleton in the simplex tree in " - << (double)(end-start)/CLOCKS_PER_SEC << " s. \n"; + << static_cast(end - start) / CLOCKS_PER_SEC << " s. \n"; start = clock(); - st.expansion ( max_dim ); //expand the 1-skeleton until dimension max_dim + // expand the 1-skeleton until dimension max_dim + st.expansion(max_dim); end = clock(); std::cout << "max_dim = " << max_dim << "\n"; std::cout << "Expand the simplex tree in " - << (double)(end-start)/CLOCKS_PER_SEC << " s. \n"; + << static_cast(end - start) / CLOCKS_PER_SEC << " s. \n"; std::cout << "Information of the Simplex Tree: " << std::endl; std::cout << " Number of vertices = " << st.num_vertices() << " "; @@ -61,43 +64,50 @@ int main (int argc, char * const argv[]) std::cout << std::endl << std::endl; std::cout << "Iterator on vertices: "; - for( auto vertex : st.complex_vertex_range() ) { std::cout << vertex << " "; } + for (auto vertex : st.complex_vertex_range()) { + std::cout << vertex << " "; + } std::cout << std::endl; std::cout << std::endl << std::endl; std::cout << "Iterator on simplices: " << std::endl; - for( auto simplex : st.complex_simplex_range() ) - { + for (auto simplex : st.complex_simplex_range()) { std::cout << " "; - for( auto vertex : st.simplex_vertex_range(simplex) ) { std::cout << vertex << " "; } + for (auto vertex : st.simplex_vertex_range(simplex)) { + std::cout << vertex << " "; + } std::cout << std::endl; } std::cout << std::endl << std::endl; std::cout << "Iterator on Simplices in the filtration, with [filtration value]:" << 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 << vertex << " "; } 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 << vertex << " "; + } + std::cout << std::endl; } std::cout << std::endl << std::endl; std::cout << "Iterator on Simplices in the filtration, and their boundary simplices:" << std::endl; - for( auto f_simplex : st.filtration_simplex_range() ) - { + 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 << vertex << " "; } std::cout << std::endl; + for (auto vertex : st.simplex_vertex_range(f_simplex)) { + std::cout << vertex << " "; + } + std::cout << std::endl; - for( auto b_simplex : st.boundary_simplex_range(f_simplex) ) - { + for (auto b_simplex : st.boundary_simplex_range(f_simplex)) { std::cout << " " << "[" << st.filtration(b_simplex) << "] "; - for( auto vertex : st.simplex_vertex_range(b_simplex) ) - { std::cout << vertex << " "; } std::cout << std::endl; + for (auto vertex : st.simplex_vertex_range(b_simplex)) { + std::cout << vertex << " "; + } + std::cout << std::endl; } } return 0; 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 06462c88..8cf5a67e 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 @@ -20,8 +20,8 @@ * along with this program. If not, see . */ -#ifndef SRC_SIMPLEX_TREE_INCLUDE_GUDHI_SIMPLEX_TREE_SIMPLEX_TREE_ITERATORS_H_ -#define SRC_SIMPLEX_TREE_INCLUDE_GUDHI_SIMPLEX_TREE_SIMPLEX_TREE_ITERATORS_H_ +#ifndef SIMPLEX_TREE_ITERATORS_H_ +#define SIMPLEX_TREE_ITERATORS_H_ #include @@ -303,4 +303,4 @@ class Simplex_tree_skeleton_simplex_iterator : public boost::iterator_facade< /* @} */ // end addtogroup simplex_tree } // namespace Gudhi -#endif // SRC_SIMPLEX_TREE_INCLUDE_GUDHI_SIMPLEX_TREE_SIMPLEX_TREE_ITERATORS_H_ +#endif // SIMPLEX_TREE_ITERATORS_H_ diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_node_explicit_storage.h b/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_node_explicit_storage.h index c49e30b9..7f735b7e 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_node_explicit_storage.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_node_explicit_storage.h @@ -20,8 +20,8 @@ * along with this program. If not, see . */ -#ifndef SRC_SIMPLEX_TREE_INCLUDE_GUDHI_SIMPLEX_TREE_SIMPLEX_TREE_NODE_EXPLICIT_STORAGE_H_ -#define SRC_SIMPLEX_TREE_INCLUDE_GUDHI_SIMPLEX_TREE_SIMPLEX_TREE_NODE_EXPLICIT_STORAGE_H_ +#ifndef SIMPLEX_TREE_NODE_EXPLICIT_STORAGE_H_ +#define SIMPLEX_TREE_NODE_EXPLICIT_STORAGE_H_ #include @@ -47,7 +47,7 @@ struct Simplex_tree_node_explicit_storage : SimplexTree::Filtration_simplex_base Simplex_tree_node_explicit_storage(Siblings * sib = nullptr, Filtration_value filtration = 0) : children_(sib) { - this->assign_filtration(filtration); + this->assign_filtration(filtration); } /* @@ -69,4 +69,4 @@ struct Simplex_tree_node_explicit_storage : SimplexTree::Filtration_simplex_base /* @} */ // end addtogroup simplex_tree } // namespace Gudhi -#endif // SRC_SIMPLEX_TREE_INCLUDE_GUDHI_SIMPLEX_TREE_SIMPLEX_TREE_NODE_EXPLICIT_STORAGE_H_ +#endif // SIMPLEX_TREE_NODE_EXPLICIT_STORAGE_H_ 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 d20a91d7..52eeaaea 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 @@ -20,15 +20,15 @@ * along with this program. If not, see . */ -#ifndef SRC_SIMPLEX_TREE_INCLUDE_GUDHI_SIMPLEX_TREE_SIMPLEX_TREE_SIBLINGS_H_ -#define SRC_SIMPLEX_TREE_INCLUDE_GUDHI_SIMPLEX_TREE_SIMPLEX_TREE_SIBLINGS_H_ - -#include "boost/container/flat_map.hpp" -#include "Simplex_tree_node_explicit_storage.h" +#ifndef SIMPLEX_TREE_SIBLINGS_H_ +#define SIMPLEX_TREE_SIBLINGS_H_ #include #include +#include "boost/container/flat_map.hpp" +#include "Simplex_tree_node_explicit_storage.h" + namespace Gudhi { /* \addtogroup simplex_tree @@ -79,7 +79,7 @@ class Simplex_tree_siblings { members.end()) { for (auto& map_el : members_) { map_el.second.assign_children(this); - } + } } /* @@ -123,4 +123,4 @@ class Simplex_tree_siblings { /* @} */ // end addtogroup simplex_tree } // namespace Gudhi -#endif // SRC_SIMPLEX_TREE_INCLUDE_GUDHI_SIMPLEX_TREE_SIMPLEX_TREE_SIBLINGS_H_ +#endif // SIMPLEX_TREE_SIBLINGS_H_ diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree/indexing_tag.h b/src/Simplex_tree/include/gudhi/Simplex_tree/indexing_tag.h index 69ffa44b..a00dac27 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree/indexing_tag.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree/indexing_tag.h @@ -20,8 +20,8 @@ * along with this program. If not, see . */ -#ifndef SRC_SIMPLEX_TREE_INCLUDE_GUDHI_SIMPLEX_TREE_INDEXING_TAG_H_ -#define SRC_SIMPLEX_TREE_INCLUDE_GUDHI_SIMPLEX_TREE_INDEXING_TAG_H_ +#ifndef INDEXING_TAG_H_ +#define INDEXING_TAG_H_ namespace Gudhi { @@ -36,4 +36,4 @@ struct linear_indexing_tag { // struct zigzag_indexing_tag {}; } // namespace Gudhi -#endif // SRC_SIMPLEX_TREE_INCLUDE_GUDHI_SIMPLEX_TREE_INDEXING_TAG_H_ +#endif // INDEXING_TAG_H_ diff --git a/src/common/include/gudhi/Clock.h b/src/common/include/gudhi/Clock.h index 08096c05..04c6ffb9 100644 --- a/src/common/include/gudhi/Clock.h +++ b/src/common/include/gudhi/Clock.h @@ -1,82 +1,79 @@ - /* 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_CLOCK_H_ -#define GUDHI_CLOCK_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 CLOCK_H_ +#define CLOCK_H_ #include -class Clock{ - -public: - Clock():end_called(false){ - startTime = boost::posix_time::microsec_clock::local_time( ); - } - - Clock(const std::string& msg_){ - end_called = false; - begin(); - msg = msg_; - } - - - void begin() const{ - end_called = false; - startTime = boost::posix_time::microsec_clock::local_time( ); - } - - void end() const{ - end_called = true; - endTime = boost::posix_time::microsec_clock::local_time( ); - } - - void print() const{ - std::cout << *this << std::endl; - } - - friend std::ostream& operator<< (std::ostream& stream,const Clock& clock){ - if(!clock.end_called) - clock.end(); - - if(!clock.end_called) stream << "end not called"; - else{ - stream << clock.msg <<":"< + +class Clock { + public: + Clock() : end_called(false) { + startTime = boost::posix_time::microsec_clock::local_time(); + } + + Clock(const std::string& msg_) { + end_called = false; + begin(); + msg = msg_; + } + + void begin() const { + end_called = false; + startTime = boost::posix_time::microsec_clock::local_time(); + } + + void end() const { + end_called = true; + endTime = boost::posix_time::microsec_clock::local_time(); + } + + void print() const { + std::cout << *this << std::endl; + } + + friend std::ostream& operator<<(std::ostream& stream, const Clock& clock) { + if (!clock.end_called) + clock.end(); + + if (!clock.end_called) { + stream << "end not called"; + } else { + stream << clock.msg << ":" << clock.num_seconds() << "s"; + } + return stream; + } + + double num_seconds() const { + if (!end_called) return -1; + return (endTime - startTime).total_milliseconds() / 1000.; + } + + private: + mutable boost::posix_time::ptime startTime, endTime; + mutable bool end_called; + std::string msg; }; - -#endif /* GUDHI_CLOCK_H_ */ +#endif // CLOCK_H_ diff --git a/src/common/include/gudhi/Off_reader.h b/src/common/include/gudhi/Off_reader.h index e29218d8..b70e7897 100644 --- a/src/common/include/gudhi/Off_reader.h +++ b/src/common/include/gudhi/Off_reader.h @@ -1,13 +1,10 @@ -/* - * Off_reader.h - * Created on: Nov 28, 2014 - * This file is part of the Gudhi Library. The Gudhi library +/* 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-Méditerranée (France) + * 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 @@ -25,14 +22,15 @@ */ -#ifndef GUDHI_OFF_READER_H_ -#define GUDHI_OFF_READER_H_ +#ifndef OFF_READER_H_ +#define OFF_READER_H_ #include #include #include - +#include +#include namespace Gudhi { @@ -48,151 +46,144 @@ namespace Gudhi { * * The number of edges num_edges is optional and can be left to zero. */ -class Off_reader{ -public: - Off_reader(std::ifstream& stream):stream_(stream){ - } -// Off_reader(const std::string& name):stream_(name){ -// if(!stream_.is_open()) -// std::cerr <<"could not open file \n"; -// } - - ~Off_reader(){ - stream_.close(); - } - - /** - * read an off file and calls the following methods : - * void init(int dim,int num_vertices,int num_faces,int num_edges); //num_edges may not be set - * void point(const std::vector& point); - * void maximal_face(const std::list& face); - * void done(); - * of the visitor when reading a point or a maximal face. - */ - template - bool read(OffVisitor& off_visitor){ - bool success_read_off_preambule = read_off_preambule(off_visitor); - if(!success_read_off_preambule) { - std::cerr <<"could not read off preambule\n"; - return false; - } - - bool success_read_off_points = read_off_points(off_visitor); - if(!success_read_off_points) { - std::cerr <<"could not read off points\n"; - return false; - } - - bool success_read_off_faces = read_off_faces(off_visitor); - if(!success_read_off_faces) { - std::cerr <<"could not read off faces\n"; - return false; - } - - off_visitor.done(); - return success_read_off_preambule && success_read_off_points && success_read_off_faces; - } - -private: - std::ifstream& stream_; - - struct Off_info{ - int dim; - int num_vertices; - int num_edges; - int num_faces; - }; - - Off_info off_info_; - - template - bool read_off_preambule(OffVisitor& off_visitor){ - std::string line; - if(!goto_next_uncomment_line(line)) return false; - - bool is_off_file = (line.find("OFF") != std::string::npos); - bool is_noff_file = (line.find("nOFF") != std::string::npos); - - if(!is_off_file && !is_noff_file) { - std::cerr << line<> off_info_.num_vertices >> off_info_.num_faces >> off_info_.num_edges)){ - std::cerr << "incorrect number of vertices/faces/edges\n"; - return false; - } - } - else - if(!(iss >> off_info_.dim >> off_info_.num_vertices >> off_info_.num_faces >> off_info_.num_edges)){ - std::cerr << "incorrect number of vertices/faces/edges\n"; - return false; - } - off_visitor.init(off_info_.dim,off_info_.num_vertices,off_info_.num_faces,off_info_.num_edges); - - return true; - } - - bool goto_next_uncomment_line(std::string& uncomment_line){ - uncomment_line.clear(); - do - std::getline(stream_, uncomment_line); - while(uncomment_line[0] == '%');// || uncomment_line.empty()); - return (uncomment_line.size()>0 && uncomment_line[0] != '%'); - } - - - template - bool read_off_points(OffVisitor& visitor){ - int num_vertices_to_read = off_info_.num_vertices; - while(num_vertices_to_read--){ - std::string line; - if(!goto_next_uncomment_line(line)) return false; - std::vector point; - std::istringstream iss(line); - point.assign(std::istream_iterator(iss),std::istream_iterator()); -// if(point.size() != off_info_.dim) return false; - visitor.point(point); - } - return true; - } - - template - bool read_off_faces(OffVisitor& visitor){ - std::string line; - while(goto_next_uncomment_line(line)){ - std::istringstream iss(line); - int num_face_vertices; - 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; - visitor.maximal_face(face); - } - return true; - } +class Off_reader { + public: + Off_reader(std::ifstream& stream) : stream_(stream) { } + // Off_reader(const std::string& name):stream_(name){ + // if(!stream_.is_open()) + // std::cerr <<"could not open file \n"; + // } + + ~Off_reader() { + stream_.close(); + } + + /** + * read an off file and calls the following methods : + * void init(int dim,int num_vertices,int num_faces,int num_edges); //num_edges may not be set + * void point(const std::vector& point); + * void maximal_face(const std::list& face); + * void done(); + * of the visitor when reading a point or a maximal face. + */ + template + bool read(OffVisitor& off_visitor) { + bool success_read_off_preambule = read_off_preambule(off_visitor); + if (!success_read_off_preambule) { + std::cerr << "could not read off preambule\n"; + return false; + } + + bool success_read_off_points = read_off_points(off_visitor); + if (!success_read_off_points) { + std::cerr << "could not read off points\n"; + return false; + } + + bool success_read_off_faces = read_off_faces(off_visitor); + if (!success_read_off_faces) { + std::cerr << "could not read off faces\n"; + return false; + } + + off_visitor.done(); + return success_read_off_preambule && success_read_off_points && success_read_off_faces; + } + + private: + std::ifstream& stream_; + + struct Off_info { + int dim; + int num_vertices; + int num_edges; + int num_faces; + }; + + Off_info off_info_; + + template + bool read_off_preambule(OffVisitor& off_visitor) { + std::string line; + if (!goto_next_uncomment_line(line)) return false; + + bool is_off_file = (line.find("OFF") != std::string::npos); + bool is_noff_file = (line.find("nOFF") != std::string::npos); + + if (!is_off_file && !is_noff_file) { + std::cerr << line << std::endl; + std::cerr << "missing off header\n"; + return false; + } + + if (!goto_next_uncomment_line(line)) return false; + std::istringstream iss(line); + if (is_off_file) { + off_info_.dim = 3; + if (!(iss >> off_info_.num_vertices >> off_info_.num_faces >> off_info_.num_edges)) { + std::cerr << "incorrect number of vertices/faces/edges\n"; + return false; + } + } else { + if (!(iss >> off_info_.dim >> off_info_.num_vertices >> off_info_.num_faces >> off_info_.num_edges)) { + std::cerr << "incorrect number of vertices/faces/edges\n"; + return false; + } + } + off_visitor.init(off_info_.dim, off_info_.num_vertices, off_info_.num_faces, off_info_.num_edges); + + return true; + } + + bool goto_next_uncomment_line(std::string& uncomment_line) { + uncomment_line.clear(); + do + std::getline(stream_, uncomment_line); while (uncomment_line[0] == '%'); // || uncomment_line.empty()); + return (uncomment_line.size() > 0 && uncomment_line[0] != '%'); + } + + template + bool read_off_points(OffVisitor& visitor) { + int num_vertices_to_read = off_info_.num_vertices; + while (num_vertices_to_read--) { + std::string line; + if (!goto_next_uncomment_line(line)) return false; + std::vector point; + std::istringstream iss(line); + point.assign(std::istream_iterator(iss), std::istream_iterator()); + // if(point.size() != off_info_.dim) return false; + visitor.point(point); + } + return true; + } + + template + bool read_off_faces(OffVisitor& visitor) { + std::string line; + while (goto_next_uncomment_line(line)) { + std::istringstream iss(line); + int num_face_vertices; + 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; + visitor.maximal_face(face); + } + return true; + } }; - template -void read_off(const std::string& name_file_off,OFFVisitor& vis){ - std::ifstream stream(name_file_off); - if(!stream.is_open()) - std::cerr <<"could not open file \n"; - else{ - Off_reader off_reader(stream); - off_reader.read(vis); - } +void read_off(const std::string& name_file_off, OFFVisitor& vis) { + std::ifstream stream(name_file_off); + if (!stream.is_open()) { + std::cerr << "could not open file \n"; + } else { + Off_reader off_reader(stream); + off_reader.read(vis); + } } - - } // namespace Gudhi - -#endif /* GUDHI_OFF_READER_H_ */ +#endif // OFF_READER_H_ diff --git a/src/common/include/gudhi/Point.h b/src/common/include/gudhi/Point.h index 4023445b..0479e71e 100644 --- a/src/common/include/gudhi/Point.h +++ b/src/common/include/gudhi/Point.h @@ -1,13 +1,10 @@ -/* - * Basic_geometry.h - * Created on: Feb 10, 2015 - * This file is part of the Gudhi Library. The Gudhi library +/* 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-Méditerranée (France) + * 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 @@ -24,9 +21,8 @@ * */ - -#ifndef BASIC_GEOMETRY_H_ -#define BASIC_GEOMETRY_H_ +#ifndef POINT_H_ +#define POINT_H_ #include #include @@ -34,143 +30,141 @@ #include #include -class Point_d{ -public: - Point_d(size_t dim=3):coords_(dim,0){} - Point_d(const Point_d& other):coords_(other.coords_){} - Point_d(const std::initializer_list& list):coords_(list) { - } - template - Point_d(CoordsIt begin,CoordsIt end):coords_(begin,end){} - - size_t dimension() const{ - return coords_.size(); - } - - double x() const{ - return coords_[0]; - } - - double y() const{ - return coords_[1]; - } - - double z() const{ - return coords_[2]; - } - - double& x(){ - return coords_[0]; - } - - double& y(){ - return coords_[1]; - } - - double& z(){ - return coords_[2]; - } - - std::vector::const_iterator begin() const{ - return coords_.begin(); - } - - std::vector::const_iterator end() const{ - return coords_.end(); - } - - double& operator[](unsigned i){ - return coords_[i]; - } - const double& operator[](unsigned i) const{ - return coords_[i]; - } - - double squared_norm() const{ - double res = 0; - for(auto x : coords_) - res+= x*x; - return res; - } - - friend double squared_dist(const Point_d& p1,const Point_d& p2){ - assert(p1.dimension()==p2.dimension()); - double res = 0; - for(unsigned i = 0; i < p1.coords_.size(); ++i) - res+= (p1[i]-p2[i])*(p1[i]-p2[i]); - return res; - } - - /** - * dot product - */ - double operator*(const Point_d& other) const{ - assert(dimension()==other.dimension()); - double res = 0; - for(unsigned i = 0; i < coords_.size(); ++i) - res+= coords_[i]*other[i]; - return res; - } - - /** - * only if points have dimension 3 - */ - Point_d cross_product(const Point_d& other){ - assert(dimension()==3 && other.dimension()==3); - Point_d res(3); - res[0] = (*this)[1] * other[2] - (*this)[2] * other[1]; - res[1] = (*this)[2] * other[0] - (*this)[0] * other[2]; - res[2] = (*this)[0] * other[1] - (*this)[1] * other[0]; - return res; - } - - Point_d operator+(const Point_d& other) const{ - assert(dimension()==other.dimension()); - Point_d res(dimension()); - for(unsigned i = 0; i < coords_.size(); ++i) - res[i] = (*this)[i] + other[i]; - return res; - } - - Point_d operator*(double lambda) const{ - Point_d res(dimension()); - for(unsigned i = 0; i < coords_.size(); ++i) - res[i] = (*this)[i] * lambda; - return res; - } - - Point_d operator/(double lambda) const{ - Point_d res(dimension()); - for(unsigned i = 0; i < coords_.size(); ++i) - res[i] = (*this)[i] / lambda; - return res; - } - - Point_d operator-(const Point_d& other) const{ - assert(dimension()==other.dimension()); - Point_d res(dimension()); - for(unsigned i = 0; i < coords_.size(); ++i) - res[i] = (*this)[i] - other[i]; - return res; - } - - friend Point_d unit_normal(const Point_d& p1,const Point_d& p2,const Point_d& p3){ - assert(p1.dimension()==3); - assert(p2.dimension()==3); - assert(p3.dimension()==3); - Point_d p1p2 = p2 - p1; - Point_d p1p3 = p3 - p1; - Point_d res(p1p2.cross_product(p1p3)); - return res / std::sqrt(res.squared_norm()); - } - - -private: - std::vector coords_; +class Point_d { + public: + Point_d(size_t dim = 3) : coords_(dim, 0) { } + + Point_d(const Point_d& other) : coords_(other.coords_) { } + + Point_d(const std::initializer_list& list) : coords_(list) { } + + template + Point_d(CoordsIt begin, CoordsIt end) : coords_(begin, end) { } + + size_t dimension() const { + return coords_.size(); + } + + double x() const { + return coords_[0]; + } + + double y() const { + return coords_[1]; + } + + double z() const { + return coords_[2]; + } + + double& x() { + return coords_[0]; + } + + double& y() { + return coords_[1]; + } + + double& z() { + return coords_[2]; + } + + std::vector::const_iterator begin() const { + return coords_.begin(); + } + + std::vector::const_iterator end() const { + return coords_.end(); + } + + double& operator[](unsigned i) { + return coords_[i]; + } + + const double& operator[](unsigned i) const { + return coords_[i]; + } + + double squared_norm() const { + double res = 0; + for (auto x : coords_) + res += x * x; + return res; + } + + friend double squared_dist(const Point_d& p1, const Point_d& p2) { + assert(p1.dimension() == p2.dimension()); + double res = 0; + for (unsigned i = 0; i < p1.coords_.size(); ++i) + res += (p1[i] - p2[i])*(p1[i] - p2[i]); + return res; + } + + /** + * dot product + */ + double operator*(const Point_d& other) const { + assert(dimension() == other.dimension()); + double res = 0; + for (unsigned i = 0; i < coords_.size(); ++i) + res += coords_[i] * other[i]; + return res; + } + + /** + * only if points have dimension 3 + */ + Point_d cross_product(const Point_d& other) { + assert(dimension() == 3 && other.dimension() == 3); + Point_d res(3); + res[0] = (*this)[1] * other[2] - (*this)[2] * other[1]; + res[1] = (*this)[2] * other[0] - (*this)[0] * other[2]; + res[2] = (*this)[0] * other[1] - (*this)[1] * other[0]; + return res; + } + + Point_d operator+(const Point_d& other) const { + assert(dimension() == other.dimension()); + Point_d res(dimension()); + for (unsigned i = 0; i < coords_.size(); ++i) + res[i] = (*this)[i] + other[i]; + return res; + } + + Point_d operator*(double lambda) const { + Point_d res(dimension()); + for (unsigned i = 0; i < coords_.size(); ++i) + res[i] = (*this)[i] * lambda; + return res; + } + + Point_d operator/(double lambda) const { + Point_d res(dimension()); + for (unsigned i = 0; i < coords_.size(); ++i) + res[i] = (*this)[i] / lambda; + return res; + } + + Point_d operator-(const Point_d& other) const { + assert(dimension() == other.dimension()); + Point_d res(dimension()); + for (unsigned i = 0; i < coords_.size(); ++i) + res[i] = (*this)[i] - other[i]; + return res; + } + + friend Point_d unit_normal(const Point_d& p1, const Point_d& p2, const Point_d& p3) { + assert(p1.dimension() == 3); + assert(p2.dimension() == 3); + assert(p3.dimension() == 3); + Point_d p1p2 = p2 - p1; + Point_d p1p3 = p3 - p1; + Point_d res(p1p2.cross_product(p1p3)); + return res / std::sqrt(res.squared_norm()); + } + + private: + std::vector coords_; }; - - - - -#endif /* BASIC_GEOMETRY_H_ */ +#endif // POINT_H_ diff --git a/src/common/include/gudhi/Simple_object_pool.h b/src/common/include/gudhi/Simple_object_pool.h index fffcb2ef..fb9c8e23 100644 --- a/src/common/include/gudhi/Simple_object_pool.h +++ b/src/common/include/gudhi/Simple_object_pool.h @@ -20,45 +20,62 @@ * along with this program. If not, see . */ +#ifndef SIMPLE_OBJECT_POOL_H_ +#define SIMPLE_OBJECT_POOL_H_ + #include #include namespace Gudhi { - /** \private - * This is a simpler version of boost::object_pool, that requires - * that users explicitly destroy all objects. This lets the - * performance scale much better, see - * https://svn.boost.org/trac/boost/ticket/3789 . - */ + +/** \private + * This is a simpler version of boost::object_pool, that requires + * that users explicitly destroy all objects. This lets the + * performance scale much better, see + * https://svn.boost.org/trac/boost/ticket/3789 . + */ template -class Simple_object_pool : protected boost::pool -{ - protected: +class Simple_object_pool : protected boost::pool { + protected: typedef boost::pool Base; typedef T* pointer; - Base& base(){return *this;} - Base const& base()const{return *this;} - public: + + Base& base() { + return *this; + } + + Base const& base()const { + return *this; + } + + public: typedef T element_type; typedef boost::default_user_allocator_malloc_free user_allocator; typedef typename Base::size_type size_type; typedef typename Base::difference_type difference_type; + template - Simple_object_pool(U&&...u) : Base(sizeof(T), std::forward(u)...) {} + Simple_object_pool(U&&...u) : Base(sizeof (T), std::forward(u)...) { } + template - pointer construct(U&&...u){ - void* p=base().malloc BOOST_PREVENT_MACRO_SUBSTITUTION(); + pointer construct(U&&...u) { + void* p = base().malloc BOOST_PREVENT_MACRO_SUBSTITUTION(); assert(p); - try { new(p) T(std::forward(u)...); } - catch(...) { + try { + new(p) T(std::forward(u)...); + } catch (...) { base().free BOOST_PREVENT_MACRO_SUBSTITUTION(p); throw; } - return static_cast(p); + return static_cast (p); } - void destroy(pointer p){ + + void destroy(pointer p) { p->~T(); base().free BOOST_PREVENT_MACRO_SUBSTITUTION(p); } }; -} + +} // namespace Gudhi + +#endif // SIMPLE_OBJECT_POOL_H_ diff --git a/src/common/include/gudhi/Test.h b/src/common/include/gudhi/Test.h index 18b7ca82..66f7bfd3 100644 --- a/src/common/include/gudhi/Test.h +++ b/src/common/include/gudhi/Test.h @@ -1,5 +1,28 @@ -#ifndef __TEST_H -#define __TEST_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 TEST_H +#define TEST_H #include #include @@ -8,78 +31,75 @@ #include -#define TEST(a) std::cout << "TEST: " << (a)< tests; - -public: - void add(std::string name_,bool (*test_)()){ - Test test(name_,test_); - tests.push_back(test); - } - bool run(){ - bool tests_succesful(true); - std::vector res; - for (Test test : tests){ - res.push_back(test.run()); - } - std::cout << "\n\n results of tests : "< "; - if (res[i++]) std::cout << "OK"< tests; + + public: + void add(std::string name_, bool (*test_)()) { + Test test(name_, test_); + tests.push_back(test); + } + + bool run() { + bool tests_succesful(true); + std::vector res; + for (Test test : tests) { + res.push_back(test.run()); + } + std::cout << "\n\n results of tests : " << std::endl; + int i = 0; + for (Test t : tests) { + std::cout << "Test " << i << " \"" << t.getName() << "\" --> "; + if (res[i++]) { + std::cout << "OK" << std::endl; + } else { + std::cout << "Fail" << std::endl; + tests_succesful = false; + break; + } + } + return tests_succesful; + } }; -#endif +#endif // TEST_H diff --git a/src/common/include/gudhi/Utils.h b/src/common/include/gudhi/Utils.h index 7678685c..43916f11 100644 --- a/src/common/include/gudhi/Utils.h +++ b/src/common/include/gudhi/Utils.h @@ -1,48 +1,46 @@ - /* 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_UTILS_H_ -#define GUDHI_UTILS_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 UTILS_H_ +#define UTILS_H_ -#define PRINT(a) std::cerr << #a << ": " << (a) << " (DISP)"< "; for(auto x:a) std::cerr<< x << ","; std::cerr< "; for (auto x : a) std::cerr << x << ","; std::cerr << +std::endl #else -//#define DBG(a) a -//#define DBGMSG(a,b) b -//#define DBGVALUE(a) a -//#define DBGCONT(a) a +// #define DBG(a) a +// #define DBGMSG(a,b) b +// #define DBGVALUE(a) a +// #define DBGCONT(a) a #define DBG(a) -#define DBGMSG(a,b) +#define DBGMSG(a, b) #define DBGVALUE(a) #define DBGCONT(a) #endif - - - -#endif /* UTILS_H_ */ +#endif // UTILS_H_ diff --git a/src/common/include/gudhi/distance_functions.h b/src/common/include/gudhi/distance_functions.h index 7a2ab035..de05be0c 100644 --- a/src/common/include/gudhi/distance_functions.h +++ b/src/common/include/gudhi/distance_functions.h @@ -1,37 +1,41 @@ - /* 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 . - */ +/* 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 DISTANCE_FUNCTION_H_ +#define DISTANCE_FUNCTION_H_ /* Compute the Euclidean distance between two Points given * by a range of coordinates. The points are assumed to have * the same dimension. */ template< typename Point > -double euclidean_distance( Point &p1, Point &p2) -{ +double euclidean_distance(Point &p1, Point &p2) { double dist = 0.; - auto it1 = p1.begin(); auto it2 = p2.begin(); - for(; it1 != p1.end(); ++it1, ++it2) - { - double tmp = *it1 - *it2; - dist += tmp*tmp; - } - return sqrt(dist); + auto it1 = p1.begin(); + auto it2 = p2.begin(); + for (; it1 != p1.end(); ++it1, ++it2) { + double tmp = *it1 - *it2; + dist += tmp*tmp; + } + return sqrt(dist); } + +#endif // DISTANCE_FUNCTION_H_ diff --git a/src/common/include/gudhi/graph_simplicial_complex.h b/src/common/include/gudhi/graph_simplicial_complex.h index 1ad9dabd..25d92be5 100644 --- a/src/common/include/gudhi/graph_simplicial_complex.h +++ b/src/common/include/gudhi/graph_simplicial_complex.h @@ -1,27 +1,27 @@ - /* 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 . - */ +/* 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_GRAPH_SIMPLICIAL_COMPLEX_FILTRATION_TAG_H -#define GUDHI_GRAPH_SIMPLICIAL_COMPLEX_FILTRATION_TAG_H +#ifndef GRAPH_SIMPLICIAL_COMPLEX_H +#define GRAPH_SIMPLICIAL_COMPLEX_H #include @@ -29,68 +29,67 @@ struct edge_filtration_t { typedef boost::edge_property_tag kind; }; + /* Vertex tag for Boost PropertyGraph. */ struct vertex_filtration_t { typedef boost::vertex_property_tag kind; }; -typedef int Vertex_handle; -typedef double Filtration_value; +typedef int Vertex_handle; +typedef double Filtration_value; typedef boost::adjacency_list < boost::vecS, boost::vecS, boost::undirectedS - , boost::property < vertex_filtration_t, Filtration_value > - , boost::property < edge_filtration_t, Filtration_value > - > Graph_t; +, boost::property < vertex_filtration_t, Filtration_value > +, boost::property < edge_filtration_t, Filtration_value > +> Graph_t; typedef std::pair< Vertex_handle, Vertex_handle > Edge_t; /** \brief Output the proximity graph of the points. - * - * If points contains n elements, the proximity graph is the graph - * with n vertices, and an edge [u,v] iff the distance function between - * points u and v is smaller than threshold. - * - * The type PointCloud furnishes .begin() and .end() methods, that return - * iterators with value_type Point. - */ + * + * If points contains n elements, the proximity graph is the graph + * with n vertices, and an edge [u,v] iff the distance function between + * points u and v is smaller than threshold. + * + * The type PointCloud furnishes .begin() and .end() methods, that return + * iterators with value_type Point. + */ template< typename PointCloud - , typename Point > -Graph_t compute_proximity_graph( PointCloud &points - , Filtration_value threshold - , Filtration_value distance(Point p1, Point p2) ) -{ - std::vector< Edge_t > edges; - std::vector< Filtration_value > edges_fil; +, typename Point > +Graph_t compute_proximity_graph(PointCloud &points + , Filtration_value threshold + , Filtration_value distance(Point p1, Point p2)) { + std::vector< Edge_t > edges; + std::vector< Filtration_value > edges_fil; std::map< Vertex_handle, Filtration_value > vertices; Vertex_handle idx_u, idx_v; Filtration_value fil; idx_u = 0; - for(auto it_u = points.begin(); it_u != points.end(); ++it_u) - { - idx_v = idx_u+1; - for(auto it_v = it_u+1; it_v != points.end(); ++it_v, ++idx_v) - { - fil = distance(*it_u,*it_v); - if(fil <= threshold) { - edges.emplace_back(idx_u,idx_v); + for (auto it_u = points.begin(); it_u != points.end(); ++it_u) { + idx_v = idx_u + 1; + for (auto it_v = it_u + 1; it_v != points.end(); ++it_v, ++idx_v) { + fil = distance(*it_u, *it_v); + if (fil <= threshold) { + edges.emplace_back(idx_u, idx_v); edges_fil.push_back(fil); } } ++idx_u; } - Graph_t skel_graph( edges.begin() - , edges.end() - , edges_fil.begin() - , idx_u); //number of points labeled from 0 to idx_u-1 + Graph_t skel_graph(edges.begin() + , edges.end() + , edges_fil.begin() + , idx_u); //number of points labeled from 0 to idx_u-1 - auto vertex_prop = boost::get(vertex_filtration_t(),skel_graph); + auto vertex_prop = boost::get(vertex_filtration_t(), skel_graph); boost::graph_traits::vertex_iterator vi, vi_end; - for ( std::tie(vi, vi_end) = boost::vertices(skel_graph); - vi != vi_end; ++vi ) - { boost::put(vertex_prop, *vi, 0.); } - + for (std::tie(vi, vi_end) = boost::vertices(skel_graph); + vi != vi_end; ++vi) { + boost::put(vertex_prop, *vi, 0.); + } + return skel_graph; } -#endif // GUDHI_GRAPH_SIMPLICIAL_COMPLEX_FILTRATION_TAG_H +#endif // GRAPH_SIMPLICIAL_COMPLEX_H diff --git a/src/common/include/gudhi/reader_utils.h b/src/common/include/gudhi/reader_utils.h index ab12c268..99426dac 100644 --- a/src/common/include/gudhi/reader_utils.h +++ b/src/common/include/gudhi/reader_utils.h @@ -1,27 +1,27 @@ - /* 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 . - */ +/* 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_READER_UTILS_H -#define GUDHI_READER_UTILS_H +#ifndef READER_UTILS_H +#define READER_UTILS_H #include #include @@ -37,22 +37,21 @@ * X21 X22 ... X2d * etc */ -inline void -read_points ( std::string file_name - , std::vector< std::vector< double > > & points) -{ - std::ifstream in_file (file_name.c_str(),std::ios::in); - if(!in_file.is_open()) { +inline void read_points(std::string file_name, std::vector< std::vector< double > > & points) { + std::ifstream in_file(file_name.c_str(), std::ios::in); + if (!in_file.is_open()) { std::cerr << "Unable to open file " << file_name << std::endl; - return;} + return; + } std::string line; double x; - while( getline ( in_file , line ) ) - { + while (getline(in_file, line)) { std::vector< double > point; - std::istringstream iss( line ); - while(iss >> x) { point.push_back(x); } + std::istringstream iss(line); + while (iss >> x) { + point.push_back(x); + } points.push_back(point); } in_file.close(); @@ -70,53 +69,64 @@ read_points ( std::string file_name * Every simplex must appear exactly once. * Simplices of dimension more than 1 are ignored. */ -inline Graph_t -read_graph ( std::string file_name ) -{ - std::ifstream in_ (file_name.c_str(),std::ios::in); - if(!in_.is_open()) { std::cerr << "Unable to open file " << file_name << std::endl; } +inline Graph_t read_graph(std::string file_name) { + std::ifstream in_(file_name.c_str(), std::ios::in); + if (!in_.is_open()) { + std::cerr << "Unable to open file " << file_name << std::endl; + } - std::vector< Edge_t > edges; - std::vector< Filtration_value > edges_fil; + std::vector< Edge_t > edges; + std::vector< Filtration_value > edges_fil; std::map< Vertex_handle, Filtration_value > vertices; - - std::string line; - int dim; - Vertex_handle u,v,max_h = -1; + + std::string line; + int dim; + Vertex_handle u, v, max_h = -1; Filtration_value fil; - while( getline ( in_ , line ) ) - { - std::istringstream iss( line ); - while(iss >> dim) { - switch ( dim ) { - case 0 : { - iss >> u; iss >> fil; + while (getline(in_, line)) { + std::istringstream iss(line); + while (iss >> dim) { + switch (dim) { + case 0: + { + iss >> u; + iss >> fil; vertices[u] = fil; - if(max_h < u) { max_h = u; } + if (max_h < u) { + max_h = u; + } break; } - case 1 : { - iss >> u; iss >> v; iss >> fil; - edges.push_back(Edge_t(u,v)); + case 1: + { + iss >> u; + iss >> v; + iss >> fil; + edges.push_back(Edge_t(u, v)); edges_fil.push_back(fil); break; } - default: {break;} - } + default: + { + break; + } + } } } in_.close(); - if((size_t)(max_h+1) != vertices.size()) - { std::cerr << "Error: vertices must be labeled from 0 to n-1 \n"; } + if ((size_t) (max_h + 1) != vertices.size()) { + std::cerr << "Error: vertices must be labeled from 0 to n-1 \n"; + } - Graph_t skel_graph(edges.begin(),edges.end(),edges_fil.begin(),vertices.size()); - auto vertex_prop = boost::get(vertex_filtration_t(),skel_graph); + Graph_t skel_graph(edges.begin(), edges.end(), edges_fil.begin(), vertices.size()); + auto vertex_prop = boost::get(vertex_filtration_t(), skel_graph); boost::graph_traits::vertex_iterator vi, vi_end; auto v_it = vertices.begin(); - for (std::tie(vi, vi_end) = boost::vertices(skel_graph); vi != vi_end; ++vi,++v_it) - { boost::put(vertex_prop, *vi, v_it->second); } + for (std::tie(vi, vi_end) = boost::vertices(skel_graph); vi != vi_end; ++vi, ++v_it) { + boost::put(vertex_prop, *vi, v_it->second); + } return skel_graph; } @@ -133,17 +143,15 @@ read_graph ( std::string file_name ) * Every simplex must appear exactly once. * Simplices of dimension more than 1 are ignored. */ -template< typename Vertex_handle - , typename Filtration_value > -bool read_simplex ( std::istream & in_ - , std::vector< Vertex_handle > & simplex - , Filtration_value & fil ) -{ - int dim=0; - if(!(in_ >> dim)) return false; +template< typename Vertex_handle, typename Filtration_value > +bool read_simplex(std::istream & in_, std::vector< Vertex_handle > & simplex, Filtration_value & fil) { + int dim = 0; + if (!(in_ >> dim)) return false; Vertex_handle v; - for(int i=0; i> v; simplex.push_back(v); } + for (int i = 0; i < dim + 1; ++i) { + in_ >> v; + simplex.push_back(v); + } in_ >> fil; in_.ignore((std::numeric_limits::max)(), '\n'); // ignore until the carriage return return true; @@ -162,20 +170,21 @@ bool read_simplex ( std::istream & in_ * Dimi ki1 ki2 ... kiDimi Fili means that the ith simplex in the * filtration has dimension Dimi, filtration value fil1 and simplices with * key ki1 ... kiDimi in its boundary.*/ -template< typename Simplex_key - , typename Filtration_value > -bool read_hasse_simplex ( std::istream & in_ - , std::vector< Simplex_key > & boundary - , Filtration_value & fil ) -{ +template< typename Simplex_key, typename Filtration_value > +bool read_hasse_simplex(std::istream & in_, std::vector< Simplex_key > & boundary, Filtration_value & fil) { int dim; - if(!(in_ >> dim)) return false; - if(dim == 0) {in_ >> fil; return true;} + if (!(in_ >> dim)) return false; + if (dim == 0) { + in_ >> fil; + return true; + } Simplex_key key; - for(int i=0; i> key; boundary.push_back(key); } + for (int i = 0; i < dim + 1; ++i) { + in_ >> key; + boundary.push_back(key); + } in_ >> fil; return true; } -#endif // GUDHI_READER_UTILS_H +#endif // READER_UTILS_H -- cgit v1.2.3 From 37f590e0d63055e5927c77d2ffa9f3dd8271a5c6 Mon Sep 17 00:00:00 2001 From: glisse Date: Mon, 5 Oct 2015 14:17:38 +0000 Subject: Use boost static_vector instead of std::vector in the boundary iterator of Simplex_tree. The size can never grow very large (bounded by the dimension, which is bounded by the log of the number of simplices) and this avoids a lot of dynamic memory handling. git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@825 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 9f6bdc1ed7bae4c44432a05278a719f9aee26b99 --- .../include/gudhi/Simplex_tree/Simplex_tree_iterators.h | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src/Simplex_tree') 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 8cf5a67e..f83f5ea8 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 @@ -24,6 +24,10 @@ #define SIMPLEX_TREE_ITERATORS_H_ #include +#include +#if BOOST_VERSION >= 105600 +# include +#endif #include @@ -131,8 +135,7 @@ class Simplex_tree_boundary_simplex_iterator : public boost::iterator_facade< } Siblings * for_sib = sib_; - for (typename std::vector::reverse_iterator rit = suffix_ - .rbegin(); rit != suffix_.rend(); ++rit) { + for (auto rit = suffix_.rbegin(); rit != suffix_.rend(); ++rit) { sh_ = for_sib->find(*rit); for_sib = sh_->second.children(); } @@ -142,9 +145,18 @@ class Simplex_tree_boundary_simplex_iterator : public boost::iterator_facade< sib_ = sib_->oncles(); } + // Most of the storage should be moved to the range, iterators should be light. Vertex_handle last_; // last vertex of the simplex Vertex_handle next_; // next vertex to push in suffix_ +#if BOOST_VERSION >= 105600 + // 40 seems a conservative bound on the dimension of a Simplex_tree for now, + // as it would not fit on the biggest hard-drive. + boost::container::static_vector suffix_; + // static_vector still has some overhead compared to a trivial hand-made + // version using std::aligned_storage, or compared to making suffix_ static. +#else std::vector suffix_; +#endif Siblings * sib_; // where the next search will start from Simplex_handle sh_; // current Simplex_handle in the boundary SimplexTree * st_; // simplex containing the simplicial complex -- cgit v1.2.3 From b813fb206a8c03e6f2e278e734d11d4acd5922ad Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Mon, 5 Oct 2015 14:48:35 +0000 Subject: cpplint fixes - simplex_tree_from_file.cpp renamed simplex_tree_from_cliques_of_graph.cpp - #include "" vs #include <> for skeleton blockers git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@826 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 1bd1ad535e4283bce35eeb31fa8d7896b9de474b --- src/CMakeLists.txt | 7 + src/GudhUI/utils/UI_utils.h | 13 +- .../Persistent_cohomology_column.h | 8 +- src/Simplex_tree/example/CMakeLists.txt | 6 +- .../example/simplex_tree_from_cliques_of_graph.cpp | 114 +++++ .../example/simplex_tree_from_file.cpp | 114 ----- .../gudhi/Simplex_tree/Simplex_tree_siblings.h | 7 +- .../include/gudhi/Skeleton_blocker.h | 29 +- .../Skeleton_blocker_complex_visitor.h | 10 +- .../Skeleton_blocker_link_superior.h | 8 +- .../Skeleton_blocker/Skeleton_blocker_off_io.h | 10 +- .../Skeleton_blocker_simple_geometric_traits.h | 10 +- .../Skeleton_blocker_simple_traits.h | 9 +- .../Skeleton_blocker/Skeleton_blocker_simplex.h | 7 +- .../Skeleton_blocker_sub_complex.h | 15 +- .../gudhi/Skeleton_blocker/internal/Top_faces.h | 105 ++--- .../include/gudhi/Skeleton_blocker/internal/Trie.h | 464 ++++++++++----------- .../Skeleton_blockers_blockers_iterators.h | 221 +++++----- .../iterators/Skeleton_blockers_edges_iterators.h | 277 ++++++------ .../iterators/Skeleton_blockers_iterators.h | 19 +- .../Skeleton_blockers_simplices_iterators.h | 23 +- .../Skeleton_blockers_triangles_iterators.h | 407 +++++++++--------- .../Skeleton_blockers_vertices_iterators.h | 318 +++++++------- .../include/gudhi/Skeleton_blocker_complex.h | 37 +- .../gudhi/Skeleton_blocker_geometric_complex.h | 12 +- .../include/gudhi/Skeleton_blocker_link_complex.h | 10 +- .../gudhi/Skeleton_blocker_simplifiable_complex.h | 8 +- src/common/include/gudhi/reader_utils.h | 10 +- 28 files changed, 1111 insertions(+), 1167 deletions(-) create mode 100644 src/Simplex_tree/example/simplex_tree_from_cliques_of_graph.cpp delete mode 100644 src/Simplex_tree/example/simplex_tree_from_file.cpp (limited to 'src/Simplex_tree') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 545b0b58..fbc3119d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,6 +1,11 @@ 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) + list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules/") find_package(Boost REQUIRED COMPONENTS system filesystem program_options chrono timer REQUIRED) @@ -51,4 +56,6 @@ else() # data points generator add_subdirectory(data/points/generator) + install (FILES include/* DESTINATION include) + endif() diff --git a/src/GudhUI/utils/UI_utils.h b/src/GudhUI/utils/UI_utils.h index a7c0689f..4ade4b98 100644 --- a/src/GudhUI/utils/UI_utils.h +++ b/src/GudhUI/utils/UI_utils.h @@ -8,21 +8,18 @@ #ifndef UI_UTILS_H_ #define UI_UTILS_H_ -#define PRINT(a) std::cerr << #a << ": " << (a) << " (DISP)"< "; for(auto x:a) std::cerr<< x << ","; std::cerr< +#include +#include +#include -#include "boost/tuple/tuple.hpp" -#include "boost/intrusive/set.hpp" -#include "boost/intrusive/list.hpp" +#include namespace Gudhi { diff --git a/src/Simplex_tree/example/CMakeLists.txt b/src/Simplex_tree/example/CMakeLists.txt index 2f924490..c70cfe35 100644 --- a/src/Simplex_tree/example/CMakeLists.txt +++ b/src/Simplex_tree/example/CMakeLists.txt @@ -1,9 +1,9 @@ cmake_minimum_required(VERSION 2.6) project(GUDHISimplexTreeFromFile) -add_executable ( simplex_tree_from_file simplex_tree_from_file.cpp ) -add_test(simplex_tree_from_file_2 ${CMAKE_CURRENT_BINARY_DIR}/simplex_tree_from_file ${CMAKE_SOURCE_DIR}/data/points/Klein_bottle_complex.txt 2) -add_test(simplex_tree_from_file_3 ${CMAKE_CURRENT_BINARY_DIR}/simplex_tree_from_file ${CMAKE_SOURCE_DIR}/data/points/Klein_bottle_complex.txt 3) +add_executable ( simplex_tree_from_cliques_of_graph simplex_tree_from_cliques_of_graph.cpp ) +add_test(simplex_tree_from_cliques_of_graph_2 ${CMAKE_CURRENT_BINARY_DIR}/simplex_tree_from_cliques_of_graph ${CMAKE_SOURCE_DIR}/data/points/Klein_bottle_complex.txt 2) +add_test(simplex_tree_from_cliques_of_graph_3 ${CMAKE_CURRENT_BINARY_DIR}/simplex_tree_from_cliques_of_graph ${CMAKE_SOURCE_DIR}/data/points/Klein_bottle_complex.txt 3) add_executable ( simple_simplex_tree simple_simplex_tree.cpp ) add_test(simple_simplex_tree ${CMAKE_CURRENT_BINARY_DIR}/simple_simplex_tree) diff --git a/src/Simplex_tree/example/simplex_tree_from_cliques_of_graph.cpp b/src/Simplex_tree/example/simplex_tree_from_cliques_of_graph.cpp new file mode 100644 index 00000000..58085014 --- /dev/null +++ b/src/Simplex_tree/example/simplex_tree_from_cliques_of_graph.cpp @@ -0,0 +1,114 @@ +/* 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 . + */ + +#include +#include + +#include +#include +#include + +using namespace Gudhi; + +int main(int argc, char * const argv[]) { + if (argc != 3) { + std::cerr << "Usage: " << argv[0] + << " path_to_file_graph max_dim \n"; + return 0; + } + std::string filegraph = argv[1]; + int max_dim = atoi(argv[2]); + + clock_t start, end; + // Construct the Simplex Tree + Simplex_tree<> st; + + start = clock(); + auto g = read_graph(filegraph); + // insert the graph in the simplex tree as 1-skeleton + st.insert_graph(g); + end = clock(); + std::cout << "Insert the 1-skeleton in the simplex tree in " + << static_cast(end - start) / CLOCKS_PER_SEC << " s. \n"; + + start = clock(); + // expand the 1-skeleton until dimension max_dim + st.expansion(max_dim); + end = clock(); + std::cout << "max_dim = " << max_dim << "\n"; + std::cout << "Expand the simplex tree in " + << static_cast(end - start) / CLOCKS_PER_SEC << " s. \n"; + + std::cout << "Information of the Simplex Tree: " << std::endl; + std::cout << " Number of vertices = " << st.num_vertices() << " "; + std::cout << " Number of simplices = " << st.num_simplices() << std::endl; + std::cout << std::endl << std::endl; + + std::cout << "Iterator on vertices: "; + for (auto vertex : st.complex_vertex_range()) { + std::cout << vertex << " "; + } + + std::cout << std::endl; + + std::cout << std::endl << std::endl; + + std::cout << "Iterator on simplices: " << std::endl; + for (auto simplex : st.complex_simplex_range()) { + std::cout << " "; + for (auto vertex : st.simplex_vertex_range(simplex)) { + std::cout << vertex << " "; + } + std::cout << std::endl; + } + + std::cout << std::endl << std::endl; + + std::cout << "Iterator on Simplices in the filtration, with [filtration value]:" << 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 << vertex << " "; + } + std::cout << std::endl; + } + + std::cout << std::endl << std::endl; + + std::cout << "Iterator on Simplices in the filtration, and their boundary simplices:" << 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 << vertex << " "; + } + std::cout << std::endl; + + for (auto b_simplex : st.boundary_simplex_range(f_simplex)) { + std::cout << " " << "[" << st.filtration(b_simplex) << "] "; + for (auto vertex : st.simplex_vertex_range(b_simplex)) { + std::cout << vertex << " "; + } + std::cout << std::endl; + } + } + return 0; +} diff --git a/src/Simplex_tree/example/simplex_tree_from_file.cpp b/src/Simplex_tree/example/simplex_tree_from_file.cpp deleted file mode 100644 index 58085014..00000000 --- a/src/Simplex_tree/example/simplex_tree_from_file.cpp +++ /dev/null @@ -1,114 +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): 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 . - */ - -#include -#include - -#include -#include -#include - -using namespace Gudhi; - -int main(int argc, char * const argv[]) { - if (argc != 3) { - std::cerr << "Usage: " << argv[0] - << " path_to_file_graph max_dim \n"; - return 0; - } - std::string filegraph = argv[1]; - int max_dim = atoi(argv[2]); - - clock_t start, end; - // Construct the Simplex Tree - Simplex_tree<> st; - - start = clock(); - auto g = read_graph(filegraph); - // insert the graph in the simplex tree as 1-skeleton - st.insert_graph(g); - end = clock(); - std::cout << "Insert the 1-skeleton in the simplex tree in " - << static_cast(end - start) / CLOCKS_PER_SEC << " s. \n"; - - start = clock(); - // expand the 1-skeleton until dimension max_dim - st.expansion(max_dim); - end = clock(); - std::cout << "max_dim = " << max_dim << "\n"; - std::cout << "Expand the simplex tree in " - << static_cast(end - start) / CLOCKS_PER_SEC << " s. \n"; - - std::cout << "Information of the Simplex Tree: " << std::endl; - std::cout << " Number of vertices = " << st.num_vertices() << " "; - std::cout << " Number of simplices = " << st.num_simplices() << std::endl; - std::cout << std::endl << std::endl; - - std::cout << "Iterator on vertices: "; - for (auto vertex : st.complex_vertex_range()) { - std::cout << vertex << " "; - } - - std::cout << std::endl; - - std::cout << std::endl << std::endl; - - std::cout << "Iterator on simplices: " << std::endl; - for (auto simplex : st.complex_simplex_range()) { - std::cout << " "; - for (auto vertex : st.simplex_vertex_range(simplex)) { - std::cout << vertex << " "; - } - std::cout << std::endl; - } - - std::cout << std::endl << std::endl; - - std::cout << "Iterator on Simplices in the filtration, with [filtration value]:" << 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 << vertex << " "; - } - std::cout << std::endl; - } - - std::cout << std::endl << std::endl; - - std::cout << "Iterator on Simplices in the filtration, and their boundary simplices:" << 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 << vertex << " "; - } - std::cout << std::endl; - - for (auto b_simplex : st.boundary_simplex_range(f_simplex)) { - std::cout << " " << "[" << st.filtration(b_simplex) << "] "; - for (auto vertex : st.simplex_vertex_range(b_simplex)) { - std::cout << vertex << " "; - } - std::cout << std::endl; - } - } - return 0; -} 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 52eeaaea..9cdda967 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 @@ -23,12 +23,13 @@ #ifndef SIMPLEX_TREE_SIBLINGS_H_ #define SIMPLEX_TREE_SIBLINGS_H_ +#include + +#include + #include #include -#include "boost/container/flat_map.hpp" -#include "Simplex_tree_node_explicit_storage.h" - namespace Gudhi { /* \addtogroup simplex_tree diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker.h index 289819b5..792a7994 100644 --- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker.h +++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker.h @@ -19,23 +19,24 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -#ifndef SRC_SKELETON_BLOCKER_INCLUDE_GUDHI_SKELETON_BLOCKER_H_ -#define SRC_SKELETON_BLOCKER_INCLUDE_GUDHI_SKELETON_BLOCKER_H_ -#include "gudhi/Skeleton_blocker_complex.h" -#include "gudhi/Skeleton_blocker_geometric_complex.h" -#include "gudhi/Skeleton_blocker_simplifiable_complex.h" -#include "gudhi/Skeleton_blocker/Skeleton_blocker_off_io.h" +#ifndef SKELETON_BLOCKER_H_ +#define SKELETON_BLOCKER_H_ -#include "gudhi/Skeleton_blocker/Skeleton_blocker_simple_traits.h" -#include "gudhi/Skeleton_blocker/Skeleton_blocker_simple_geometric_traits.h" +#include +#include +#include +#include +#include +#include -#include "gudhi/Utils.h" // xxx - +#include // xxx namespace Gudhi { + namespace skbl { + /** \defgroup skbl Skeleton-Blocker \author David Salinas @@ -243,11 +244,9 @@ their collaboration to write the two initial papers \verbatim Contact: David Salinas, david.salinas@inria.fr \endverbatim */ /** @} */ // end defgroup -} // namespace skbl -} // namespace Gudhi - - -#endif // SRC_SKELETON_BLOCKER_INCLUDE_GUDHI_SKELETON_BLOCKER_H_ +} // namespace skbl +} // namespace Gudhi +#endif // SKELETON_BLOCKER_H_ 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 829ab1e8..72bdf4c9 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 @@ -19,10 +19,10 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -#ifndef SRC_SKELETON_BLOCKER_INCLUDE_GUDHI_SKELETON_BLOCKER_SKELETON_BLOCKER_COMPLEX_VISITOR_H_ -#define SRC_SKELETON_BLOCKER_INCLUDE_GUDHI_SKELETON_BLOCKER_SKELETON_BLOCKER_COMPLEX_VISITOR_H_ +#ifndef SKELETON_BLOCKER_SKELETON_BLOCKER_COMPLEX_VISITOR_H_ +#define SKELETON_BLOCKER_SKELETON_BLOCKER_COMPLEX_VISITOR_H_ -#include "gudhi/Skeleton_blocker/Skeleton_blocker_simplex.h" +#include namespace Gudhi { @@ -59,7 +59,7 @@ class Skeleton_blocker_complex_visitor { * remove_edge(b,x) */ virtual void on_swaped_edge(Vertex_handle a, Vertex_handle b, - Vertex_handle x)=0; + Vertex_handle x) = 0; virtual void on_add_blocker( const Skeleton_blocker_simplex&) = 0; virtual void on_delete_blocker( @@ -132,4 +132,4 @@ class Print_complex_visitor : public Skeleton_blocker_complex_visitor< } // namespace Gudhi -#endif // SRC_SKELETON_BLOCKER_INCLUDE_GUDHI_SKELETON_BLOCKER_SKELETON_BLOCKER_COMPLEX_VISITOR_H_ +#endif // SKELETON_BLOCKER_SKELETON_BLOCKER_COMPLEX_VISITOR_H_ 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 17d58956..d39fa9f3 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 @@ -19,10 +19,10 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -#ifndef SRC_SKELETON_BLOCKER_INCLUDE_GUDHI_SKELETON_BLOCKER_SKELETON_BLOCKER_LINK_SUPERIOR_H_ -#define SRC_SKELETON_BLOCKER_INCLUDE_GUDHI_SKELETON_BLOCKER_SKELETON_BLOCKER_LINK_SUPERIOR_H_ +#ifndef SKELETON_BLOCKER_SKELETON_BLOCKER_LINK_SUPERIOR_H_ +#define SKELETON_BLOCKER_SKELETON_BLOCKER_LINK_SUPERIOR_H_ -#include "gudhi/Skeleton_blocker_link_complex.h" +#include namespace Gudhi { @@ -74,4 +74,4 @@ class Skeleton_blocker_link_superior : public Skeleton_blocker_link_complex< } // namespace Gudhi -#endif // SRC_SKELETON_BLOCKER_INCLUDE_GUDHI_SKELETON_BLOCKER_SKELETON_BLOCKER_LINK_SUPERIOR_H_ +#endif // SKELETON_BLOCKER_SKELETON_BLOCKER_LINK_SUPERIOR_H_ 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 6ad1fdd3..ec000986 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 @@ -19,15 +19,15 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -#ifndef SRC_SKELETON_BLOCKER_INCLUDE_GUDHI_SKELETON_BLOCKER_SKELETON_BLOCKER_OFF_IO_H_ -#define SRC_SKELETON_BLOCKER_INCLUDE_GUDHI_SKELETON_BLOCKER_SKELETON_BLOCKER_OFF_IO_H_ +#ifndef SKELETON_BLOCKER_SKELETON_BLOCKER_OFF_IO_H_ +#define SKELETON_BLOCKER_SKELETON_BLOCKER_OFF_IO_H_ + +#include #include #include #include -#include "gudhi/Off_reader.h" - namespace Gudhi { namespace skbl { @@ -197,4 +197,4 @@ class Skeleton_blocker_off_writer { } // namespace Gudhi -#endif // SRC_SKELETON_BLOCKER_INCLUDE_GUDHI_SKELETON_BLOCKER_SKELETON_BLOCKER_OFF_IO_H_ +#endif // SKELETON_BLOCKER_SKELETON_BLOCKER_OFF_IO_H_ diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_simple_geometric_traits.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_simple_geometric_traits.h index d3a5b9d8..8508d9a5 100644 --- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_simple_geometric_traits.h +++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_simple_geometric_traits.h @@ -19,14 +19,14 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -#ifndef SRC_SKELETON_BLOCKER_INCLUDE_GUDHI_SKELETON_BLOCKER_SKELETON_BLOCKER_SIMPLE_GEOMETRIC_TRAITS_H_ -#define SRC_SKELETON_BLOCKER_INCLUDE_GUDHI_SKELETON_BLOCKER_SKELETON_BLOCKER_SIMPLE_GEOMETRIC_TRAITS_H_ +#ifndef SKELETON_BLOCKER_SKELETON_BLOCKER_SIMPLE_GEOMETRIC_TRAITS_H_ +#define SKELETON_BLOCKER_SKELETON_BLOCKER_SIMPLE_GEOMETRIC_TRAITS_H_ + +#include #include #include -#include "gudhi/Skeleton_blocker/Skeleton_blocker_simple_traits.h" - namespace Gudhi { namespace skbl { @@ -91,4 +91,4 @@ struct Skeleton_blocker_simple_geometric_traits : } // namespace Gudhi -#endif // SRC_SKELETON_BLOCKER_INCLUDE_GUDHI_SKELETON_BLOCKER_SKELETON_BLOCKER_SIMPLE_GEOMETRIC_TRAITS_H_ +#endif // SKELETON_BLOCKER_SKELETON_BLOCKER_SIMPLE_GEOMETRIC_TRAITS_H_ diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_simple_traits.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_simple_traits.h index 52e454ea..10d552ec 100644 --- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_simple_traits.h +++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_simple_traits.h @@ -19,12 +19,13 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -#ifndef SRC_SKELETON_BLOCKER_INCLUDE_GUDHI_SKELETON_BLOCKER_SKELETON_BLOCKER_SIMPLE_TRAITS_H_ -#define SRC_SKELETON_BLOCKER_INCLUDE_GUDHI_SKELETON_BLOCKER_SKELETON_BLOCKER_SIMPLE_TRAITS_H_ +#ifndef SKELETON_BLOCKER_SKELETON_BLOCKER_SIMPLE_TRAITS_H_ +#define SKELETON_BLOCKER_SKELETON_BLOCKER_SIMPLE_TRAITS_H_ + +#include #include #include -#include "Skeleton_blocker_simplex.h" namespace Gudhi { @@ -77,7 +78,7 @@ struct Skeleton_blocker_simple_traits { : vertex(val) { } - operator int() const { return (int)vertex; } + operator int() const { return static_cast(vertex); } boost_vertex_handle vertex; 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 0a2fcb9a..0d838d50 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 @@ -20,8 +20,8 @@ * along with this program. If not, see . */ -#ifndef SRC_SKELETON_BLOCKER_INCLUDE_GUDHI_SKELETON_BLOCKER_SKELETON_BLOCKER_SIMPLEX_H_ -#define SRC_SKELETON_BLOCKER_INCLUDE_GUDHI_SKELETON_BLOCKER_SKELETON_BLOCKER_SIMPLEX_H_ +#ifndef SKELETON_BLOCKER_SKELETON_BLOCKER_SIMPLEX_H_ +#define SKELETON_BLOCKER_SKELETON_BLOCKER_SIMPLEX_H_ #include #include @@ -371,5 +371,4 @@ class Skeleton_blocker_simplex { } // namespace Gudhi -#endif // SRC_SKELETON_BLOCKER_INCLUDE_GUDHI_SKELETON_BLOCKER_SKELETON_BLOCKER_SIMPLEX_H_ - +#endif // SKELETON_BLOCKER_SKELETON_BLOCKER_SIMPLEX_H_ 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 40e26c68..b33b9606 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 @@ -20,16 +20,16 @@ * along with this program. If not, see . */ -#ifndef SRC_SKELETON_BLOCKER_INCLUDE_GUDHI_SKELETON_BLOCKER_SKELETON_BLOCKER_SUB_COMPLEX_H_ -#define SRC_SKELETON_BLOCKER_INCLUDE_GUDHI_SKELETON_BLOCKER_SKELETON_BLOCKER_SUB_COMPLEX_H_ +#ifndef SKELETON_BLOCKER_SKELETON_BLOCKER_SUB_COMPLEX_H_ +#define SKELETON_BLOCKER_SKELETON_BLOCKER_SUB_COMPLEX_H_ + +#include +#include +#include #include #include -#include "gudhi/Skeleton_blocker_complex.h" -#include "gudhi/Skeleton_blocker/Skeleton_blocker_simplex.h" -#include "gudhi/Utils.h" - namespace Gudhi { namespace skbl { @@ -75,7 +75,6 @@ class Skeleton_blocker_sub_complex : public ComplexType { typedef typename ComplexType::Root_simplex_handle Root_simplex_handle; protected: - /** * @brief Determines whether all proper faces of simplex 'sigma' belong to 'link1' \cup 'link2' * where 'link1' and 'link2' are subcomplexes of the same complex of type ComplexType @@ -287,5 +286,5 @@ bool proper_faces_in_union( } // namespace Gudhi -#endif // SRC_SKELETON_BLOCKER_INCLUDE_GUDHI_SKELETON_BLOCKER_SKELETON_BLOCKER_SUB_COMPLEX_H_ +#endif // SKELETON_BLOCKER_SKELETON_BLOCKER_SUB_COMPLEX_H_ diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/internal/Top_faces.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/internal/Top_faces.h index 32538f38..eb970195 100644 --- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/internal/Top_faces.h +++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/internal/Top_faces.h @@ -1,67 +1,70 @@ - /* 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 TOP_FACES_H_ -#define TOP_FACES_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 SKELETON_BLOCKER_INTERNAL_TOP_FACES_H_ +#define SKELETON_BLOCKER_INTERNAL_TOP_FACES_H_ #include #include #include +namespace Gudhi { + +namespace skbl { + template -std::list subfaces(SimplexHandle top_face){ - std::list res; - if(top_face.dimension()==-1) return res; - if(top_face.dimension()==0) { - res.push_back(top_face); - return res; - } - else{ - auto first_vertex = top_face.first_vertex(); - top_face.remove_vertex(first_vertex); - res = subfaces(top_face); - std::list copy = res; - for(auto& simplex : copy){ - simplex.add_vertex(first_vertex); - } - res.push_back(SimplexHandle(first_vertex)); - res.splice(res.end(),copy); - return res; - } +std::list subfaces(SimplexHandle top_face) { + std::list res; + if (top_face.dimension() == -1) return res; + if (top_face.dimension() == 0) { + res.push_back(top_face); + return res; + } else { + auto first_vertex = top_face.first_vertex(); + top_face.remove_vertex(first_vertex); + res = subfaces(top_face); + std::list copy = res; + for (auto& simplex : copy) { + simplex.add_vertex(first_vertex); + } + res.push_back(SimplexHandle(first_vertex)); + res.splice(res.end(), copy); + return res; + } } /** * add all faces of top_face in simplices_per_dimension */ template -void register_faces( - std::vector< std::set >& simplices_per_dimension, - const SimplexHandle& top_face){ - std::list subfaces_list = subfaces(top_face); - for(auto& simplex : subfaces_list ){ - simplices_per_dimension[simplex.dimension()].insert(simplex); - } +void register_faces(std::vector< std::set >& simplices_per_dimension, + const SimplexHandle& top_face) { + std::list subfaces_list = subfaces(top_face); + for (auto& simplex : subfaces_list) { + simplices_per_dimension[simplex.dimension()].insert(simplex); + } } +} // namespace skbl +} // namespace Gudhi - -#endif /* TOP_FACES_H_ */ +#endif // SKELETON_BLOCKER_INTERNAL_TOP_FACES_H_ 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 f2a443dc..aa0416ef 100644 --- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/internal/Trie.h +++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/internal/Trie.h @@ -1,13 +1,10 @@ -/* - * Trie.h - * Created on: Jan 29, 2015 - * This file is part of the Gudhi Library. The Gudhi library +/* 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-Méditerranée (France) + * 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 @@ -25,8 +22,8 @@ */ -#ifndef TRIE_H_ -#define TRIE_H_ +#ifndef SKELETON_BLOCKER_INTERNAL_TRIE_H_ +#define SKELETON_BLOCKER_INTERNAL_TRIE_H_ #include #include @@ -35,242 +32,237 @@ namespace Gudhi { - namespace skbl { - template -struct Trie{ - typedef SimplexHandle Simplex_handle; - typedef typename SimplexHandle::Vertex_handle Vertex_handle; - - Vertex_handle v; - std::vector > childs; - //std::vector > childs; -> use of deleted function -private: - const Trie* parent_; -public: - Trie():parent_(0){} - Trie(Vertex_handle v_):v(v_),parent_(0){} - - Trie(Vertex_handle v_,Trie* parent):v(v_),parent_(parent){} - - - bool operator==(const Trie& other) const{ - return (v == other.v) ; - } - - void add_child(Trie* child){ - if(child){ - std::shared_ptr ptr_to_add(child); - childs.push_back(ptr_to_add); - child->parent_ = this; - } - } - - typedef typename Simplex_handle::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) return 0; - else{ - Trie* res = new Trie(*s_it); - Trie* child = make_trie(++s_it,s_end); - res->add_child(child); - return res; - } - } -private: - //go down recursively in the tree while advancing the simplex iterator. - //when it reaches a leaf, it inserts the remaining that is not present - void add_simplex_helper(Simplex_vertex_const_iterator s_it,Simplex_vertex_const_iterator s_end){ - assert(*s_it == v); - ++s_it; - if(s_it==s_end) return ; - if(!is_leaf()){ - for(auto child : childs){ - if(child->v == *s_it) - return child->add_simplex_helper(s_it,s_end); - } - //s_it is not found and needs to be inserted - } - //not leaf -> remaining of s needs to be inserted - Trie* son_with_what_remains_of_s(make_trie(s_it,s_end)); - add_child(son_with_what_remains_of_s); - return; - } - - void maximal_faces_helper(std::vector& res) const{ - if(is_leaf()) res.push_back(simplex()); - else - for(auto child : childs) - child->maximal_faces_helper(res); - } - -public: - /** - * adds the simplex to the trie - */ - void add_simplex(const Simplex_handle& s){ - if(s.empty()) return; - assert(v==s.first_vertex()); - add_simplex_helper(s.begin(),s.end()); - } - - std::vector maximal_faces() const{ - std::vector res; - maximal_faces_helper(res); - return res; - } - - /** - * Goes to the root in the trie to consitute simplex - */ - void add_vertices_up_to_the_root(Simplex_handle& res) const{ - res.add_vertex(v); - if(parent_) - parent_->add_vertices_up_to_the_root(res); - } - - Simplex_handle simplex() const{ - Simplex_handle res; - add_vertices_up_to_the_root(res); - return res; - } - - bool is_leaf() const{ - return childs.empty(); - } - - bool is_root() const{ - return parent_==0; - } - - const Trie* parent() { - return parent_; - } - - void remove_leaf() { - assert(is_leaf); - if(!is_root()) - parent_->childs.erase(this); - } - - /** - * true iff the simplex corresponds to one node in the trie - */ - bool contains(const Simplex_handle& s) const{ - Trie const* current = this; - if(s.empty()) return true; - if(current->v != s.first_vertex()) return false; - auto s_pos = s.begin(); - ++s_pos; - while(s_pos != s.end() && current != 0){ - bool found = false; - for(const auto child : current->childs){ - if(child->v == *s_pos) { - ++s_pos; - current = child.get(); - found = true; - break; - } - } - if(!found) return false; - } - return current!=0; - } - - Trie* go_bottom_left(){ - if(is_leaf()) - return this; - else - return (*childs.begin())->go_bottom_left(); - } - - friend std::ostream& operator<<(std::ostream& stream, const Trie& trie){ - stream<< "T( "<< trie.v<< " "; - for(auto t : trie.childs) - stream << *t ; - stream<<")"; - return stream; - } +struct Trie { + typedef SimplexHandle Simplex_handle; + typedef typename SimplexHandle::Vertex_handle Vertex_handle; + + Vertex_handle v; + std::vector > childs; + // std::vector > childs; -> use of deleted function + private: + const Trie* parent_; + + public: + Trie() : parent_(0) { } + + Trie(Vertex_handle v_) : v(v_), parent_(0) { } + + Trie(Vertex_handle v_, Trie* parent) : v(v_), parent_(parent) { } + + bool operator==(const Trie& other) const { + return (v == other.v); + } + + void add_child(Trie* child) { + if (child) { + std::shared_ptr ptr_to_add(child); + childs.push_back(ptr_to_add); + child->parent_ = this; + } + } + + typedef typename Simplex_handle::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) { + return 0; + } else { + Trie* res = new Trie(*s_it); + Trie* child = make_trie(++s_it, s_end); + res->add_child(child); + return res; + } + } + + private: + // go down recursively in the tree while advancing the simplex iterator. + // when it reaches a leaf, it inserts the remaining that is not present + void add_simplex_helper(Simplex_vertex_const_iterator s_it, Simplex_vertex_const_iterator s_end) { + assert(*s_it == v); + ++s_it; + if (s_it == s_end) return; + if (!is_leaf()) { + for (auto child : childs) { + if (child->v == *s_it) + return child->add_simplex_helper(s_it, s_end); + } + // s_it is not found and needs to be inserted + } + // not leaf -> remaining of s needs to be inserted + Trie * son_with_what_remains_of_s(make_trie(s_it, s_end)); + add_child(son_with_what_remains_of_s); + return; + } + + void maximal_faces_helper(std::vector& res) const { + if (is_leaf()) res.push_back(simplex()); + else + for (auto child : childs) + child->maximal_faces_helper(res); + } + + public: + /** + * adds the simplex to the trie + */ + void add_simplex(const Simplex_handle& s) { + if (s.empty()) return; + assert(v == s.first_vertex()); + add_simplex_helper(s.begin(), s.end()); + } + + std::vector maximal_faces() const { + std::vector res; + maximal_faces_helper(res); + return res; + } + + /** + * Goes to the root in the trie to consitute simplex + */ + void add_vertices_up_to_the_root(Simplex_handle& res) const { + res.add_vertex(v); + if (parent_) + parent_->add_vertices_up_to_the_root(res); + } + + Simplex_handle simplex() const { + Simplex_handle res; + add_vertices_up_to_the_root(res); + return res; + } + + bool is_leaf() const { + return childs.empty(); + } + + bool is_root() const { + return parent_ == 0; + } + + const Trie* parent() { + return parent_; + } + + void remove_leaf() { + assert(is_leaf); + if (!is_root()) + parent_->childs.erase(this); + } + + /** + * true iff the simplex corresponds to one node in the trie + */ + bool contains(const Simplex_handle& s) const { + Trie const* current = this; + if (s.empty()) return true; + if (current->v != s.first_vertex()) return false; + auto s_pos = s.begin(); + ++s_pos; + while (s_pos != s.end() && current != 0) { + bool found = false; + for (const auto child : current->childs) { + if (child->v == *s_pos) { + ++s_pos; + current = child.get(); + found = true; + break; + } + } + if (!found) return false; + } + return current != 0; + } + + Trie* go_bottom_left() { + if (is_leaf()) + return this; + else + return (*childs.begin())->go_bottom_left(); + } + + friend std::ostream& operator<<(std::ostream& stream, const Trie& trie) { + stream << "T( " << trie.v << " "; + for (auto t : trie.childs) + stream << *t; + stream << ")"; + return stream; + } }; - template -struct Tries{ - typedef typename SimplexHandle::Vertex_handle Vertex_handle; - typedef SimplexHandle Simplex_handle; - - typedef Trie STrie; - - - template - Tries(unsigned num_vertices,SimpleHandleOutputIterator simplex_begin, SimpleHandleOutputIterator simplex_end): - cofaces_(num_vertices,0){ - for (auto i = 0u; i < num_vertices; ++i) - cofaces_[i] = new STrie(Vertex_handle(i)); - for (auto s_it = simplex_begin; s_it != simplex_end; ++s_it) { - if (s_it->dimension() >= 1) - cofaces_[s_it->first_vertex()]->add_simplex(*s_it); - } - } - - ~Tries(){ - for(STrie* t : cofaces_) - delete t; - } - - //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; - for(auto child : cofaces_[v]->childs) - res.add_vertex(child->v); - return res; - } - - bool contains(const Simplex_handle& s) const{ - auto first_v = s.first_vertex(); - return cofaces_[first_v]->contains(s); - } - - friend std::ostream& operator<<(std::ostream& stream, const Tries& tries){ - for(auto trie : tries.cofaces_) - stream<<*trie< next_dimension_simplices() const{ - std::vector 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) - to_see_.push_back(child.get()); - to_see_.pop_front(); - } - ++current_dimension_; - return res; - } - - void init_next_dimension() const{ - for(auto trie : cofaces_) - to_see_.push_back(trie); - } - -private: - mutable std::deque to_see_; - mutable unsigned current_dimension_=0; - - - std::vector cofaces_; - +struct Tries { + typedef typename SimplexHandle::Vertex_handle Vertex_handle; + typedef SimplexHandle Simplex_handle; + + typedef Trie STrie; + + template + Tries(unsigned num_vertices, SimpleHandleOutputIterator simplex_begin, SimpleHandleOutputIterator simplex_end) : + cofaces_(num_vertices, 0) { + for (auto i = 0u; i < num_vertices; ++i) + cofaces_[i] = new STrie(Vertex_handle(i)); + for (auto s_it = simplex_begin; s_it != simplex_end; ++s_it) { + if (s_it->dimension() >= 1) + cofaces_[s_it->first_vertex()]->add_simplex(*s_it); + } + } + + ~Tries() { + for (STrie* t : cofaces_) + delete t; + } + + // 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; + for (auto child : cofaces_[v]->childs) + res.add_vertex(child->v); + return res; + } + + bool contains(const Simplex_handle& s) const { + auto first_v = s.first_vertex(); + return cofaces_[first_v]->contains(s); + } + + friend std::ostream& operator<<(std::ostream& stream, const Tries& tries) { + for (auto trie : tries.cofaces_) + stream << *trie << std::endl; + return stream; + } + + // init_next_dimension must be called first + + std::vector next_dimension_simplices() const { + std::vector 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) + to_see_.push_back(child.get()); + to_see_.pop_front(); + } + ++current_dimension_; + return res; + } + + void init_next_dimension() const { + for (auto trie : cofaces_) + to_see_.push_back(trie); + } + + private: + mutable std::deque to_see_; + mutable unsigned current_dimension_ = 0; + std::vector cofaces_; }; +} // namespace skbl +} // namespace Gudhi -} - -} - -#endif /* TRIE_H_ */ +#endif // SKELETON_BLOCKER_INTERNAL_TRIE_H_ 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 f6f2c955..56a20a24 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 @@ -1,134 +1,131 @@ - /* 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_SKELETON_BLOCKERS_BLOCKERS_ITERATORS_H_ -#define GUDHI_SKELETON_BLOCKERS_BLOCKERS_ITERATORS_H_ - -#include "boost/iterator/iterator_facade.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 SKELETON_BLOCKER_ITERATORS_SKELETON_BLOCKERS_BLOCKERS_ITERATORS_H_ +#define SKELETON_BLOCKER_ITERATORS_SKELETON_BLOCKERS_BLOCKERS_ITERATORS_H_ + +#include + +namespace Gudhi { namespace skbl { /** * @brief Iterator through the blockers of a vertex. - */ + */ // ReturnType = const Simplex_handle* or Simplex_handle* // MapIteratorType = BlockerMapConstIterator or BlockerMapIterator + template class Blocker_iterator_internal : public boost::iterator_facade< - Blocker_iterator_internal, - ReturnType, - boost::forward_traversal_tag, - ReturnType - >{ -private: - MapIteratorType current_position; - MapIteratorType end_of_map; -public: - - Blocker_iterator_internal():current_position(){} - - Blocker_iterator_internal(MapIteratorType position,MapIteratorType end_of_map_ ): - current_position(position), end_of_map(end_of_map_) - { } - - bool equal(const Blocker_iterator_internal& other) const{ - return current_position == other.current_position; - } - - void increment(){ - goto_next_blocker(); - } - - ReturnType dereference() const { - return(current_position->second); - } - -private: - /** - * Let the current pair be (v,sigma) where v is a vertex and sigma is a blocker. - * If v is not the first vertex of sigma then we already have seen sigma as a blocker - * and we look for the next one. - */ - void goto_next_blocker(){ - do { - ++current_position; - } while (!(current_position == end_of_map) && !first_time_blocker_is_seen()); - } - - bool first_time_blocker_is_seen() const{ - return current_position->first == current_position->second->first_vertex(); - } +Blocker_iterator_internal, +ReturnType, +boost::forward_traversal_tag, +ReturnType +> { + private: + MapIteratorType current_position; + MapIteratorType end_of_map; + + public: + Blocker_iterator_internal() : current_position() { } + + Blocker_iterator_internal(MapIteratorType position, MapIteratorType end_of_map_) : + current_position(position), end_of_map(end_of_map_) { } + + bool equal(const Blocker_iterator_internal& other) const { + return current_position == other.current_position; + } + + void increment() { + goto_next_blocker(); + } + + ReturnType dereference() const { + return (current_position->second); + } + + private: + /** + * Let the current pair be (v,sigma) where v is a vertex and sigma is a blocker. + * If v is not the first vertex of sigma then we already have seen sigma as a blocker + * and we look for the next one. + */ + void goto_next_blocker() { + do { + ++current_position; + } while (!(current_position == end_of_map) && !first_time_blocker_is_seen()); + } + + bool first_time_blocker_is_seen() const { + return current_position->first == current_position->second->first_vertex(); + } }; - - /** * @brief Iterator through the blockers of a vertex */ // ReturnType = const Simplex_handle* or Simplex_handle* // MapIteratorType = BlockerMapConstIterator or BlockerMapIterator + template class Blocker_iterator_around_vertex_internal : public boost::iterator_facade< - Blocker_iterator_around_vertex_internal, - ReturnType, - boost::forward_traversal_tag, - ReturnType ->{ -private: - MapIteratorType current_position_; -public: - - Blocker_iterator_around_vertex_internal():current_position_(){} - - Blocker_iterator_around_vertex_internal(MapIteratorType position): - current_position_(position) - {} - - Blocker_iterator_around_vertex_internal& operator=(Blocker_iterator_around_vertex_internal other){ - this->current_position_ = other.current_position_; - return *this; - } - - bool equal(const Blocker_iterator_around_vertex_internal& other) const{ - return current_position_ == other.current_position_; - } - - void increment(){ - current_position_++; - } - - ReturnType dereference() const{ - return(current_position_->second); - } - - - MapIteratorType current_position(){ - return this->current_position_; - } +Blocker_iterator_around_vertex_internal, +ReturnType, +boost::forward_traversal_tag, +ReturnType +> { + private: + MapIteratorType current_position_; + + public: + Blocker_iterator_around_vertex_internal() : current_position_() { } + + Blocker_iterator_around_vertex_internal(MapIteratorType position) : + current_position_(position) { } + + Blocker_iterator_around_vertex_internal& operator=(Blocker_iterator_around_vertex_internal other) { + this->current_position_ = other.current_position_; + return *this; + } + + bool equal(const Blocker_iterator_around_vertex_internal& other) const { + return current_position_ == other.current_position_; + } + + void increment() { + current_position_++; + } + + ReturnType dereference() const { + return (current_position_->second); + } + + MapIteratorType current_position() { + return this->current_position_; + } }; -} +} // namespace skbl -} // namespace GUDHI +} // namespace Gudhi -#endif /* GUDHI_SKELETON_BLOCKERS_BLOCKERS_ITERATORS_H_ */ +#endif // SKELETON_BLOCKER_ITERATORS_SKELETON_BLOCKERS_BLOCKERS_ITERATORS_H_ diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_edges_iterators.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_edges_iterators.h index 0be6c74d..ef4c7970 100644 --- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_edges_iterators.h +++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_edges_iterators.h @@ -1,167 +1,144 @@ - /* 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_SKELETON_BLOCKERS_ITERATORS_EDGES_H_ -#define GUDHI_SKELETON_BLOCKERS_ITERATORS_EDGES_H_ - -#include "boost/iterator/iterator_facade.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 SKELETON_BLOCKER_ITERATORS_SKELETON_BLOCKERS_EDGES_ITERATORS_H_ +#define SKELETON_BLOCKER_ITERATORS_SKELETON_BLOCKERS_EDGES_ITERATORS_H_ + +#include +#include + +#include // for pair<> + +namespace Gudhi { namespace skbl { template -class Edge_around_vertex_iterator : - public boost::iterator_facade < Edge_around_vertex_iterator - , typename SkeletonBlockerComplex::Edge_handle const - , boost::forward_traversal_tag - , typename SkeletonBlockerComplex::Edge_handle const - > -{ - friend class boost::iterator_core_access; - - typedef SkeletonBlockerComplex Complex; - typedef typename Complex::boost_adjacency_iterator boost_adjacency_iterator; - typedef typename Complex::Vertex_handle Vertex_handle; - typedef typename Complex::Edge_handle Edge_handle; - -private: - - const Complex* complex; - Vertex_handle v; - - boost_adjacency_iterator current_; - boost_adjacency_iterator end_; - -public: - - Edge_around_vertex_iterator():complex(NULL){ - } - - Edge_around_vertex_iterator(const Complex* complex_,Vertex_handle v_): - complex(complex_), - v(v_) - { - tie(current_,end_) = adjacent_vertices(v.vertex, complex->skeleton); - } - - /** - * returns an iterator to the end - */ - Edge_around_vertex_iterator(const Complex* complex_,Vertex_handle v_,int end): - complex(complex_), - v(v_) - { - tie(current_,end_) = adjacent_vertices(v.vertex, complex->skeleton); - set_end(); - } - - bool equal(const Edge_around_vertex_iterator& other) const{ - return (complex== other.complex) && (v == other.v) && (current_ == other.current_) && (end_ == other.end_); - } - - void increment(){ - if(current_ != end_) - ++current_; - } - - Edge_handle dereference() const{ - return *(*complex)[std::make_pair(v,static_cast(*current_))]; - } - -private: - //remove this ugly hack - void set_end(){ - current_ = end_; - } +class Edge_around_vertex_iterator : public boost::iterator_facade +, typename SkeletonBlockerComplex::Edge_handle const, boost::forward_traversal_tag +, typename SkeletonBlockerComplex::Edge_handle const> { + friend class boost::iterator_core_access; + + typedef SkeletonBlockerComplex Complex; + typedef typename Complex::boost_adjacency_iterator boost_adjacency_iterator; + typedef typename Complex::Vertex_handle Vertex_handle; + typedef typename Complex::Edge_handle Edge_handle; + + private: + const Complex* complex; + Vertex_handle v; + + boost_adjacency_iterator current_; + boost_adjacency_iterator end_; + + public: + Edge_around_vertex_iterator() : complex(NULL) { } + + Edge_around_vertex_iterator(const Complex* complex_, Vertex_handle v_) : + complex(complex_), + v(v_) { + tie(current_, end_) = adjacent_vertices(v.vertex, complex->skeleton); + } + + /** + * returns an iterator to the end + */ + Edge_around_vertex_iterator(const Complex* complex_, Vertex_handle v_, int end) : + complex(complex_), + v(v_) { + tie(current_, end_) = adjacent_vertices(v.vertex, complex->skeleton); + set_end(); + } + + bool equal(const Edge_around_vertex_iterator& other) const { + return (complex == other.complex) && (v == other.v) && (current_ == other.current_) && (end_ == other.end_); + } + + void increment() { + if (current_ != end_) + ++current_; + } + + Edge_handle dereference() const { + return *(*complex)[std::make_pair(v, static_cast (*current_))]; + } + + private: + // remove this ugly hack + void set_end() { + current_ = end_; + } }; - - /** *@brief Iterator on the edges of a simplicial complex. * */ template -class Edge_iterator : -public boost::iterator_facade < Edge_iterator +class Edge_iterator : public boost::iterator_facade , typename SkeletonBlockerComplex::Edge_handle const , boost::forward_traversal_tag -, typename SkeletonBlockerComplex::Edge_handle const -> - -{ - friend class boost::iterator_core_access; -public: - typedef SkeletonBlockerComplex Complex; - typedef typename Complex::boost_edge_iterator boost_edge_iterator; - typedef typename Complex::Edge_handle Edge_handle; - - - const Complex* complex; - std::pair edge_iterator ; - - Edge_iterator():complex(NULL){ - } - - Edge_iterator(const SkeletonBlockerComplex* complex_): - complex(complex_), - edge_iterator(boost::edges(complex_->skeleton)) - { - } - - /** - * return an iterator to the end - */ - Edge_iterator(const SkeletonBlockerComplex* complex_,int end): - complex(complex_), - edge_iterator(boost::edges(complex_->skeleton)) - { - edge_iterator.first = edge_iterator.second; - } - - - bool equal(const Edge_iterator& other) const{ - return (complex == other.complex) && (edge_iterator == other.edge_iterator); - } - - void increment(){ - if(edge_iterator.first != edge_iterator.second){ - ++(edge_iterator.first); - } - } - - Edge_handle dereference() const{ - return(*(edge_iterator.first)); - } +, typename SkeletonBlockerComplex::Edge_handle const> { + friend class boost::iterator_core_access; + + public: + typedef SkeletonBlockerComplex Complex; + typedef typename Complex::boost_edge_iterator boost_edge_iterator; + typedef typename Complex::Edge_handle Edge_handle; + + const Complex* complex; + std::pair edge_iterator; + + Edge_iterator() : complex(NULL) { } + + Edge_iterator(const SkeletonBlockerComplex* complex_) : + complex(complex_), + edge_iterator(boost::edges(complex_->skeleton)) { } + + /** + * return an iterator to the end + */ + Edge_iterator(const SkeletonBlockerComplex* complex_, int end) : + complex(complex_), + edge_iterator(boost::edges(complex_->skeleton)) { + edge_iterator.first = edge_iterator.second; + } + + bool equal(const Edge_iterator& other) const { + return (complex == other.complex) && (edge_iterator == other.edge_iterator); + } + + void increment() { + if (edge_iterator.first != edge_iterator.second) { + ++(edge_iterator.first); + } + } + + Edge_handle dereference() const { + return (*(edge_iterator.first)); + } }; +} // namespace skbl +} // namespace Gudhi -} - -} // namespace GUDHI - - -#endif /* GUDHI_SKELETON_BLOCKERS_ITERATORS_EDGES_H_ */ - - +#endif // SKELETON_BLOCKER_ITERATORS_SKELETON_BLOCKERS_EDGES_ITERATORS_H_ diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_iterators.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_iterators.h index 20a94734..cc3ed276 100644 --- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_iterators.h +++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_iterators.h @@ -19,17 +19,14 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -#ifndef GUDHI_SKELETON_BLOCKERS_ITERATORS_H_ -#define GUDHI_SKELETON_BLOCKERS_ITERATORS_H_ +#ifndef SKELETON_BLOCKER_ITERATORS_SKELETON_BLOCKERS_ITERATORS_H_ +#define SKELETON_BLOCKER_ITERATORS_SKELETON_BLOCKERS_ITERATORS_H_ -#include "Skeleton_blockers_vertices_iterators.h" -#include "Skeleton_blockers_edges_iterators.h" -#include "Skeleton_blockers_blockers_iterators.h" -#include "Skeleton_blockers_triangles_iterators.h" -#include "Skeleton_blockers_simplices_iterators.h" +#include +#include +#include +#include +#include - - - -#endif /* GUDHI_SKELETON_BLOCKERS_ITERATORS_H_ */ +#endif // SKELETON_BLOCKER_ITERATORS_SKELETON_BLOCKERS_ITERATORS_H_ 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 f9d4d072..4d71b3f5 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 @@ -19,20 +19,20 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -#ifndef GUDHI_SKELETON_BLOCKERS_SIMPLICES_ITERATORS_H_ -#define GUDHI_SKELETON_BLOCKERS_SIMPLICES_ITERATORS_H_ +#ifndef SKELETON_BLOCKER_ITERATORS_SKELETON_BLOCKERS_SIMPLICES_ITERATORS_H_ +#define SKELETON_BLOCKER_ITERATORS_SKELETON_BLOCKERS_SIMPLICES_ITERATORS_H_ -#include "boost/iterator/iterator_facade.hpp" +#include +#include +#include +#include + +#include #include #include #include -#include "gudhi/Skeleton_blocker_link_complex.h" -#include "gudhi/Skeleton_blocker/Skeleton_blocker_link_superior.h" -#include "gudhi/Skeleton_blocker/internal/Trie.h" -#include "gudhi/Utils.h" - namespace Gudhi { namespace skbl { @@ -68,7 +68,7 @@ public boost::iterator_facade < Simplex_around_vertex_iterator link_v; std::shared_ptr trie; - std::list nodes_to_be_seen; // todo deque + std::list nodes_to_be_seen; // todo deque public: Simplex_around_vertex_iterator() : complex(0) {} @@ -159,7 +159,7 @@ public boost::iterator_facade < Simplex_around_vertex_iteratorchilds) { nodes_to_be_seen.push_back(childs.get()); } - } Simplex_handle dereference() const { @@ -309,4 +308,4 @@ public boost::iterator_facade < Simplex_iterator } // namespace Gudhi -#endif // GUDHI_SKELETON_BLOCKERS_SIMPLICES_ITERATORS_H_ +#endif // SKELETON_BLOCKER_ITERATORS_SKELETON_BLOCKERS_SIMPLICES_ITERATORS_H_ 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 e137d1ea..28f5805d 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 @@ -1,117 +1,108 @@ - /* 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_SKELETON_BLOCKERS_TRIANGLES_ITERATORS_H_ -#define GUDHI_SKELETON_BLOCKERS_TRIANGLES_ITERATORS_H_ - -#include "boost/iterator/iterator_facade.hpp" +/* 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 SKELETON_BLOCKER_ITERATORS_SKELETON_BLOCKERS_TRIANGLES_ITERATORS_H_ +#define SKELETON_BLOCKER_ITERATORS_SKELETON_BLOCKERS_TRIANGLES_ITERATORS_H_ + +#include #include -namespace Gudhi{ +namespace Gudhi { namespace skbl { -////////////////////////////////////////////////////////////////////// /** * \brief Iterator over the triangles that are * adjacent to a vertex of the simplicial complex. * \remark Will be removed soon -> dont look */ -template +template class Triangle_around_vertex_iterator : public boost::iterator_facade -< Triangle_around_vertex_iterator +< Triangle_around_vertex_iterator , typename Complex::Simplex_handle const , boost::forward_traversal_tag -, typename Complex::Simplex_handle const -> -{ - friend class boost::iterator_core_access; - template 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 Complex::Complex_edge_iterator Complex_edge_iterator_; - - const Complex* complex_; - Vertex_handle v_; - std::shared_ptr link_; - Complex_edge_iterator_ current_edge_; - bool is_end_; -public: - Triangle_around_vertex_iterator(const Complex* complex,Vertex_handle v): - complex_(complex),v_(v),link_(new LinkType(*complex,v_)), - current_edge_(link_->edge_range().begin()), - is_end_(current_edge_ == link_->edge_range().end()){ - } - - /** - * @brief ugly hack to get an iterator to the end - */ - Triangle_around_vertex_iterator(const Complex* complex,Vertex_handle v,bool is_end): - complex_(complex),v_(v),link_(0),is_end_(true){ - } - - /** - * @brief ugly hack to get an iterator to the end - */ - Triangle_around_vertex_iterator(): - complex_(0),v_(-1),link_(0),is_end_(true){ - } - - - Triangle_around_vertex_iterator(const Triangle_around_vertex_iterator& other){ - v_ = other.v_; - complex_ = other.complex_; - is_end_ = other.is_end_; - - if(!is_end_){ - link_ = other.link_; - current_edge_= other.current_edge_; - } - } - - bool equal(const Triangle_around_vertex_iterator& other) const{ - return (complex_==other.complex_) && ((finished() &&other.finished()) || current_edge_ == other.current_edge_); - } - - Simplex_handle 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))); - } - - void increment(){ - ++current_edge_; - } - -private: - bool finished() const{ - return is_end_ || (current_edge_ == link_->edge_range().end()); - } - +, typename Complex::Simplex_handle const> { + friend class boost::iterator_core_access; + template 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 Complex::Complex_edge_iterator Complex_edge_iterator_; + + const Complex* complex_; + Vertex_handle v_; + std::shared_ptr link_; + Complex_edge_iterator_ current_edge_; + bool is_end_; + + public: + Triangle_around_vertex_iterator(const Complex* complex, Vertex_handle v) : + complex_(complex), v_(v), link_(new LinkType(*complex, v_)), + current_edge_(link_->edge_range().begin()), + is_end_(current_edge_ == link_->edge_range().end()) { } + + /** + * @brief ugly hack to get an iterator to the end + */ + Triangle_around_vertex_iterator(const Complex* complex, Vertex_handle v, bool is_end) : + complex_(complex), v_(v), link_(0), is_end_(true) { } + + /** + * @brief ugly hack to get an iterator to the end + */ + Triangle_around_vertex_iterator() : + complex_(0), v_(-1), link_(0), is_end_(true) { } + + Triangle_around_vertex_iterator(const Triangle_around_vertex_iterator& other) { + v_ = other.v_; + complex_ = other.complex_; + is_end_ = other.is_end_; + + if (!is_end_) { + link_ = other.link_; + current_edge_ = other.current_edge_; + } + } + + bool equal(const Triangle_around_vertex_iterator& other) const { + return (complex_ == other.complex_) && ((finished() && other.finished()) || current_edge_ == other.current_edge_); + } + + Simplex_handle 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))); + } + + void increment() { + ++current_edge_; + } + + private: + bool finished() const { + return is_end_ || (current_edge_ == link_->edge_range().end()); + } }; - - /** * \brief Iterator over the triangles of the * simplicial complex. @@ -119,121 +110,111 @@ private: * */ template -class Triangle_iterator : - public boost::iterator_facade< - Triangle_iterator , - typename SkeletonBlockerComplex::Simplex_handle const - , boost::forward_traversal_tag - , typename SkeletonBlockerComplex::Simplex_handle 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::Superior_triangle_around_vertex_iterator STAVI; - typedef typename SkeletonBlockerComplex::Complex_vertex_iterator Complex_vertex_iterator; - - const SkeletonBlockerComplex* complex_; - Complex_vertex_iterator current_vertex_; - STAVI current_triangle_; - bool is_end_; -public: - - /* - * @remark assume that the complex is non-empty - */ - Triangle_iterator(const SkeletonBlockerComplex* complex): - complex_(complex), - current_vertex_(complex->vertex_range().begin()), - current_triangle_(complex,*current_vertex_), // xxx this line is problematic is the complex is empty - is_end_(false){ - - assert(!complex->empty()); - gotoFirstTriangle(); - } - -private: - //goto to the first triangle or to the end if none - void gotoFirstTriangle(){ - if(!is_finished() && current_triangle_.finished()){ - goto_next_vertex(); - } - } -public: - - /** - * @brief ugly hack to get an iterator to the end - * @remark assume that the complex is non-empty - */ - Triangle_iterator(const SkeletonBlockerComplex* complex,bool is_end): - complex_(complex), - current_vertex_(complex->vertex_range().end()), - current_triangle_(), // xxx this line is problematic is the complex is empty - is_end_(true){ - } - - - Triangle_iterator& operator=(const Triangle_iterator & other){ - complex_ = other.complex_; - Complex_vertex_iterator current_vertex_; - STAVI current_triangle_; - return *this; - } - - - bool equal(const Triangle_iterator& other) const{ - bool both_are_finished = is_finished() && other.is_finished(); - bool both_arent_finished = !is_finished() && !other.is_finished(); - // if the two iterators are not finished, they must have the same state - return (complex_==other.complex_) && - (both_are_finished || - ( (both_arent_finished) && current_vertex_ == other.current_vertex_ && current_triangle_ == other.current_triangle_)); - - } - - Simplex_handle dereference() const{ - return *current_triangle_; - } - -private: - - // goto the next vertex that has a triangle pending or the - // end vertex iterator if none exists - void goto_next_vertex(){ - assert(current_triangle_.finished()); //we mush have consume all triangles passing through the vertex - assert(!is_finished()); // we must not be done - - ++current_vertex_; - - if(!is_finished()){ - current_triangle_ = STAVI(complex_, *current_vertex_); - if(current_triangle_.finished()) - goto_next_vertex(); - } - } -public: - void increment(){ - if(!current_triangle_.finished()){ - ++current_triangle_; // problem here - if(current_triangle_.finished()) - goto_next_vertex(); - } - else{ - assert(!is_finished()); - goto_next_vertex(); - } - } - -private: - bool is_finished() const{ - return is_end_ || current_vertex_ == complex_->vertex_range().end(); - } +class Triangle_iterator : public boost::iterator_facade< +Triangle_iterator , +typename SkeletonBlockerComplex::Simplex_handle const +, boost::forward_traversal_tag +, typename SkeletonBlockerComplex::Simplex_handle 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::Superior_triangle_around_vertex_iterator STAVI; + typedef typename SkeletonBlockerComplex::Complex_vertex_iterator Complex_vertex_iterator; + + const SkeletonBlockerComplex* complex_; + Complex_vertex_iterator current_vertex_; + STAVI current_triangle_; + bool is_end_; + + public: + /* + * @remark assume that the complex is non-empty + */ + Triangle_iterator(const SkeletonBlockerComplex* complex) : + complex_(complex), + current_vertex_(complex->vertex_range().begin()), + current_triangle_(complex, *current_vertex_), // xxx this line is problematic is the complex is empty + is_end_(false) { + assert(!complex->empty()); + gotoFirstTriangle(); + } + + private: + // goto to the first triangle or to the end if none + void gotoFirstTriangle() { + if (!is_finished() && current_triangle_.finished()) { + goto_next_vertex(); + } + } + + public: + /** + * @brief ugly hack to get an iterator to the end + * @remark assume that the complex is non-empty + */ + Triangle_iterator(const SkeletonBlockerComplex* complex, bool is_end) : + complex_(complex), + current_vertex_(complex->vertex_range().end()), + current_triangle_(), // xxx this line is problematic is the complex is empty + is_end_(true) { } + + Triangle_iterator& operator=(const Triangle_iterator & other) { + complex_ = other.complex_; + Complex_vertex_iterator current_vertex_; + STAVI current_triangle_; + return *this; + } + + bool equal(const Triangle_iterator& other) const { + bool both_are_finished = is_finished() && other.is_finished(); + bool both_arent_finished = !is_finished() && !other.is_finished(); + // if the two iterators are not finished, they must have the same state + return (complex_ == other.complex_) && (both_are_finished || ((both_arent_finished) && + current_vertex_ == other.current_vertex_ && current_triangle_ == other.current_triangle_)); + } + + Simplex_handle dereference() const { + return *current_triangle_; + } + + private: + // goto the next vertex that has a triangle pending or the + // end vertex iterator if none exists + void goto_next_vertex() { + assert(current_triangle_.finished()); // we mush have consume all triangles passing through the vertex + assert(!is_finished()); // we must not be done + + ++current_vertex_; + + if (!is_finished()) { + current_triangle_ = STAVI(complex_, *current_vertex_); + if (current_triangle_.finished()) + goto_next_vertex(); + } + } + + public: + void increment() { + if (!current_triangle_.finished()) { + ++current_triangle_; // problem here + if (current_triangle_.finished()) + goto_next_vertex(); + } else { + assert(!is_finished()); + goto_next_vertex(); + } + } + + private: + bool is_finished() const { + return is_end_ || current_vertex_ == complex_->vertex_range().end(); + } }; -} +} // namespace skbl -} // namespace GUDHI +} // namespace Gudhi -#endif /* GUDHI_SKELETON_BLOCKERS_TRIANGLES_ITERATORS_H_ */ +#endif // SKELETON_BLOCKER_ITERATORS_SKELETON_BLOCKERS_TRIANGLES_ITERATORS_H_ diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_vertices_iterators.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_vertices_iterators.h index a9d4e373..14ae136a 100644 --- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_vertices_iterators.h +++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_vertices_iterators.h @@ -1,31 +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_SKELETON_BLOCKERS_VERTICES_ITERATORS_H_ -#define GUDHI_SKELETON_BLOCKERS_VERTICES_ITERATORS_H_ - -#include "boost/iterator/iterator_facade.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 SKELETON_BLOCKER_ITERATORS_SKELETON_BLOCKERS_VERTICES_ITERATORS_H_ +#define SKELETON_BLOCKER_ITERATORS_SKELETON_BLOCKERS_VERTICES_ITERATORS_H_ + +#include + +#include // for pair<> + +namespace Gudhi { namespace skbl { @@ -35,148 +36,137 @@ namespace skbl { *@remark Incrementation increases Vertex_handle. */ template -class Vertex_iterator : public boost::iterator_facade -< Vertex_iterator - , typename SkeletonBlockerComplex::Vertex_handle const - , boost::forward_traversal_tag - , typename SkeletonBlockerComplex::Vertex_handle const - > -{ - friend class boost::iterator_core_access; - - typedef typename SkeletonBlockerComplex::boost_vertex_iterator boost_vertex_iterator; - typedef typename SkeletonBlockerComplex::Vertex_handle Vertex_handle; -private: - const SkeletonBlockerComplex* complex; - std::pair vertexIterator; - - -public: - Vertex_iterator():complex(NULL){ - } - - Vertex_iterator(const SkeletonBlockerComplex* complex_): - complex(complex_), - vertexIterator(vertices(complex_->skeleton)){ - if(!finished() && !is_active()) { - goto_next_valid(); - } - } - - /** - * return an iterator to the end. - */ - Vertex_iterator(const SkeletonBlockerComplex* complex_,int end): - complex(complex_),vertexIterator(vertices(complex_->skeleton)){ - vertexIterator.first = vertexIterator.second ; - } - -public: - void increment () {goto_next_valid();} - Vertex_handle dereference() const { - return(Vertex_handle(*(vertexIterator.first))); - } - - bool equal(const Vertex_iterator& other) const{ - return vertexIterator == other.vertexIterator && complex == other.complex; - } - - bool operator<(const Vertex_iterator& other) const{ - return dereference() +, typename SkeletonBlockerComplex::Vertex_handle const +, boost::forward_traversal_tag +, typename SkeletonBlockerComplex::Vertex_handle const> { + friend class boost::iterator_core_access; + + typedef typename SkeletonBlockerComplex::boost_vertex_iterator boost_vertex_iterator; + typedef typename SkeletonBlockerComplex::Vertex_handle Vertex_handle; + private: + const SkeletonBlockerComplex* complex; + std::pair vertexIterator; + + + public: + Vertex_iterator() : complex(NULL) { } + + Vertex_iterator(const SkeletonBlockerComplex* complex_) : + complex(complex_), + vertexIterator(vertices(complex_->skeleton)) { + if (!finished() && !is_active()) { + goto_next_valid(); + } + } + + /** + * return an iterator to the end. + */ + Vertex_iterator(const SkeletonBlockerComplex* complex_, int end) : + complex(complex_), vertexIterator(vertices(complex_->skeleton)) { + vertexIterator.first = vertexIterator.second; + } + + public: + void increment() { + goto_next_valid(); + } + + Vertex_handle dereference() const { + return (Vertex_handle(*(vertexIterator.first))); + } + + bool equal(const Vertex_iterator& other) const { + return vertexIterator == other.vertexIterator && complex == other.complex; + } + + bool operator<(const Vertex_iterator& other) const { + return dereference() < other.dereference(); + } + + private: + bool finished() const { + return vertexIterator.first == vertexIterator.second; + } + + void goto_next_valid() { + ++vertexIterator.first; + if (!finished() && !is_active()) { + goto_next_valid(); + } + } + + bool is_active() const { + return ((*complex)[Vertex_handle(*vertexIterator.first)]).is_active(); + } }; - - - template -class Neighbors_vertices_iterator -: public boost::iterator_facade < Neighbors_vertices_iterator - , typename SkeletonBlockerComplex::Vertex_handle const - , boost::forward_traversal_tag - , typename SkeletonBlockerComplex::Vertex_handle const - > -{ - friend class boost::iterator_core_access; - - typedef SkeletonBlockerComplex Complex; - typedef typename Complex::boost_adjacency_iterator boost_adjacency_iterator; - typedef typename Complex::Vertex_handle Vertex_handle; - typedef typename Complex::Edge_handle Edge_handle; - -private: - - const Complex* complex; - Vertex_handle v; - - boost_adjacency_iterator current_; - boost_adjacency_iterator end_; - -public: - // boost_adjacency_iterator ai, ai_end; - // for (tie(ai, ai_end) = adjacent_vertices(v.vertex, skeleton); ai != ai_end; ++ai){ - - Neighbors_vertices_iterator():complex(NULL){ - } - - Neighbors_vertices_iterator(const Complex* complex_,Vertex_handle v_): - complex(complex_), - v(v_){ - tie(current_,end_) = adjacent_vertices(v.vertex, complex->skeleton); - } - - /** - * returns an iterator to the end - */ - Neighbors_vertices_iterator(const Complex* complex_,Vertex_handle v_,int end): - complex(complex_), - v(v_){ - tie(current_,end_) = adjacent_vertices(v.vertex, complex->skeleton); - set_end(); - } - - - void increment () { - if(current_ != end_) - ++current_; - } - - Vertex_handle dereference() const { - return(Vertex_handle(*current_)); - } - - bool equal(const Neighbors_vertices_iterator& other) const{ - return (complex== other.complex) && (v == other.v) && (current_ == other.current_) && (end_ == other.end_); - } - -private: - //todo remove this ugly hack - void set_end(){ - current_ = end_; - } +class Neighbors_vertices_iterator: public boost::iterator_facade < Neighbors_vertices_iterator +, typename SkeletonBlockerComplex::Vertex_handle const +, boost::forward_traversal_tag +, typename SkeletonBlockerComplex::Vertex_handle const> { + friend class boost::iterator_core_access; + + typedef SkeletonBlockerComplex Complex; + typedef typename Complex::boost_adjacency_iterator boost_adjacency_iterator; + typedef typename Complex::Vertex_handle Vertex_handle; + typedef typename Complex::Edge_handle Edge_handle; + + private: + const Complex* complex; + Vertex_handle v; + + boost_adjacency_iterator current_; + boost_adjacency_iterator end_; + + public: + // boost_adjacency_iterator ai, ai_end; + // for (tie(ai, ai_end) = adjacent_vertices(v.vertex, skeleton); ai != ai_end; ++ai) { + + Neighbors_vertices_iterator() : complex(NULL) { } + + Neighbors_vertices_iterator(const Complex* complex_, Vertex_handle v_) : + complex(complex_), + v(v_) { + tie(current_, end_) = adjacent_vertices(v.vertex, complex->skeleton); + } + + /** + * returns an iterator to the end + */ + Neighbors_vertices_iterator(const Complex* complex_, Vertex_handle v_, int end) : + complex(complex_), + v(v_) { + tie(current_, end_) = adjacent_vertices(v.vertex, complex->skeleton); + set_end(); + } + + void increment() { + if (current_ != end_) + ++current_; + } + + Vertex_handle dereference() const { + return (Vertex_handle(*current_)); + } + + bool equal(const Neighbors_vertices_iterator& other) const { + return (complex == other.complex) && (v == other.v) && (current_ == other.current_) && (end_ == other.end_); + } + + private: + // todo remove this ugly hack + void set_end() { + current_ = end_; + } }; -} +} // namespace skbl -} // namespace GUDHI +} // namespace Gudhi -#endif /* GUDHI_SKELETON_BLOCKERS_VERTICES_ITERATORS_H_ */ +#endif // SKELETON_BLOCKER_ITERATORS_SKELETON_BLOCKERS_VERTICES_ITERATORS_H_ diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_complex.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_complex.h index 700830f2..07f371a2 100644 --- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_complex.h +++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_complex.h @@ -20,8 +20,20 @@ * along with this program. If not, see . */ -#ifndef SRC_SKELETON_BLOCKER_INCLUDE_GUDHI_SKELETON_BLOCKER_COMPLEX_H_ -#define SRC_SKELETON_BLOCKER_INCLUDE_GUDHI_SKELETON_BLOCKER_COMPLEX_H_ +#ifndef SKELETON_BLOCKER_COMPLEX_H_ +#define SKELETON_BLOCKER_COMPLEX_H_ + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include #include #include @@ -40,18 +52,6 @@ #include #include -#include "gudhi/Skeleton_blocker/iterators/Skeleton_blockers_iterators.h" -#include "gudhi/Skeleton_blocker_link_complex.h" -#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" - namespace Gudhi { namespace skbl { @@ -1406,7 +1406,8 @@ class Skeleton_blocker_complex { Const_complex_blocker_around_vertex_iterator; typedef boost::iterator_range Complex_blocker_around_vertex_range; - typedef boost::iterator_range Const_complex_blocker_around_vertex_range; + typedef boost::iterator_range + Const_complex_blocker_around_vertex_range; public: /** @@ -1514,7 +1515,7 @@ class Skeleton_blocker_complex { * return the total number of simplices */ template -Complex make_complex_from_top_faces(SimplexHandleIterator simplex_begin, SimplexHandleIterator simplex_end, +Complex make_complex_from_top_faces(SimplexHandleIterator simplex_begin, SimplexHandleIterator simplex_end, bool is_flag_complex = false) { typedef typename Complex::Simplex_handle Simplex_handle; std::vector simplices; @@ -1531,6 +1532,4 @@ Complex make_complex_from_top_faces(SimplexHandleIterator simplex_begin, Simplex #include "Skeleton_blocker_simplifiable_complex.h" - -#endif // SRC_SKELETON_BLOCKER_INCLUDE_GUDHI_SKELETON_BLOCKER_COMPLEX_H_ - +#endif // SKELETON_BLOCKER_COMPLEX_H_ 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 3eff1ba3..b8395251 100644 --- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_geometric_complex.h +++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_geometric_complex.h @@ -19,12 +19,12 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -#ifndef SRC_SKELETON_BLOCKER_INCLUDE_GUDHI_SKELETON_BLOCKER_GEOMETRIC_COMPLEX_H_ -#define SRC_SKELETON_BLOCKER_INCLUDE_GUDHI_SKELETON_BLOCKER_GEOMETRIC_COMPLEX_H_ +#ifndef SKELETON_BLOCKER_GEOMETRIC_COMPLEX_H_ +#define SKELETON_BLOCKER_GEOMETRIC_COMPLEX_H_ -#include "gudhi/Utils.h" -#include "gudhi/Skeleton_blocker_complex.h" -#include "gudhi/Skeleton_blocker/Skeleton_blocker_sub_complex.h" +#include +#include +#include namespace Gudhi { @@ -221,4 +221,4 @@ SkeletonBlockerGeometricComplex make_complex_from_top_faces( } // namespace Gudhi -#endif // SRC_SKELETON_BLOCKER_INCLUDE_GUDHI_SKELETON_BLOCKER_GEOMETRIC_COMPLEX_H_ +#endif // SKELETON_BLOCKER_GEOMETRIC_COMPLEX_H_ 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 725ecce5..95d8fa97 100644 --- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_link_complex.h +++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_link_complex.h @@ -19,11 +19,11 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -#ifndef SRC_SKELETON_BLOCKER_INCLUDE_GUDHI_SKELETON_BLOCKER_LINK_COMPLEX_H_ -#define SRC_SKELETON_BLOCKER_INCLUDE_GUDHI_SKELETON_BLOCKER_LINK_COMPLEX_H_ +#ifndef SKELETON_BLOCKER_LINK_COMPLEX_H_ +#define SKELETON_BLOCKER_LINK_COMPLEX_H_ -#include "gudhi/Utils.h" -#include "gudhi/Skeleton_blocker_complex.h" +#include +#include namespace Gudhi { @@ -297,4 +297,4 @@ class Skeleton_blocker_link_complex : public Skeleton_blocker_sub_complex< } // namespace Gudhi -#endif // SRC_SKELETON_BLOCKER_INCLUDE_GUDHI_SKELETON_BLOCKER_LINK_COMPLEX_H_ +#endif // SKELETON_BLOCKER_LINK_COMPLEX_H_ 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 57e1daf0..705c78bb 100644 --- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_simplifiable_complex.h +++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_simplifiable_complex.h @@ -19,14 +19,14 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -#ifndef SRC_SKELETON_BLOCKER_INCLUDE_GUDHI_SKELETON_BLOCKER_SIMPLIFIABLE_COMPLEX_H_ -#define SRC_SKELETON_BLOCKER_INCLUDE_GUDHI_SKELETON_BLOCKER_SIMPLIFIABLE_COMPLEX_H_ +#ifndef SKELETON_BLOCKER_SIMPLIFIABLE_COMPLEX_H_ +#define SKELETON_BLOCKER_SIMPLIFIABLE_COMPLEX_H_ #include #include #include -#include "gudhi/Skeleton_blocker/Skeleton_blocker_sub_complex.h" +#include namespace Gudhi { @@ -447,4 +447,4 @@ Skeleton_blocker_complex::notify_changed_edges(Vertex_handle } // namespace Gudhi -#endif // SRC_SKELETON_BLOCKER_INCLUDE_GUDHI_SKELETON_BLOCKER_SIMPLIFIABLE_COMPLEX_H_ +#endif // SKELETON_BLOCKER_SIMPLIFIABLE_COMPLEX_H_ diff --git a/src/common/include/gudhi/reader_utils.h b/src/common/include/gudhi/reader_utils.h index b824e0d4..e05714c7 100644 --- a/src/common/include/gudhi/reader_utils.h +++ b/src/common/include/gudhi/reader_utils.h @@ -23,10 +23,16 @@ #ifndef READER_UTILS_H_ #define READER_UTILS_H_ +#include + +#include + #include #include -#include -#include "gudhi/graph_simplicial_complex.h" +#include +#include // for numeric_limits<> +#include +#include /** * \brief Read a set of points to turn it -- 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 'src/Simplex_tree') 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 From 376c2a0dbde0decffb3f37146071368ccb3836a7 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Thu, 8 Oct 2015 21:48:10 +0000 Subject: cpplint fixes git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@845 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 8b15f0805527b494f3a57625de5c69d836b287dd --- .../CGAL_queue/Modifiable_priority_queue.h | 6 +++--- .../gudhi/Contraction/policies/Edge_length_cost.h | 6 +++--- src/GudhUI/utils/Edge_collapsor.h | 6 +++--- src/GudhUI/utils/Edge_contractor.h | 2 +- src/GudhUI/utils/Is_manifold.h | 4 ++-- src/GudhUI/utils/Vertex_collapsor.h | 2 ++ src/GudhUI/view/Viewer.h | 6 +++--- src/GudhUI/view/Viewer_instructor.h | 6 +++--- src/Hasse_complex/include/gudhi/Hasse_complex.h | 9 +++++---- .../include/gudhi/Persistent_cohomology.h | 20 +++++++++++--------- .../include/gudhi/Persistent_cohomology/Field_Zp.h | 6 +++--- .../gudhi/Persistent_cohomology/Multi_field.h | 6 +++--- .../Persistent_cohomology_column.h | 6 +++--- src/Simplex_tree/include/gudhi/Simplex_tree.h | 13 ++++++++----- .../gudhi/Simplex_tree/Simplex_tree_iterators.h | 6 +++--- .../Simplex_tree_node_explicit_storage.h | 6 +++--- .../gudhi/Simplex_tree/Simplex_tree_siblings.h | 6 +++--- .../include/gudhi/Simplex_tree/indexing_tag.h | 6 +++--- .../gudhi/Skeleton_blocker_simplifiable_complex.h | 6 +++--- src/common/include/gudhi/graph_simplicial_complex.h | 6 +++++- 20 files changed, 73 insertions(+), 61 deletions(-) (limited to 'src/Simplex_tree') 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 28ae535d..5a55c513 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 @@ -16,8 +16,8 @@ // // Author(s) : Fernando Cacciola // -#ifndef CONTRACTION_CGAL_MODIFIABLE_PRIORITY_QUEUE_H -#define CONTRACTION_CGAL_MODIFIABLE_PRIORITY_QUEUE_H +#ifndef CONTRACTION_CGAL_QUEUE_MODIFIABLE_PRIORITY_QUEUE_H_ +#define CONTRACTION_CGAL_QUEUE_MODIFIABLE_PRIORITY_QUEUE_H_ #define CGAL_SURFACE_MESH_SIMPLIFICATION_USE_RELAXED_HEAP @@ -98,4 +98,4 @@ class Modifiable_priority_queue { } // namespace CGAL -#endif // CONTRACTION_CGAL_MODIFIABLE_PRIORITY_QUEUE_H +#endif // CONTRACTION_CGAL_QUEUE_MODIFIABLE_PRIORITY_QUEUE_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 e4beb220..dac2d448 100644 --- a/src/Contraction/include/gudhi/Contraction/policies/Edge_length_cost.h +++ b/src/Contraction/include/gudhi/Contraction/policies/Edge_length_cost.h @@ -20,8 +20,8 @@ * along with this program. If not, see . */ -#ifndef CONTRACTION_POLICIES_DUMMY_EDGE_LENGTH_COST_H_ -#define CONTRACTION_POLICIES_DUMMY_EDGE_LENGTH_COST_H_ +#ifndef CONTRACTION_POLICIES_EDGE_LENGTH_COST_H_ +#define CONTRACTION_POLICIES_EDGE_LENGTH_COST_H_ #include @@ -53,4 +53,4 @@ class Edge_length_cost : public Cost_policy { } // namespace Gudhi -#endif // CONTRACTION_POLICIES_DUMMY_EDGE_LENGTH_COST_H_ +#endif // CONTRACTION_POLICIES_EDGE_LENGTH_COST_H_ diff --git a/src/GudhUI/utils/Edge_collapsor.h b/src/GudhUI/utils/Edge_collapsor.h index fcf2a248..151e9b01 100644 --- a/src/GudhUI/utils/Edge_collapsor.h +++ b/src/GudhUI/utils/Edge_collapsor.h @@ -21,8 +21,8 @@ * */ -#ifndef UTILS_COLLAPSOR_H_ -#define UTILS_COLLAPSOR_H_ +#ifndef UTILS_EDGE_COLLAPSOR_H_ +#define UTILS_EDGE_COLLAPSOR_H_ #include #include "utils/Edge_contractor.h" @@ -94,4 +94,4 @@ template class Edge_collapsor { } }; -#endif // UTILS_COLLAPSOR_H_ +#endif // UTILS_EDGE_COLLAPSOR_H_ diff --git a/src/GudhUI/utils/Edge_contractor.h b/src/GudhUI/utils/Edge_contractor.h index 053aac04..45079a40 100644 --- a/src/GudhUI/utils/Edge_contractor.h +++ b/src/GudhUI/utils/Edge_contractor.h @@ -94,4 +94,4 @@ template class Edge_contractor { } }; -#endif /* EDGE_CONTRACTOR_H_ */ +#endif // UTILS_EDGE_CONTRACTOR_H_ diff --git a/src/GudhUI/utils/Is_manifold.h b/src/GudhUI/utils/Is_manifold.h index 1b25df34..b6b19ee0 100644 --- a/src/GudhUI/utils/Is_manifold.h +++ b/src/GudhUI/utils/Is_manifold.h @@ -56,7 +56,7 @@ template class Is_manifold { dim = local_dimension(v); break; } - //check that the link of every vertex is a dim-1 sphere + // check that the link of every vertex is a dim-1 sphere for (auto v : input_complex_.vertex_range()) { if (!is_k_sphere(v, dim - 1)) { res = false; @@ -90,7 +90,7 @@ template class Is_manifold { if (complex.empty()) return -1; if (complex.num_blockers() != 1) return -2; - //necessary and sufficient condition : there exists a unique blocker that passes through all vertices + // necessary and sufficient condition : there exists a unique blocker that passes through all vertices auto first_blocker = *(complex.const_blocker_range().begin()); if (first_blocker->dimension() + 1 != complex.num_vertices()) diff --git a/src/GudhUI/utils/Vertex_collapsor.h b/src/GudhUI/utils/Vertex_collapsor.h index be03c765..2b36cb3a 100644 --- a/src/GudhUI/utils/Vertex_collapsor.h +++ b/src/GudhUI/utils/Vertex_collapsor.h @@ -24,6 +24,8 @@ #ifndef UTILS_VERTEX_COLLAPSOR_H_ #define UTILS_VERTEX_COLLAPSOR_H_ +#include + #include "utils/Edge_contractor.h" #include "utils/Furthest_point_epsilon_net.h" #include "utils/UI_utils.h" diff --git a/src/GudhUI/view/Viewer.h b/src/GudhUI/view/Viewer.h index 99bd63e4..276ccd3c 100644 --- a/src/GudhUI/view/Viewer.h +++ b/src/GudhUI/view/Viewer.h @@ -21,8 +21,8 @@ * */ -#ifndef VIEW_VIEWER_H -#define VIEW_VIEWER_H +#ifndef VIEW_VIEWER_H_ +#define VIEW_VIEWER_H_ // Workaround for moc-qt4 not parsing boost headers #include @@ -117,4 +117,4 @@ class Viewer : public QGLViewer { void click(const Point_3& position); }; -#endif // VIEW_VIEWER_H +#endif // VIEW_VIEWER_H_ diff --git a/src/GudhUI/view/Viewer_instructor.h b/src/GudhUI/view/Viewer_instructor.h index e1c6af8b..31a1d273 100644 --- a/src/GudhUI/view/Viewer_instructor.h +++ b/src/GudhUI/view/Viewer_instructor.h @@ -21,8 +21,8 @@ * */ -#ifndef VIEW_VIEWER_INSTRUCTOR_H -#define VIEW_VIEWER_INSTRUCTOR_H +#ifndef VIEW_VIEWER_INSTRUCTOR_H_ +#define VIEW_VIEWER_INSTRUCTOR_H_ // todo do a viewer instructor that have directely a pointer to a QGLviewer and buffer ot not triangles @@ -114,4 +114,4 @@ class Viewer_instructor : public QWidget { void change_light(); }; -#endif // VIEW_VIEWER_INSTRUCTOR_H +#endif // VIEW_VIEWER_INSTRUCTOR_H_ diff --git a/src/Hasse_complex/include/gudhi/Hasse_complex.h b/src/Hasse_complex/include/gudhi/Hasse_complex.h index c3a84c02..67079687 100644 --- a/src/Hasse_complex/include/gudhi/Hasse_complex.h +++ b/src/Hasse_complex/include/gudhi/Hasse_complex.h @@ -26,6 +26,8 @@ #include #include +#include // for pair +#include namespace Gudhi { @@ -71,11 +73,10 @@ template < typename FiltrationValue = double > 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 int Simplex_handle; // index in vector complex_ typedef boost::counting_iterator< Simplex_handle > Filtration_simplex_iterator; typedef boost::iterator_range Filtration_simplex_range; @@ -214,8 +215,8 @@ std::istream& operator>>(std::istream & is 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 - { + // 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 >(key, fil, boundary)); diff --git a/src/Persistent_cohomology/include/gudhi/Persistent_cohomology.h b/src/Persistent_cohomology/include/gudhi/Persistent_cohomology.h index 8c614e96..d096792f 100644 --- a/src/Persistent_cohomology/include/gudhi/Persistent_cohomology.h +++ b/src/Persistent_cohomology/include/gudhi/Persistent_cohomology.h @@ -20,8 +20,8 @@ * along with this program. If not, see . */ -#ifndef SRC_PERSISTENT_COHOMOLOGY_INCLUDE_GUDHI_PERSISTENT_COHOMOLOGY_H_ -#define SRC_PERSISTENT_COHOMOLOGY_INCLUDE_GUDHI_PERSISTENT_COHOMOLOGY_H_ +#ifndef PERSISTENT_COHOMOLOGY_H_ +#define PERSISTENT_COHOMOLOGY_H_ #include #include @@ -38,6 +38,10 @@ #include #include #include // std::ofstream +#include // for numeric_limits<> +#include +#include +#include namespace Gudhi { @@ -709,13 +713,11 @@ class Persistent_cohomology { } } - void write_output_diagram(std::string diagram_name) - { - std::ofstream diagram_out(diagram_name.c_str()); - cmp_intervals_by_length cmp( cpx_ ); + void write_output_diagram(std::string diagram_name) { + std::ofstream diagram_out(diagram_name.c_str()); + cmp_intervals_by_length cmp(cpx_); std::sort(std::begin(persistent_pairs_), std::end(persistent_pairs_), cmp); - for(auto pair : persistent_pairs_) - { + for (auto pair : persistent_pairs_) { diagram_out << cpx_->dimension(get<0>(pair)) << " " << cpx_->filtration(get<0>(pair)) << " " << cpx_->filtration(get<1>(pair)) << std::endl; @@ -774,4 +776,4 @@ class Persistent_cohomology { } // namespace Gudhi -#endif // SRC_PERSISTENT_COHOMOLOGY_INCLUDE_GUDHI_PERSISTENT_COHOMOLOGY_H_ +#endif // PERSISTENT_COHOMOLOGY_H_ diff --git a/src/Persistent_cohomology/include/gudhi/Persistent_cohomology/Field_Zp.h b/src/Persistent_cohomology/include/gudhi/Persistent_cohomology/Field_Zp.h index a12019f8..6db16e69 100644 --- a/src/Persistent_cohomology/include/gudhi/Persistent_cohomology/Field_Zp.h +++ b/src/Persistent_cohomology/include/gudhi/Persistent_cohomology/Field_Zp.h @@ -20,8 +20,8 @@ * along with this program. If not, see . */ -#ifndef SRC_PERSISTENT_COHOMOLOGY_INCLUDE_GUDHI_PERSISTENT_COHOMOLOGY_FIELD_ZP_H_ -#define SRC_PERSISTENT_COHOMOLOGY_INCLUDE_GUDHI_PERSISTENT_COHOMOLOGY_FIELD_ZP_H_ +#ifndef PERSISTENT_COHOMOLOGY_FIELD_ZP_H_ +#define PERSISTENT_COHOMOLOGY_FIELD_ZP_H_ #include #include @@ -113,4 +113,4 @@ class Field_Zp { } // namespace Gudhi -#endif // SRC_PERSISTENT_COHOMOLOGY_INCLUDE_GUDHI_PERSISTENT_COHOMOLOGY_FIELD_ZP_H_ +#endif // PERSISTENT_COHOMOLOGY_FIELD_ZP_H_ 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 555d696f..0591fc95 100644 --- a/src/Persistent_cohomology/include/gudhi/Persistent_cohomology/Multi_field.h +++ b/src/Persistent_cohomology/include/gudhi/Persistent_cohomology/Multi_field.h @@ -20,8 +20,8 @@ * along with this program. If not, see . */ -#ifndef SRC_PERSISTENT_COHOMOLOGY_INCLUDE_GUDHI_PERSISTENT_COHOMOLOGY_MULTI_FIELD_H_ -#define SRC_PERSISTENT_COHOMOLOGY_INCLUDE_GUDHI_PERSISTENT_COHOMOLOGY_MULTI_FIELD_H_ +#ifndef PERSISTENT_COHOMOLOGY_MULTI_FIELD_H_ +#define PERSISTENT_COHOMOLOGY_MULTI_FIELD_H_ #include @@ -183,4 +183,4 @@ class Multi_field { } // namespace Gudhi -#endif // SRC_PERSISTENT_COHOMOLOGY_INCLUDE_GUDHI_PERSISTENT_COHOMOLOGY_MULTI_FIELD_H_ +#endif // PERSISTENT_COHOMOLOGY_MULTI_FIELD_H_ 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 568f24df..612658e6 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 @@ -20,8 +20,8 @@ * along with this program. If not, see . */ -#ifndef SRC_PERSISTENT_COHOMOLOGY_INCLUDE_GUDHI_PERSISTENT_COHOMOLOGY_PERSISTENT_COHOMOLOGY_COLUMN_H_ -#define SRC_PERSISTENT_COHOMOLOGY_INCLUDE_GUDHI_PERSISTENT_COHOMOLOGY_PERSISTENT_COHOMOLOGY_COLUMN_H_ +#ifndef PERSISTENT_COHOMOLOGY_PERSISTENT_COHOMOLOGY_COLUMN_H_ +#define PERSISTENT_COHOMOLOGY_PERSISTENT_COHOMOLOGY_COLUMN_H_ #include #include @@ -138,4 +138,4 @@ class Persistent_cohomology_column : public boost::intrusive::set_base_hook< } // namespace Gudhi -#endif // SRC_PERSISTENT_COHOMOLOGY_INCLUDE_GUDHI_PERSISTENT_COHOMOLOGY_PERSISTENT_COHOMOLOGY_COLUMN_H_ +#endif // PERSISTENT_COHOMOLOGY_PERSISTENT_COHOMOLOGY_COLUMN_H_ diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index 96565ff1..6e51d107 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -120,7 +120,9 @@ class Simplex_tree { /* Type of node in the simplex tree. */ typedef Simplex_tree_node_explicit_storage Node; /* Type of dictionary Vertex_handle -> Node for traversing the simplex tree. */ - // Note: this wastes space when Vertex_handle is 32 bits and Node is aligned on 64 bits. It would be better to use a flat_set (with our own comparator) where we can control the layout of the struct (put Vertex_handle and Simplex_key next to each other). + // Note: this wastes space when Vertex_handle is 32 bits and Node is aligned on 64 bits. It would be better to use a + // flat_set (with our own comparator) where we can control the layout of the struct (put Vertex_handle and + // Simplex_key next to each other). typedef typename boost::container::flat_map Dictionary; /* \brief Set of nodes sharing a same parent in the simplex tree. */ @@ -131,7 +133,7 @@ class Simplex_tree { Key_simplex_base_real() : key_(-1) {} void assign_key(Simplex_key k) { key_ = k; } Simplex_key key() const { return key_; } - private: + private: Simplex_key key_; }; struct Key_simplex_base_dummy { @@ -145,7 +147,7 @@ class Simplex_tree { Filtration_simplex_base_real() : filt_(0) {} void assign_filtration(Filtration_value f) { filt_ = f; } Filtration_value filtration() const { return filt_; } - private: + private: Filtration_value filt_; }; struct Filtration_simplex_base_dummy { @@ -153,7 +155,8 @@ class Simplex_tree { void assign_filtration(Filtration_value f) { assert(f == 0); } Filtration_value filtration() const { return 0; } }; - typedef typename std::conditional::type Filtration_simplex_base; + typedef typename std::conditional::type Filtration_simplex_base; public: /** \brief Handle type to a simplex contained in the simplicial complex represented @@ -271,7 +274,7 @@ class Simplex_tree { * The filtration must be valid. If the filtration has not been initialized yet, the * method initializes it (i.e. order the simplices). If the complex has changed since the last time the filtration * was initialized, please call `initialize_filtration()` to recompute it. */ - Filtration_simplex_range const& filtration_simplex_range(Indexing_tag=Indexing_tag()) { + Filtration_simplex_range const& filtration_simplex_range(Indexing_tag = Indexing_tag()) { if (filtration_vect_.empty()) { initialize_filtration(); } 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 f83f5ea8..372ef329 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 @@ -20,8 +20,8 @@ * along with this program. If not, see . */ -#ifndef SIMPLEX_TREE_ITERATORS_H_ -#define SIMPLEX_TREE_ITERATORS_H_ +#ifndef SIMPLEX_TREE_SIMPLEX_TREE_ITERATORS_H_ +#define SIMPLEX_TREE_SIMPLEX_TREE_ITERATORS_H_ #include #include @@ -315,4 +315,4 @@ class Simplex_tree_skeleton_simplex_iterator : public boost::iterator_facade< /* @} */ // end addtogroup simplex_tree } // namespace Gudhi -#endif // SIMPLEX_TREE_ITERATORS_H_ +#endif // SIMPLEX_TREE_SIMPLEX_TREE_ITERATORS_H_ diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_node_explicit_storage.h b/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_node_explicit_storage.h index 7f735b7e..25d4888a 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_node_explicit_storage.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_node_explicit_storage.h @@ -20,8 +20,8 @@ * along with this program. If not, see . */ -#ifndef SIMPLEX_TREE_NODE_EXPLICIT_STORAGE_H_ -#define SIMPLEX_TREE_NODE_EXPLICIT_STORAGE_H_ +#ifndef SIMPLEX_TREE_SIMPLEX_TREE_NODE_EXPLICIT_STORAGE_H_ +#define SIMPLEX_TREE_SIMPLEX_TREE_NODE_EXPLICIT_STORAGE_H_ #include @@ -69,4 +69,4 @@ struct Simplex_tree_node_explicit_storage : SimplexTree::Filtration_simplex_base /* @} */ // end addtogroup simplex_tree } // namespace Gudhi -#endif // SIMPLEX_TREE_NODE_EXPLICIT_STORAGE_H_ +#endif // SIMPLEX_TREE_SIMPLEX_TREE_NODE_EXPLICIT_STORAGE_H_ 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 9cdda967..158ee1f7 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 @@ -20,8 +20,8 @@ * along with this program. If not, see . */ -#ifndef SIMPLEX_TREE_SIBLINGS_H_ -#define SIMPLEX_TREE_SIBLINGS_H_ +#ifndef SIMPLEX_TREE_SIMPLEX_TREE_SIBLINGS_H_ +#define SIMPLEX_TREE_SIMPLEX_TREE_SIBLINGS_H_ #include @@ -124,4 +124,4 @@ class Simplex_tree_siblings { /* @} */ // end addtogroup simplex_tree } // namespace Gudhi -#endif // SIMPLEX_TREE_SIBLINGS_H_ +#endif // SIMPLEX_TREE_SIMPLEX_TREE_SIBLINGS_H_ diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree/indexing_tag.h b/src/Simplex_tree/include/gudhi/Simplex_tree/indexing_tag.h index a00dac27..0adeb46d 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree/indexing_tag.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree/indexing_tag.h @@ -20,8 +20,8 @@ * along with this program. If not, see . */ -#ifndef INDEXING_TAG_H_ -#define INDEXING_TAG_H_ +#ifndef SIMPLEX_TREE_INDEXING_TAG_H_ +#define SIMPLEX_TREE_INDEXING_TAG_H_ namespace Gudhi { @@ -36,4 +36,4 @@ struct linear_indexing_tag { // struct zigzag_indexing_tag {}; } // namespace Gudhi -#endif // INDEXING_TAG_H_ +#endif // SIMPLEX_TREE_INDEXING_TAG_H_ 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 705c78bb..17a237a7 100644 --- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_simplifiable_complex.h +++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_simplifiable_complex.h @@ -22,12 +22,12 @@ #ifndef SKELETON_BLOCKER_SIMPLIFIABLE_COMPLEX_H_ #define SKELETON_BLOCKER_SIMPLIFIABLE_COMPLEX_H_ +#include + #include #include #include -#include - namespace Gudhi { namespace skbl { @@ -340,7 +340,7 @@ Skeleton_blocker_complex::contract_edge(Vertex_handle a, Vert assert(this->contains_vertex(a)); assert(this->contains_vertex(b)); - if(this->contains_edge(a, b)) + if (this->contains_edge(a, b)) this->add_edge(a, b); // if some blockers passes through 'ab', we need to remove them. diff --git a/src/common/include/gudhi/graph_simplicial_complex.h b/src/common/include/gudhi/graph_simplicial_complex.h index 859504b2..042ef516 100644 --- a/src/common/include/gudhi/graph_simplicial_complex.h +++ b/src/common/include/gudhi/graph_simplicial_complex.h @@ -25,6 +25,10 @@ #include +#include // for pair<> +#include +#include + /* Edge tag for Boost PropertyGraph. */ struct edge_filtration_t { typedef boost::edge_property_tag kind; @@ -79,7 +83,7 @@ Graph_t compute_proximity_graph(PointCloud &points Graph_t skel_graph(edges.begin() , edges.end() , edges_fil.begin() - , idx_u); //number of points labeled from 0 to idx_u-1 + , idx_u); // number of points labeled from 0 to idx_u-1 auto vertex_prop = boost::get(vertex_filtration_t(), skel_graph); -- cgit v1.2.3 From 53c5df01a52987c5d2ea75a3de9523acc076d8a7 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Mon, 12 Oct 2015 11:41:05 +0000 Subject: Workaround for include(${CGAL_USE_FILE}) in GudhUI and hypergenerator Fix make test issue when cmake in a build directory for SimplexTreeUT and skbl TestGeometricComplex git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@849 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: d6b35ba4b697c7ee61fcd39b998a0fd717a3716a --- data/points/generator/CMakeLists.txt | 15 +++++++++++++++ src/GudhUI/CMakeLists.txt | 27 +++++++++++++++------------ src/Simplex_tree/test/CMakeLists.txt | 3 +++ src/Skeleton_blocker/test/CMakeLists.txt | 4 ++++ 4 files changed, 37 insertions(+), 12 deletions(-) (limited to 'src/Simplex_tree') diff --git a/data/points/generator/CMakeLists.txt b/data/points/generator/CMakeLists.txt index 0d045450..26b44446 100644 --- a/data/points/generator/CMakeLists.txt +++ b/data/points/generator/CMakeLists.txt @@ -4,7 +4,22 @@ project(GUDHIPointsGenerator) 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) diff --git a/src/GudhUI/CMakeLists.txt b/src/GudhUI/CMakeLists.txt index e896f42c..71f4fd1a 100644 --- a/src/GudhUI/CMakeLists.txt +++ b/src/GudhUI/CMakeLists.txt @@ -18,20 +18,23 @@ if ( CGAL_FOUND AND QT4_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND ) LINK_DIRECTORIES(${Boost_LIBRARY_DIRS}) include(${QT_USE_FILE}) - include(${CGAL_USE_FILE}) -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() + 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 -message("CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}") -message("CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG}") -message("CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE}") include_directories (${QGLVIEWER_INCLUDE_DIR}) include_directories(.) diff --git a/src/Simplex_tree/test/CMakeLists.txt b/src/Simplex_tree/test/CMakeLists.txt index b6a1c0b6..c9eae163 100644 --- a/src/Simplex_tree/test/CMakeLists.txt +++ b/src/Simplex_tree/test/CMakeLists.txt @@ -17,6 +17,9 @@ endif() add_executable ( SimplexTreeUT simplex_tree_unit_test.cpp ) target_link_libraries(SimplexTreeUT ${Boost_SYSTEM_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) +# Do not forget to copy test files in current binary dir +file(COPY "simplex_tree_for_unit_test.txt" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) + # Unitary tests add_test(NAME SimplexTreeUT COMMAND ${CMAKE_CURRENT_BINARY_DIR}/SimplexTreeUT diff --git a/src/Skeleton_blocker/test/CMakeLists.txt b/src/Skeleton_blocker/test/CMakeLists.txt index e62600a2..8b6fb672 100644 --- a/src/Skeleton_blocker/test/CMakeLists.txt +++ b/src/Skeleton_blocker/test/CMakeLists.txt @@ -18,6 +18,10 @@ add_executable(TestSkeletonBlockerComplex TestSkeletonBlockerComplex.cpp) add_executable(TestSimplifiable TestSimplifiable.cpp) add_executable(TestGeometricComplex TestGeometricComplex.cpp) +# Do not forget to copy test files in current binary dir +file(COPY "test.off" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) +file(COPY "test2.off" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) + add_test(TestSkeletonBlockerComplex ${CMAKE_CURRENT_BINARY_DIR}/TestSkeletonBlockerComplex) add_test(TestSimplifiable ${CMAKE_CURRENT_BINARY_DIR}/TestSimplifiable) add_test(TestGeometricComplex ${CMAKE_CURRENT_BINARY_DIR}/TestGeometricComplex) -- cgit v1.2.3 From d0938e30da46a8ef0ad2e58ca57ab8df64454831 Mon Sep 17 00:00:00 2001 From: glisse Date: Wed, 14 Oct 2015 11:19:12 +0000 Subject: Update old comment about stable_sort. git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@856 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 20773a87a3a40113ad8a051be7972289144cd1d7 --- src/Simplex_tree/include/gudhi/Simplex_tree.h | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/Simplex_tree') diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index 6e51d107..4c6a95e8 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -771,12 +771,6 @@ class Simplex_tree { * assigned a Simplex_key corresponding to its order in the filtration (from 0 to m-1 for a * simplicial complex with m simplices). * - * The use of a depth-first traversal of the simplex tree, provided by - * complex_simplex_range(), combined with - * a stable sort is meant to optimize the order of simplices with same - * filtration value. The heuristic consists in inserting the cofaces of a - * simplex as soon as possible. - * * Will be automatically called when calling filtration_simplex_range() * if the filtration has never been initialized yet. */ void initialize_filtration() { @@ -785,7 +779,15 @@ class Simplex_tree { for (Simplex_handle sh : complex_simplex_range()) filtration_vect_.push_back(sh); - // the stable sort ensures the ordering heuristic + /* We use stable_sort here because with libstdc++ it is faster than sort. + * is_before_in_filtration is now a total order, but we used to call + * stable_sort for the following heuristic: + * The use of a depth-first traversal of the simplex tree, provided by + * complex_simplex_range(), combined with a stable sort is meant to + * optimize the order of simplices with same filtration value. The + * heuristic consists in inserting the cofaces of a simplex as soon as + * possible. + */ std::stable_sort(filtration_vect_.begin(), filtration_vect_.end(), is_before_in_filtration(this)); } -- cgit v1.2.3 From 3b22ae31478387efd64ae5f185128857f17ca9ee Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 23 Oct 2015 09:40:36 +0000 Subject: generate_version excludes bottleneck for version 1.2.0 - to be removed for 1.3.0 generate_version copies concept for doxygen purpose Contact gudhi-users on skbl and contraction page Doxygen warning fixes Doxygen Software section git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@871 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: bd7e252c2d0528f4bbc40c33a9221e1d6b386510 --- scripts/generate_version.sh | 10 ++++- src/Contraction/include/gudhi/Edge_contraction.h | 2 +- src/Doxyfile | 6 +-- src/Simplex_tree/concept/SimplexTreeOptions.h | 6 +-- .../include/gudhi/Skeleton_blocker.h | 2 +- .../include/gudhi/Skeleton_blocker_complex.h | 4 +- src/common/doc/main_page.h | 51 +++++++++++++++++++++- 7 files changed, 68 insertions(+), 13 deletions(-) (limited to 'src/Simplex_tree') diff --git a/scripts/generate_version.sh b/scripts/generate_version.sh index 43a54c1c..323396dc 100755 --- a/scripts/generate_version.sh +++ b/scripts/generate_version.sh @@ -61,12 +61,13 @@ cp $ROOT_DIR/GUDHIVersion.cmake.in $VERSION_DIR PACKAGE_INC_DIR="/include" #PACKAGE_SRC_DIR="/source" PACKAGE_EX_DIR="/example" +PACKAGE_CONCEPT_DIR="/concept" PACKAGE_DOC_DIR="/doc" for package in `ls $ROOT_DIR/src/` do - echo $package - if [ -d "$ROOT_DIR/src/$package" ] + if [ -d "$ROOT_DIR/src/$package" ] && [ $package != "Bottleneck" ] then + echo $package if [ "$package" == "cmake" ] then # SPECIFIC FOR CMAKE MODULES @@ -91,6 +92,11 @@ do mkdir -p $VERSION_DIR$PACKAGE_EX_DIR/$package cp -R $ROOT_DIR/src/$package$PACKAGE_EX_DIR/* $VERSION_DIR$PACKAGE_EX_DIR/$package fi + if [ -d "$ROOT_DIR/src/$package$PACKAGE_CONCEPT_DIR" ] + then + mkdir -p $VERSION_DIR$PACKAGE_CONCEPT_DIR/$package + cp -R $ROOT_DIR/src/$package$PACKAGE_CONCEPT_DIR/* $VERSION_DIR$PACKAGE_CONCEPT_DIR/$package + fi if [ -d "$ROOT_DIR/src/$package$PACKAGE_DOC_DIR" ] then mkdir -p $VERSION_DIR$PACKAGE_DOC_DIR/$package diff --git a/src/Contraction/include/gudhi/Edge_contraction.h b/src/Contraction/include/gudhi/Edge_contraction.h index dfce8d1b..f3076057 100644 --- a/src/Contraction/include/gudhi/Edge_contraction.h +++ b/src/Contraction/include/gudhi/Edge_contraction.h @@ -226,7 +226,7 @@ Time to simplify and enumerate simplices: \copyright GNU General Public License v3. -\verbatim Contact: David Salinas, david.salinas@inria.fr \endverbatim +\verbatim Contact: gudhi-users@lists.gforge.inria.fr \endverbatim */ /** @} */ // end defgroup } // namespace contraction diff --git a/src/Doxyfile b/src/Doxyfile index 85c496a8..084a9abb 100644 --- a/src/Doxyfile +++ b/src/Doxyfile @@ -38,7 +38,7 @@ PROJECT_NAME = "Gudhi" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = "1.1.0" +PROJECT_NUMBER = "1.2.0" # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a @@ -1338,7 +1338,7 @@ ECLIPSE_DOC_ID = org.doxygen.Project # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. -DISABLE_INDEX = NO +DISABLE_INDEX = YES # The GENERATE_TREEVIEW tag is used to specify whether a tree-like index # structure should be generated to display hierarchical information. If the tag @@ -1355,7 +1355,7 @@ DISABLE_INDEX = NO # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. -GENERATE_TREEVIEW = NO +GENERATE_TREEVIEW = YES # The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that # doxygen will group on one line in the generated HTML documentation. diff --git a/src/Simplex_tree/concept/SimplexTreeOptions.h b/src/Simplex_tree/concept/SimplexTreeOptions.h index a50a2bf1..add3ebdd 100644 --- a/src/Simplex_tree/concept/SimplexTreeOptions.h +++ b/src/Simplex_tree/concept/SimplexTreeOptions.h @@ -34,8 +34,8 @@ struct SimplexTreeOptions { /// Must be a signed integer type. typedef SimplexKey Simplex_key; /// If true, each simplex has extra storage for one `Simplex_key`. Necessary for `Persistent_cohomology`. - static constexpr 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 constexpr bool store_filtration; + 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; }; diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker.h index 792a7994..3be480fd 100644 --- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker.h +++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker.h @@ -241,7 +241,7 @@ their collaboration to write the two initial papers \copyright GNU General Public License v3. -\verbatim Contact: David Salinas, david.salinas@inria.fr \endverbatim +\verbatim Contact: gudhi-users@lists.gforge.inria.fr \endverbatim */ /** @} */ // end defgroup diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_complex.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_complex.h index 07f371a2..d26d12b0 100644 --- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_complex.h +++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_complex.h @@ -1018,7 +1018,7 @@ class Skeleton_blocker_complex { } //@} - /** @Simplification operations + /** @name Simplification operations */ //@{ @@ -1131,7 +1131,7 @@ class Skeleton_blocker_complex { } //@} - /** @Edge contraction operations + /** @name Edge contraction operations */ //@{ diff --git a/src/common/doc/main_page.h b/src/common/doc/main_page.h index 315aa0ac..d1060740 100644 --- a/src/common/doc/main_page.h +++ b/src/common/doc/main_page.h @@ -7,7 +7,7 @@ The Gudhi library (Geometric Understanding in Higher Dimensions) is a generic C+ topological analysis of high-dimensional data whose goal is to provide robust, efficient, flexible and easy to use implementations of state-of-the-art algorithms and data structures for computational topology. -This library is part of the Gudhi project. +This library is part of the Gudhi project. The current release of the library allows to use several data-structures for simplicial complexes : simplex tree, Hasse diagram or skeleton-blocker. Several operations can then be done on top of these @@ -70,3 +70,52 @@ make \verbatim Contact: gudhi-users@lists.gforge.inria.fr \endverbatim */ + +/*! \page Software Software + * \tableofcontents + * \section SoftwareIntroduction Introduction + * The GUDHI open source library will provide the central data structures and algorithms that underly applications in geometry understanding in higher dimensions. It is intended to both help the development of new algorithmic solutions inside and outside the project, and to facilitate the transfer of results in applied fields. + * + * The current release of the GUDHI library includes: + * + * – Data structures to represent, construct and manipulate simplicial complexes. + * + * – Algorithms to compute persistent homology and multi-field persistent homology. + * + * – Simplification methods via implicit representations. + * + * + * The library is available here and the documentation is + * available at this webpage. + * + * \section ReleaseHistory Release history + * + * – ??-??-2015; release v.1.2.0, Skeleton-Blocker simplex insertion, GudhUI (Gudhi Qt demo), Simplex tree coface function, Clang build issue fix. + * + * – 12-18-2014; release v.1.1, Skeleton-Blocker data-structure, simplification package, additional examples for topological persistence. + * + * – 08-12-2014; release v. 1.0.2, initialize simplex keys in initialize_filtration in Simplex_tree + * + * – 07-11-2014: release v. 1.0.1, bug fix in summing columns in Persistent_cohomology + * + * – 06-23-2014: release v. 1.0 + * + * \section Citation How to cite Gudhi + * Each Gudhi module (either data structures or algorithms) has an author section. + * + * Thank you to refer to this section, and to cite the author(s) of all the module you are using. + * + * \section Soon Coming soon + * + * – Alpha complex. + * + * – Bottleneck distance. + * + * – Zig zag persistence. + * + * – Witness complex. + * + * – Tangential complex. + * + * – Hard clustering. +*/ -- cgit v1.2.3