From 468f9f1fcf5a818d1615b3102f6324f67a0a825c Mon Sep 17 00:00:00 2001 From: glisse Date: Mon, 28 Sep 2015 15:30:36 +0000 Subject: Workaround for moc-qt4 failing to parse boost. These should be removed when we move to Qt5. git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@799 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 022769c3fcff955eba91c36cd27d2839702ec8dc --- src/GudhUI/gui/MainWindow.h | 2 ++ src/GudhUI/gui/Menu_edge_contraction.h | 2 ++ src/GudhUI/view/Viewer.h | 3 +++ src/GudhUI/view/Viewer_instructor.h | 2 ++ 4 files changed, 9 insertions(+) (limited to 'src/GudhUI') diff --git a/src/GudhUI/gui/MainWindow.h b/src/GudhUI/gui/MainWindow.h index 587f1c6f..e46b72a3 100644 --- a/src/GudhUI/gui/MainWindow.h +++ b/src/GudhUI/gui/MainWindow.h @@ -1,6 +1,8 @@ #ifndef MAIN_WINDOW_H #define MAIN_WINDOW_H +// Workaround for moc-qt4 not parsing boost headers +#include #include #include "ui_main_window.h" diff --git a/src/GudhUI/gui/Menu_edge_contraction.h b/src/GudhUI/gui/Menu_edge_contraction.h index e497a90f..81d37bd8 100644 --- a/src/GudhUI/gui/Menu_edge_contraction.h +++ b/src/GudhUI/gui/Menu_edge_contraction.h @@ -8,6 +8,8 @@ #ifndef MENU_EDGE_CONTRACTION_H_ #define MENU_EDGE_CONTRACTION_H_ +// Workaround for moc-qt4 not parsing boost headers +#include #include "gui/MainWindow.h" #include "gui/ui_MenuEdgeContraction.h" diff --git a/src/GudhUI/view/Viewer.h b/src/GudhUI/view/Viewer.h index 5639aa56..00f9b245 100644 --- a/src/GudhUI/view/Viewer.h +++ b/src/GudhUI/view/Viewer.h @@ -1,6 +1,9 @@ #ifndef VIEWER_H #define VIEWER_H +// Workaround for moc-qt4 not parsing boost headers +#include + #include #include "View_parameter.h" #include "model/Complex_typedefs.h" diff --git a/src/GudhUI/view/Viewer_instructor.h b/src/GudhUI/view/Viewer_instructor.h index 9a2a236b..62b3755e 100644 --- a/src/GudhUI/view/Viewer_instructor.h +++ b/src/GudhUI/view/Viewer_instructor.h @@ -3,6 +3,8 @@ // todo do a viewer instructor that have directely a pointer to a QGLviewer and buffer ot not triangles +// Workaround for moc-qt4 not parsing boost headers +#include #include -- 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/GudhUI') 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 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/GudhUI') 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 cd2e83819689afd2cd1bc76810282111cf5cd59d Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Thu, 8 Oct 2015 21:15:51 +0000 Subject: cpplint fixes on GudhUI git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@844 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 3acf1e789f3e4bded974f324ce3161bc1d1d2433 --- data/points/generator/hypergenerator.cpp | 7 +- src/GudhUI/gui/MainWindow.cpp | 385 +++++++-------- src/GudhUI/gui/MainWindow.h | 140 +++--- src/GudhUI/gui/Menu_edge_contraction.cpp | 118 ++--- src/GudhUI/gui/Menu_edge_contraction.h | 73 +-- src/GudhUI/gui/Menu_k_nearest_neighbors.cpp | 82 ++-- src/GudhUI/gui/Menu_k_nearest_neighbors.h | 58 ++- src/GudhUI/gui/Menu_persistence.cpp | 45 +- src/GudhUI/gui/Menu_persistence.h | 42 +- src/GudhUI/gui/Menu_uniform_neighbors.cpp | 87 ++-- src/GudhUI/gui/Menu_uniform_neighbors.h | 57 ++- src/GudhUI/gui/Viewer.cpp | 0 src/GudhUI/gui/Viewer_instructor.cpp | 0 src/GudhUI/gui/gudhui.cpp | 35 +- src/GudhUI/model/Complex_typedefs.h | 48 +- src/GudhUI/model/Model.h | 650 +++++++++++++------------- src/GudhUI/utils/Critical_points.h | 203 ++++---- src/GudhUI/utils/Edge_collapsor.h | 156 ++++--- src/GudhUI/utils/Edge_contractor.h | 156 ++++--- src/GudhUI/utils/Furthest_point_epsilon_net.h | 244 +++++----- src/GudhUI/utils/Is_manifold.h | 117 +++-- src/GudhUI/utils/K_nearest_builder.h | 143 +++--- src/GudhUI/utils/Lloyd_builder.h | 133 +++--- src/GudhUI/utils/MClock.h | 109 +++-- src/GudhUI/utils/Persistence_compute.h | 138 +++--- src/GudhUI/utils/Rips_builder.h | 99 ++-- src/GudhUI/utils/UI_utils.h | 43 +- src/GudhUI/utils/Vertex_collapsor.h | 138 +++--- src/GudhUI/view/Color.h | 42 +- src/GudhUI/view/FirstCoordProjector.h | 44 +- src/GudhUI/view/Projector3D.h | 47 +- src/GudhUI/view/View_parameter.h | 264 ++++++----- src/GudhUI/view/Viewer.cpp | 303 ++++++------ src/GudhUI/view/Viewer.h | 129 ++--- src/GudhUI/view/Viewer_instructor.cpp | 272 +++++------ src/GudhUI/view/Viewer_instructor.h | 149 +++--- 36 files changed, 2492 insertions(+), 2264 deletions(-) delete mode 100644 src/GudhUI/gui/Viewer.cpp delete mode 100644 src/GudhUI/gui/Viewer_instructor.cpp (limited to 'src/GudhUI') diff --git a/data/points/generator/hypergenerator.cpp b/data/points/generator/hypergenerator.cpp index 32ef450d..60890b44 100644 --- a/data/points/generator/hypergenerator.cpp +++ b/data/points/generator/hypergenerator.cpp @@ -35,8 +35,9 @@ typedef CGAL::Epick_d< CGAL::Dynamic_dimension_tag > K; typedef K::Point_d Point; void usage(char * const progName) { - std::cerr << "Usage: " << progName << " in|on sphere|cube off_file_name points_number[integer > 0] dimension[integer > 1] radius[double > 0.0 | default = 1.0]" << std::endl; - exit(-1); // ----- >> + std::cerr << "Usage: " << progName << " in|on sphere|cube off_file_name points_number[integer > 0] " << + "dimension[integer > 1] radius[double > 0.0 | default = 1.0]" << std::endl; + exit(-1); } int main(int argc, char **argv) { @@ -119,7 +120,7 @@ int main(int argc, char **argv) { for (auto thePoint : points) { int i = 0; - for (;i < dimension - 1; i++) { + for (; i < dimension - 1; i++) { diagram_out << thePoint[i] << " "; } diagram_out << thePoint[i] << std::endl; // last point + Carriage Return diff --git a/src/GudhUI/gui/MainWindow.cpp b/src/GudhUI/gui/MainWindow.cpp index e41b15ba..779ccd33 100644 --- a/src/GudhUI/gui/MainWindow.cpp +++ b/src/GudhUI/gui/MainWindow.cpp @@ -1,3 +1,25 @@ +/* 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 . + */ + #include "MainWindow.h" #include @@ -6,292 +28,271 @@ #include - #include "gui/Menu_k_nearest_neighbors.h" #include "gui/Menu_uniform_neighbors.h" #include "gui/Menu_edge_contraction.h" #include "gui/Menu_persistence.h" +MainWindow::MainWindow(QWidget* parent) : + menu_k_nearest_neighbors_(new Menu_k_nearest_neighbors(this)), + menu_uniform_neighbors_(new Menu_uniform_neighbors(this)), + menu_edge_contraction_(new Menu_edge_contraction(this, model_)), + menu_persistence_(new Menu_persistence(this)) { + // #ifndef NDEBUG // catch nan + // feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW); + // #endif -MainWindow::MainWindow(QWidget* parent): -menu_k_nearest_neighbors_(new Menu_k_nearest_neighbors(this)), -menu_uniform_neighbors_(new Menu_uniform_neighbors(this)), -menu_edge_contraction_(new Menu_edge_contraction(this,model_)), -menu_persistence_(new Menu_persistence(this)) -{ -//#ifndef NDEBUG // catch nan -//feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW); -//#endif + setupUi(this); - setupUi(this); + viewer_instructor_ = new Viewer_instructor( + this, + this->viewer, + model_.complex_); - viewer_instructor_ = new Viewer_instructor( - this, - this->viewer, - model_.complex_ - ); + connectActions(); - connectActions(); - - update_view(); + update_view(); } -void -MainWindow::closeEvent(QCloseEvent *event){ - exit(0); +void +MainWindow::closeEvent(QCloseEvent *event) { + exit(0); } - -void -MainWindow::connectActions(){ - QObject::connect(this->actionLoad_complex, SIGNAL(triggered()), this, - SLOT(off_file_open())); - QObject::connect(this->actionLoad_points, SIGNAL(triggered()), this, - SLOT(off_points_open())); - QObject::connect(this->actionSave_complex, SIGNAL(triggered()), this, - SLOT(off_file_save())); - QObject::connect(this->actionSave_points, SIGNAL(triggered()), this, - SLOT(off_points_save())); - - QObject::connect(this->actionShow_graph_stats, SIGNAL(triggered()), this, - SLOT(show_graph_stats())); - QObject::connect(this->actionShow_complex_stats, SIGNAL(triggered()), this, - SLOT(show_complex_stats())); - QObject::connect(this->actionShow_complex_dimension, SIGNAL(triggered()), this, - SLOT(show_complex_dimension())); - - QObject::connect(this->actionUniform_proximity_graph, SIGNAL(triggered()), this, - SLOT(build_rips_menu())); - QObject::connect(this->actionK_nearest_neighbors_graph, SIGNAL(triggered()), this, - SLOT(build_k_nearest_neighbors_menu())); - - - QObject::connect(this->actionContract_edges, SIGNAL(triggered()), this, - SLOT(contract_edge_menu())); - - QObject::connect(this->actionCollapse_vertices, SIGNAL(triggered()), this, - SLOT(collapse_vertices())); - - QObject::connect(this->actionCollapse_edges, SIGNAL(triggered()), this, - SLOT(collapse_edges())); - - QObject::connect(this->actionNoise, SIGNAL(triggered()), this, - SLOT(uniform_noise())); - QObject::connect(this->actionLloyd, SIGNAL(triggered()), this, - SLOT(lloyd())); - - - //view - QObject::connect(this->actionPoints, SIGNAL(triggered()), this->viewer_instructor_, - SLOT(change_draw_vertices())); - QObject::connect(this->actionEdges, SIGNAL(triggered()), this->viewer_instructor_, - SLOT(change_draw_edges())); - QObject::connect(this->actionTriangles, SIGNAL(triggered()), this->viewer_instructor_, - SLOT(change_draw_triangles())); - - //topology - QObject::connect(this->actionShow_homology_group, SIGNAL(triggered()), this, - SLOT(show_homology_group())); - QObject::connect(this->actionEuler_characteristic, SIGNAL(triggered()), this, - SLOT(show_euler_characteristic())); - QObject::connect(this->actionPersistence, SIGNAL(triggered()), this, - SLOT(persistence_menu())); - QObject::connect(this->actionEstimate_topological_changes, SIGNAL(triggered()), this, - SLOT(critical_points_menu())); - QObject::connect(this->actionIs_manifold, SIGNAL(triggered()), this, - SLOT(is_manifold_menu())); - - - QObject::connect(this, SIGNAL(sceneChanged()), this->viewer_instructor_, - SLOT(sceneChanged())); - +void +MainWindow::connectActions() { + QObject::connect(this->actionLoad_complex, SIGNAL(triggered()), this, + SLOT(off_file_open())); + QObject::connect(this->actionLoad_points, SIGNAL(triggered()), this, + SLOT(off_points_open())); + QObject::connect(this->actionSave_complex, SIGNAL(triggered()), this, + SLOT(off_file_save())); + QObject::connect(this->actionSave_points, SIGNAL(triggered()), this, + SLOT(off_points_save())); + + QObject::connect(this->actionShow_graph_stats, SIGNAL(triggered()), this, + SLOT(show_graph_stats())); + QObject::connect(this->actionShow_complex_stats, SIGNAL(triggered()), this, + SLOT(show_complex_stats())); + QObject::connect(this->actionShow_complex_dimension, SIGNAL(triggered()), this, + SLOT(show_complex_dimension())); + + QObject::connect(this->actionUniform_proximity_graph, SIGNAL(triggered()), this, + SLOT(build_rips_menu())); + QObject::connect(this->actionK_nearest_neighbors_graph, SIGNAL(triggered()), this, + SLOT(build_k_nearest_neighbors_menu())); + + + QObject::connect(this->actionContract_edges, SIGNAL(triggered()), this, + SLOT(contract_edge_menu())); + + QObject::connect(this->actionCollapse_vertices, SIGNAL(triggered()), this, + SLOT(collapse_vertices())); + + QObject::connect(this->actionCollapse_edges, SIGNAL(triggered()), this, + SLOT(collapse_edges())); + + QObject::connect(this->actionNoise, SIGNAL(triggered()), this, + SLOT(uniform_noise())); + QObject::connect(this->actionLloyd, SIGNAL(triggered()), this, + SLOT(lloyd())); + + + // view + QObject::connect(this->actionPoints, SIGNAL(triggered()), this->viewer_instructor_, + SLOT(change_draw_vertices())); + QObject::connect(this->actionEdges, SIGNAL(triggered()), this->viewer_instructor_, + SLOT(change_draw_edges())); + QObject::connect(this->actionTriangles, SIGNAL(triggered()), this->viewer_instructor_, + SLOT(change_draw_triangles())); + + // topology + QObject::connect(this->actionShow_homology_group, SIGNAL(triggered()), this, + SLOT(show_homology_group())); + QObject::connect(this->actionEuler_characteristic, SIGNAL(triggered()), this, + SLOT(show_euler_characteristic())); + QObject::connect(this->actionPersistence, SIGNAL(triggered()), this, + SLOT(persistence_menu())); + QObject::connect(this->actionEstimate_topological_changes, SIGNAL(triggered()), this, + SLOT(critical_points_menu())); + QObject::connect(this->actionIs_manifold, SIGNAL(triggered()), this, + SLOT(is_manifold_menu())); + + + QObject::connect(this, SIGNAL(sceneChanged()), this->viewer_instructor_, + SLOT(sceneChanged())); } void -MainWindow::init_view() const{ - viewer_instructor_->initialize_bounding_box(); - viewer_instructor_->show_entire_scene(); - update_view(); +MainWindow::init_view() const { + viewer_instructor_->initialize_bounding_box(); + viewer_instructor_->show_entire_scene(); + update_view(); } - void -MainWindow::update_view() const{ - emit (sceneChanged()); +MainWindow::update_view() const { + emit(sceneChanged()); } - - /** * open a file chooser to choose an off to load */ -void -MainWindow::off_file_open(){ - QString fileName = QFileDialog::getOpenFileName(this, tr("Open off File"), - "~/", tr("off files (*.off)")); - if (!fileName.isEmpty()){ - model_.off_file_open(fileName.toStdString()); - init_view(); - } +void +MainWindow::off_file_open() { + QString fileName = QFileDialog::getOpenFileName(this, tr("Open off File"), + "~/", tr("off files (*.off)")); + if (!fileName.isEmpty()) { + model_.off_file_open(fileName.toStdString()); + init_view(); + } } void -MainWindow::off_points_open(){ - QString fileName = QFileDialog::getOpenFileName(this, tr("Open points in a off file"), - "~/", tr("off files (*.off)")); - if (!fileName.isEmpty()){ - model_.off_points_open(fileName.toStdString()); - init_view(); - } +MainWindow::off_points_open() { + QString fileName = QFileDialog::getOpenFileName(this, tr("Open points in a off file"), + "~/", tr("off files (*.off)")); + if (!fileName.isEmpty()) { + model_.off_points_open(fileName.toStdString()); + init_view(); + } } - /** * open a file chooser to choose an off to save */ -void -MainWindow::off_file_save(){ - QString fileName = QFileDialog::getOpenFileName(this, tr("Save to off File"), - "~/", tr("off files (*.off)")); - if (!fileName.isEmpty()) - { - model_.off_file_save(fileName.toStdString()); - } +void +MainWindow::off_file_save() { + QString fileName = QFileDialog::getOpenFileName(this, tr("Save to off File"), + "~/", tr("off files (*.off)")); + if (!fileName.isEmpty()) { + model_.off_file_save(fileName.toStdString()); + } } /** * open a file chooser to choose an off to save */ void -MainWindow::off_points_save(){ - QString fileName = QFileDialog::getOpenFileName(this, tr("Save to off File"), - "~/", tr("off files (*.off)")); - if (!fileName.isEmpty()) - { - model_.off_points_save(fileName.toStdString()); - } +MainWindow::off_points_save() { + QString fileName = QFileDialog::getOpenFileName(this, tr("Save to off File"), + "~/", tr("off files (*.off)")); + if (!fileName.isEmpty()) { + model_.off_points_save(fileName.toStdString()); + } } - void -MainWindow::show_graph_stats(){ - model_.show_graph_stats(); +MainWindow::show_graph_stats() { + model_.show_graph_stats(); } void -MainWindow::show_complex_stats(){ - model_.show_complex_stats(); +MainWindow::show_complex_stats() { + model_.show_complex_stats(); } -void -MainWindow::show_complex_dimension(){ - model_.show_complex_dimension(); +void +MainWindow::show_complex_dimension() { + model_.show_complex_dimension(); } - void -MainWindow::build_rips_menu(){ - menu_uniform_neighbors_->show(); +MainWindow::build_rips_menu() { + menu_uniform_neighbors_->show(); } void -MainWindow::build_rips(double alpha){ - model_.build_rips(alpha); - update_view(); +MainWindow::build_rips(double alpha) { + model_.build_rips(alpha); + update_view(); } void -MainWindow::build_k_nearest_neighbors_menu(){ - menu_k_nearest_neighbors_->show(); +MainWindow::build_k_nearest_neighbors_menu() { + menu_k_nearest_neighbors_->show(); } void -MainWindow::build_k_nearest_neighbors(unsigned k){ - model_.build_k_nearest_neighbors(k); - update_view(); +MainWindow::build_k_nearest_neighbors(unsigned k) { + model_.build_k_nearest_neighbors(k); + update_view(); } void -MainWindow::contract_edge_menu(){ - menu_edge_contraction_->show(); +MainWindow::contract_edge_menu() { + menu_edge_contraction_->show(); } void -MainWindow::contract_edges(unsigned num_collapses){ - std::cerr <<"Collapse "<show(); +MainWindow::persistence_menu() { + menu_persistence_->show(); } void -MainWindow::compute_persistence(int p,double threshold,int max_dim,double min_pers){ - model_.show_persistence(p,threshold,max_dim,min_pers); +MainWindow::compute_persistence(int p, double threshold, int max_dim, double min_pers) { + model_.show_persistence(p, threshold, max_dim, min_pers); } void -MainWindow::critical_points_menu(){ - bool ok; - double max_length = QInputDialog::getDouble(this, tr("Maximal edge length for the Rips"), - tr("Maximal edge length:"), 0, 0, 10000, 3, &ok); - if (ok) - model_.show_critical_points(max_length); +MainWindow::critical_points_menu() { + bool ok; + double max_length = QInputDialog::getDouble(this, tr("Maximal edge length for the Rips"), + tr("Maximal edge length:"), 0, 0, 10000, 3, &ok); + if (ok) + model_.show_critical_points(max_length); } void -MainWindow::is_manifold_menu(){ - model_.show_is_manifold(); +MainWindow::is_manifold_menu() { + model_.show_is_manifold(); } diff --git a/src/GudhUI/gui/MainWindow.h b/src/GudhUI/gui/MainWindow.h index e46b72a3..c8c3fcf6 100644 --- a/src/GudhUI/gui/MainWindow.h +++ b/src/GudhUI/gui/MainWindow.h @@ -1,5 +1,27 @@ -#ifndef MAIN_WINDOW_H -#define MAIN_WINDOW_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 GUI_MAINWINDOW_H_ +#define GUI_MAINWINDOW_H_ // Workaround for moc-qt4 not parsing boost headers #include @@ -15,86 +37,82 @@ class Menu_uniform_neighbors; class Menu_edge_contraction; class Menu_persistence; -class MainWindow : public QMainWindow,public Ui::MainWindow{ - Q_OBJECT +class MainWindow : public QMainWindow, public Ui::MainWindow { + Q_OBJECT -private: - Model model_; - Viewer_instructor* viewer_instructor_; - Menu_k_nearest_neighbors* menu_k_nearest_neighbors_; - Menu_uniform_neighbors* menu_uniform_neighbors_; - Menu_edge_contraction* menu_edge_contraction_; - Menu_persistence* menu_persistence_; + private: + Model model_; + Viewer_instructor* viewer_instructor_; + Menu_k_nearest_neighbors* menu_k_nearest_neighbors_; + Menu_uniform_neighbors* menu_uniform_neighbors_; + Menu_edge_contraction* menu_edge_contraction_; + Menu_persistence* menu_persistence_; -public: - MainWindow(QWidget* parent = 0); - void connectActions(); + public: + MainWindow(QWidget* parent = 0); + void connectActions(); - /** - * compute the bounding box and calls update view - */ - void init_view() const; - void update_view() const; + /** + * compute the bounding box and calls update view + */ + void init_view() const; + void update_view() const; -protected: - void closeEvent(QCloseEvent *event); - void keyPressEvent(QKeyEvent *event){} + protected: + void closeEvent(QCloseEvent *event); -public: + void keyPressEvent(QKeyEvent *event) { } - public slots: + public: + public slots: + /** + * open a file chooser to choose an off to load + */ + void off_file_open(); + void off_points_open(); - /** - * open a file chooser to choose an off to load - */ - void off_file_open(); + /** + * open a file chooser to choose an off to save + */ + void off_file_save(); + void off_points_save(); - void off_points_open(); + void show_graph_stats(); + void show_complex_stats(); + void show_complex_dimension(); - /** - * open a file chooser to choose an off to save - */ - void off_file_save(); - void off_points_save(); - void show_graph_stats(); - void show_complex_stats(); - void show_complex_dimension(); + void build_rips_menu(); + void build_rips(double alpha); + void build_k_nearest_neighbors_menu(); + void build_k_nearest_neighbors(unsigned k); - void build_rips_menu(); - void build_rips(double alpha); - void build_k_nearest_neighbors_menu(); - void build_k_nearest_neighbors(unsigned k); + void contract_edge_menu(); + void contract_edges(unsigned num_collapses); - void contract_edge_menu(); - void contract_edges(unsigned num_collapses); + void collapse_vertices(); + void collapse_edges(); - void collapse_vertices(); - void collapse_edges(); + void uniform_noise(); + void lloyd(); + void show_homology_group(); + void show_euler_characteristic(); + void persistence_menu(); + void compute_persistence(int p, double threshold, int max_dim, double min_pers); + void critical_points_menu(); + void is_manifold_menu(); - void uniform_noise(); - void lloyd(); - - void show_homology_group(); - void show_euler_characteristic(); - void persistence_menu(); - void compute_persistence(int p,double threshold,int max_dim,double min_pers); - void critical_points_menu(); - void is_manifold_menu(); - - -public: - signals: - void sceneChanged() const; - + public: + signals: + void sceneChanged() const; }; -#endif +#endif // GUI_MAINWINDOW_H_ diff --git a/src/GudhUI/gui/Menu_edge_contraction.cpp b/src/GudhUI/gui/Menu_edge_contraction.cpp index dd2621be..a679b0bf 100644 --- a/src/GudhUI/gui/Menu_edge_contraction.cpp +++ b/src/GudhUI/gui/Menu_edge_contraction.cpp @@ -1,91 +1,97 @@ -/* - * Menu_edge_contraction.cpp +/* This file is part of the Gudhi Library. The Gudhi library + * (Geometric Understanding in Higher Dimensions) is a generic C++ + * library for computational topology. * - * Created on: Sep 11, 2014 - * Author: dsalinas + * 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 MENU_EDGE_CONTRACTION_CPP_ -#define MENU_EDGE_CONTRACTION_CPP_ - +#ifndef GUI_MENU_EDGE_CONTRACTION_CPP_ +#define GUI_MENU_EDGE_CONTRACTION_CPP_ #include "Menu_edge_contraction.h" -Menu_edge_contraction::Menu_edge_contraction(MainWindow* parent,const Model& model): -parent_(parent),model_(model) -{ - setupUi(this); - connectActions(parent_); +Menu_edge_contraction::Menu_edge_contraction(MainWindow* parent, const Model& model) : + parent_(parent), model_(model) { + setupUi(this); + connectActions(parent_); } -void Menu_edge_contraction::connectActions(MainWindow* parent) -{ - QObject::connect( - this->horizontalSlider, - SIGNAL(valueChanged(int)), - this, - SLOT(slider_value_changed(int)) - ); +void Menu_edge_contraction::connectActions(MainWindow* parent) { + QObject::connect( + this->horizontalSlider, + SIGNAL(valueChanged(int)), + this, + SLOT(slider_value_changed(int))); - QObject::connect(this, SIGNAL(contract_edges(unsigned)), parent, SLOT(contract_edges(unsigned))); - - QObject::connect(this->pushButton_collapse, SIGNAL(clicked()), this, SLOT(send_contract_edges())); + QObject::connect(this, SIGNAL(contract_edges(unsigned)), parent, SLOT(contract_edges(unsigned))); + QObject::connect(this->pushButton_collapse, SIGNAL(clicked()), this, SLOT(send_contract_edges())); } -void Menu_edge_contraction::slider_value_changed(int new_slider_value){ - int num_collapses = - (horizontalSlider->value()==1)? 1 : horizontalSlider->value() * model_.num_vertices() / 100 ; - this->txt_nb_vertices->setNum((int)model_.num_vertices()); - this->txt_nb_collapses->setNum(num_collapses); - this->spinBox_nb_remaining_vertices->setValue(model_.num_vertices()-num_collapses); +void Menu_edge_contraction::slider_value_changed(int new_slider_value) { + int num_collapses = + (horizontalSlider->value() == 1) ? 1 : horizontalSlider->value() * model_.num_vertices() / 100; + this->txt_nb_vertices->setNum(static_cast(model_.num_vertices())); + this->txt_nb_collapses->setNum(num_collapses); + this->spinBox_nb_remaining_vertices->setValue(model_.num_vertices() - num_collapses); } - void -Menu_edge_contraction::update_slider_value(){ - int num_vertices = model_.num_vertices(); - int num_collapses = (horizontalSlider->value()==1)? 1 : horizontalSlider->value() * num_vertices / 100 ; - int horizontal_slider_position = num_vertices>0? num_collapses/(double)num_vertices * 100 : 1 ; - horizontalSlider->setValue(horizontal_slider_position); +Menu_edge_contraction::update_slider_value() { + int num_vertices = model_.num_vertices(); + int num_collapses = (horizontalSlider->value() == 1) ? 1 : horizontalSlider->value() * num_vertices / 100; + int horizontal_slider_position = num_vertices > 0 ? num_collapses / static_cast(num_vertices * 100) : 1; + horizontalSlider->setValue(horizontal_slider_position); } - void -Menu_edge_contraction::update_gui_numbers(){ - update_slider_value(); - bool ok; - int num_collapses = this->txt_nb_collapses->text().toInt(&ok,10); - if(!ok) return; - this->txt_nb_vertices->setNum((int)model_.num_vertices()); - this->txt_nb_collapses->setNum(num_collapses); - this->spinBox_nb_remaining_vertices->setValue(model_.num_vertices()-num_collapses); +Menu_edge_contraction::update_gui_numbers() { + update_slider_value(); + bool ok; + int num_collapses = this->txt_nb_collapses->text().toInt(&ok, 10); + if (!ok) return; + this->txt_nb_vertices->setNum(static_cast(model_.num_vertices())); + this->txt_nb_collapses->setNum(num_collapses); + this->spinBox_nb_remaining_vertices->setValue(model_.num_vertices() - num_collapses); } void -Menu_edge_contraction::update_gui_numbers(int new_value){ - update_gui_numbers(); +Menu_edge_contraction::update_gui_numbers(int new_value) { + update_gui_numbers(); } - void -Menu_edge_contraction::send_contract_edges(){ - emit(contract_edges(num_collapses())); - update_gui_numbers(); +Menu_edge_contraction::send_contract_edges() { + emit(contract_edges(num_collapses())); + update_gui_numbers(); } unsigned -Menu_edge_contraction::num_vertices(){ - return model_.num_vertices(); +Menu_edge_contraction::num_vertices() { + return model_.num_vertices(); } unsigned -Menu_edge_contraction::num_collapses(){ - return (horizontalSlider->value()==1)? 1 : horizontalSlider->value() * num_vertices() / 100 ; +Menu_edge_contraction::num_collapses() { + return (horizontalSlider->value() == 1) ? 1 : horizontalSlider->value() * num_vertices() / 100; } - #include "Menu_edge_contraction.moc" -#endif /* MENU_EDGE_CONTRACTION_CPP_ */ +#endif // GUI_MENU_EDGE_CONTRACTION_CPP_ diff --git a/src/GudhUI/gui/Menu_edge_contraction.h b/src/GudhUI/gui/Menu_edge_contraction.h index 81d37bd8..08f0bf67 100644 --- a/src/GudhUI/gui/Menu_edge_contraction.h +++ b/src/GudhUI/gui/Menu_edge_contraction.h @@ -1,12 +1,27 @@ -/* - * Menu_edge_contraction.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. * - * Created on: Sep 11, 2014 - * Author: dsalinas + * 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 MENU_EDGE_CONTRACTION_H_ -#define MENU_EDGE_CONTRACTION_H_ +#ifndef GUI_MENU_EDGE_CONTRACTION_H_ +#define GUI_MENU_EDGE_CONTRACTION_H_ // Workaround for moc-qt4 not parsing boost headers #include @@ -16,39 +31,33 @@ #include "model/Model.h" +class Menu_edge_contraction : public QDialog, public Ui::MenuEdgeContraction { + Q_OBJECT -class Menu_edge_contraction : public QDialog,public Ui::MenuEdgeContraction{ - Q_OBJECT -private: - MainWindow* parent_; - const Model& model_; - + private: + MainWindow* parent_; + const Model& model_; - void update_slider_value(); -public: + void update_slider_value(); - Menu_edge_contraction(MainWindow* parent,const Model& model); + public: + Menu_edge_contraction(MainWindow* parent, const Model& model); - void connectActions(MainWindow* parent); + void connectActions(MainWindow* parent); + private: + unsigned num_vertices(); + unsigned num_collapses(); -private: - unsigned num_vertices(); - unsigned num_collapses(); + public slots: + void slider_value_changed(int new_slider_value); + void update_gui_numbers(); + void update_gui_numbers(int gui_numbers); - public slots: - - void slider_value_changed(int new_slider_value); - void update_gui_numbers(); - void update_gui_numbers(int); - - void send_contract_edges(); - signals: - - void contract_edges(unsigned num_collapses); + void send_contract_edges(); + signals: + void contract_edges(unsigned num_collapses); }; - - -#endif /* MENU_EDGE_CONTRACTION_H_ */ +#endif // GUI_MENU_EDGE_CONTRACTION_H_ diff --git a/src/GudhUI/gui/Menu_k_nearest_neighbors.cpp b/src/GudhUI/gui/Menu_k_nearest_neighbors.cpp index 21c67b2a..e24865f2 100644 --- a/src/GudhUI/gui/Menu_k_nearest_neighbors.cpp +++ b/src/GudhUI/gui/Menu_k_nearest_neighbors.cpp @@ -1,55 +1,59 @@ -/* - * Menu_k_nearest_neighbors.cpp +/* This file is part of the Gudhi Library. The Gudhi library + * (Geometric Understanding in Higher Dimensions) is a generic C++ + * library for computational topology. * - * Created on: Sep 11, 2014 - * Author: dsalinas + * 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 . */ - #include "Menu_k_nearest_neighbors.h" -Menu_k_nearest_neighbors::Menu_k_nearest_neighbors(QMainWindow* parent_): -parent(parent_) -{ - setupUi(this); - connectActions(parent_); +Menu_k_nearest_neighbors::Menu_k_nearest_neighbors(QMainWindow* parent_) + : parent(parent_) { + setupUi(this); + connectActions(parent_); } -void Menu_k_nearest_neighbors::connectActions(QMainWindow* parent){ - - QObject::connect( - this->pushButtonCompute, - SIGNAL(clicked()), - this, - SLOT(send_compute_k_nearest_neighbors()) - ); - QObject::connect( - this->spinBoxK, - SIGNAL(valueChanged(int)), - this, - SLOT(update_k(int)) - ); - QObject::connect( - this, - SIGNAL(compute_k_nearest_neighbors(unsigned)), - parent, - SLOT(build_k_nearest_neighbors(unsigned)) - ); - +void Menu_k_nearest_neighbors::connectActions(QMainWindow* parent) { + QObject::connect(this->pushButtonCompute, + SIGNAL(clicked()), + this, + SLOT(send_compute_k_nearest_neighbors())); + QObject::connect(this->spinBoxK, + SIGNAL(valueChanged(int)), + this, + SLOT(update_k(int))); + QObject::connect(this, + SIGNAL(compute_k_nearest_neighbors(unsigned)), + parent, + SLOT(build_k_nearest_neighbors(unsigned))); } -void Menu_k_nearest_neighbors::send_compute_k_nearest_neighbors(){ - emit(compute_k_nearest_neighbors((unsigned)spinBoxK->value())); +void Menu_k_nearest_neighbors::send_compute_k_nearest_neighbors() { + emit(compute_k_nearest_neighbors((unsigned) spinBoxK->value())); } -void Menu_k_nearest_neighbors::accept(){ - send_compute_k_nearest_neighbors(); +void Menu_k_nearest_neighbors::accept() { + send_compute_k_nearest_neighbors(); } -void Menu_k_nearest_neighbors::update_k(int new_k_value){ - if(checkBoxAutoUpdate->isChecked()) - emit(compute_k_nearest_neighbors((unsigned)spinBoxK->value())); +void Menu_k_nearest_neighbors::update_k(int new_k_value) { + if (checkBoxAutoUpdate->isChecked()) + emit(compute_k_nearest_neighbors((unsigned) spinBoxK->value())); } - #include "Menu_k_nearest_neighbors.moc" diff --git a/src/GudhUI/gui/Menu_k_nearest_neighbors.h b/src/GudhUI/gui/Menu_k_nearest_neighbors.h index d72b0074..8088b768 100644 --- a/src/GudhUI/gui/Menu_k_nearest_neighbors.h +++ b/src/GudhUI/gui/Menu_k_nearest_neighbors.h @@ -1,39 +1,51 @@ -/* - * Menu_k_nearest_neighbors.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. * - * Created on: Sep 11, 2014 - * Author: dsalinas + * 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 MENU_K_NEAREST_NEIGHBORS_H_ -#define MENU_K_NEAREST_NEIGHBORS_H_ +#ifndef GUI_MENU_K_NEAREST_NEIGHBORS_H_ +#define GUI_MENU_K_NEAREST_NEIGHBORS_H_ #include #include "gui/ui_KNearestNeighborsMenu.h" class QWidget; +class Menu_k_nearest_neighbors : public QDialog, public Ui::KNearestNeighborsMenu { + Q_OBJECT -class Menu_k_nearest_neighbors : public QDialog,public Ui::KNearestNeighborsMenu{ - Q_OBJECT -private: - QMainWindow* parent; + private: + QMainWindow* parent; -public: + public: + Menu_k_nearest_neighbors(QMainWindow* parent_); - Menu_k_nearest_neighbors(QMainWindow* parent_); + void connectActions(QMainWindow* parent); - void connectActions(QMainWindow* parent); - - public slots: - void send_compute_k_nearest_neighbors(); - void update_k(int); - void accept(); - - signals: - void compute_k_nearest_neighbors(unsigned k); + public slots: + void send_compute_k_nearest_neighbors(); + void update_k(int k); + void accept(); + signals: + void compute_k_nearest_neighbors(unsigned k); }; - -#endif /* MENU_K_NEAREST_NEIGHBORS_H_ */ +#endif // GUI_MENU_K_NEAREST_NEIGHBORS_H_ diff --git a/src/GudhUI/gui/Menu_persistence.cpp b/src/GudhUI/gui/Menu_persistence.cpp index fae3a0e6..016c076b 100644 --- a/src/GudhUI/gui/Menu_persistence.cpp +++ b/src/GudhUI/gui/Menu_persistence.cpp @@ -1,13 +1,10 @@ -/* - * Menu_persistence.cpp - * Created on: Jan 27, 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 @@ -27,34 +24,30 @@ #include "Menu_persistence.h" -Menu_persistence::Menu_persistence(QMainWindow* parent_):parent(parent_) -{ - setupUi(this); - connectActions(parent_); +Menu_persistence::Menu_persistence(QMainWindow* parent_) : parent(parent_) { + setupUi(this); + connectActions(parent_); } -void Menu_persistence::connectActions(QMainWindow* parent){ - QObject::connect( - this, - SIGNAL(compute_persistence(int,double,int,double)), - parent, - SLOT(compute_persistence(int,double,int,double)) - ); +void Menu_persistence::connectActions(QMainWindow* parent) { + QObject::connect(this, + SIGNAL(compute_persistence(int, double, int, double)), + parent, + SLOT(compute_persistence(int, double, int, double))); } -void Menu_persistence::send_compute_persistence(){ - emit(compute_persistence(p_spinBox->value(),threshold_doubleSpinBox->value(), - maxdimension_spinBox->value(),minpersistence_doubleSpinBox->value())); +void Menu_persistence::send_compute_persistence() { + emit(compute_persistence(p_spinBox->value(), threshold_doubleSpinBox->value(), + maxdimension_spinBox->value(), minpersistence_doubleSpinBox->value())); } -void Menu_persistence::accept(){ - send_compute_persistence(); +void Menu_persistence::accept() { + send_compute_persistence(); } -//void Menu_persistence::compute_persistence(int p_fied,double threshold,int dim_max,double min_persistence){ -//// if(checkBoxAutoUpdate->isChecked()) -//// emit(compute_k_nearest_neighbors((unsigned)spinBoxK->value())); -//} - +// void Menu_persistence::compute_persistence(int p_fied,double threshold,int dim_max,double min_persistence) { +// if(checkBoxAutoUpdate->isChecked()) +// emit(compute_k_nearest_neighbors((unsigned)spinBoxK->value())); +// } #include "Menu_persistence.moc" diff --git a/src/GudhUI/gui/Menu_persistence.h b/src/GudhUI/gui/Menu_persistence.h index 67b64afa..8c4df158 100644 --- a/src/GudhUI/gui/Menu_persistence.h +++ b/src/GudhUI/gui/Menu_persistence.h @@ -1,13 +1,10 @@ -/* - * Menu_persistence.h - * Created on: Jan 27, 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,36 +21,31 @@ * */ - -#ifndef MENU_PERSISTENCE_H_ -#define MENU_PERSISTENCE_H_ - +#ifndef GUI_MENU_PERSISTENCE_H_ +#define GUI_MENU_PERSISTENCE_H_ #include #include "gui/ui_PersistenceMenu.h" class QWidget; +class Menu_persistence : public QDialog, public Ui::PersistenceMenu { + Q_OBJECT -class Menu_persistence : public QDialog,public Ui::PersistenceMenu{ - Q_OBJECT -private: - QMainWindow* parent; - -public: + private: + QMainWindow* parent; - Menu_persistence(QMainWindow* parent_); + public: + Menu_persistence(QMainWindow* parent_); - void connectActions(QMainWindow* parent); + void connectActions(QMainWindow* parent); - public slots: - void send_compute_persistence(); - void accept(); - signals: - void compute_persistence(int p_fied,double threshold,int dim_max,double min_persistence); + public slots: + void send_compute_persistence(); + void accept(); + signals: + void compute_persistence(int p_fied, double threshold, int dim_max, double min_persistence); }; - - -#endif /* MENU_PERSISTENCE_H_ */ +#endif // GUI_MENU_PERSISTENCE_H_ diff --git a/src/GudhUI/gui/Menu_uniform_neighbors.cpp b/src/GudhUI/gui/Menu_uniform_neighbors.cpp index 86e2593e..20e4f98f 100644 --- a/src/GudhUI/gui/Menu_uniform_neighbors.cpp +++ b/src/GudhUI/gui/Menu_uniform_neighbors.cpp @@ -1,59 +1,60 @@ -/* - * Menu_uniform_neighbors.cpp +/* This file is part of the Gudhi Library. The Gudhi library + * (Geometric Understanding in Higher Dimensions) is a generic C++ + * library for computational topology. * - * Created on: Sep 11, 2014 - * Author: dsalinas + * 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 . + * */ - - - - #include "Menu_uniform_neighbors.h" -Menu_uniform_neighbors::Menu_uniform_neighbors(QMainWindow* parent_): -parent(parent_) -{ - setupUi(this); - connectActions(parent_); +Menu_uniform_neighbors::Menu_uniform_neighbors(QMainWindow* parent_) : + parent(parent_) { + setupUi(this); + connectActions(parent_); } -void Menu_uniform_neighbors::connectActions(QMainWindow* parent){ - - QObject::connect( - this->pushButtonCompute, - SIGNAL(clicked()), - this, - SLOT(send_compute_uniform_neighbors()) - ); - QObject::connect( - this->doubleSpinBoxAlpha, - SIGNAL(valueChanged(double)), - this, - SLOT(update_alpha(double)) - ); - QObject::connect( - this, - SIGNAL(compute_uniform_neighbors(double)), - parent, - SLOT(build_rips(double)) - ); - +void Menu_uniform_neighbors::connectActions(QMainWindow* parent) { + QObject::connect(this->pushButtonCompute, + SIGNAL(clicked()), + this, + SLOT(send_compute_uniform_neighbors())); + QObject::connect(this->doubleSpinBoxAlpha, + SIGNAL(valueChanged(double)), + this, + SLOT(update_alpha(double))); + QObject::connect(this, + SIGNAL(compute_uniform_neighbors(double)), + parent, + SLOT(build_rips(double))); } -void Menu_uniform_neighbors::send_compute_uniform_neighbors(){ - emit(compute_uniform_neighbors(doubleSpinBoxAlpha->value())); +void Menu_uniform_neighbors::send_compute_uniform_neighbors() { + emit(compute_uniform_neighbors(doubleSpinBoxAlpha->value())); } -void Menu_uniform_neighbors::accept(){ - send_compute_uniform_neighbors(); +void Menu_uniform_neighbors::accept() { + send_compute_uniform_neighbors(); } -void Menu_uniform_neighbors::update_alpha(double alpha){ - if(checkBoxAutoUpdate->isChecked()) - emit(compute_uniform_neighbors(doubleSpinBoxAlpha->value())); +void Menu_uniform_neighbors::update_alpha(double alpha) { + if (checkBoxAutoUpdate->isChecked()) + emit(compute_uniform_neighbors(doubleSpinBoxAlpha->value())); } - - #include "Menu_uniform_neighbors.moc" diff --git a/src/GudhUI/gui/Menu_uniform_neighbors.h b/src/GudhUI/gui/Menu_uniform_neighbors.h index cb90cc88..0b6f65fe 100644 --- a/src/GudhUI/gui/Menu_uniform_neighbors.h +++ b/src/GudhUI/gui/Menu_uniform_neighbors.h @@ -1,36 +1,51 @@ -/* - * Menu_uniform_neighbors.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. * - * Created on: Sep 11, 2014 - * Author: dsalinas + * 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 MENU_UNIFORM_NEIGHBORS_H_ -#define MENU_UNIFORM_NEIGHBORS_H_ +#ifndef GUI_MENU_UNIFORM_NEIGHBORS_H_ +#define GUI_MENU_UNIFORM_NEIGHBORS_H_ #include #include "gui/ui_UniformNeighborsMenu.h" -class Menu_uniform_neighbors : public QDialog,public Ui::UniformMenu { - Q_OBJECT -private: - QMainWindow* parent; - -public: +class Menu_uniform_neighbors : public QDialog, public Ui::UniformMenu { + Q_OBJECT - Menu_uniform_neighbors(QMainWindow* parent_); + private: + QMainWindow* parent; - void connectActions(QMainWindow* parent); + public: + Menu_uniform_neighbors(QMainWindow* parent_); - public slots: - void send_compute_uniform_neighbors(); - void update_alpha(double); - void accept(); + void connectActions(QMainWindow* parent); - signals: - void compute_uniform_neighbors(double alpha); + public slots: + void send_compute_uniform_neighbors(); + void update_alpha(double alpha); + void accept(); + signals: + void compute_uniform_neighbors(double alpha); }; -#endif /* MENU_UNIFORM_NEIGHBORS_H_ */ +#endif // GUI_MENU_UNIFORM_NEIGHBORS_H_ diff --git a/src/GudhUI/gui/Viewer.cpp b/src/GudhUI/gui/Viewer.cpp deleted file mode 100644 index e69de29b..00000000 diff --git a/src/GudhUI/gui/Viewer_instructor.cpp b/src/GudhUI/gui/Viewer_instructor.cpp deleted file mode 100644 index e69de29b..00000000 diff --git a/src/GudhUI/gui/gudhui.cpp b/src/GudhUI/gui/gudhui.cpp index 8d90270f..377cd2f2 100644 --- a/src/GudhUI/gui/gudhui.cpp +++ b/src/GudhUI/gui/gudhui.cpp @@ -1,15 +1,36 @@ +/* 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 . + * + */ + #include "MainWindow.h" #include #include +int main(int argc, char** argv) { + QApplication application(argc, argv); + application.setOrganizationDomain("inria.fr"); + application.setOrganizationName("INRIA"); + application.setApplicationName("GudhUI"); -int main(int argc, char** argv) -{ - QApplication application(argc,argv); - application.setOrganizationDomain("inria.fr"); - application.setOrganizationName("INRIA"); - application.setApplicationName("GudhUI"); - MainWindow mw; application.setQuitOnLastWindowClosed(false); mw.show(); diff --git a/src/GudhUI/model/Complex_typedefs.h b/src/GudhUI/model/Complex_typedefs.h index b6404d62..c310d4a6 100644 --- a/src/GudhUI/model/Complex_typedefs.h +++ b/src/GudhUI/model/Complex_typedefs.h @@ -1,39 +1,49 @@ -/* - * Complex_typedefs.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. * - * Created on: Aug 26, 2014 - * Author: dsalinas + * 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 COMPLEX_TYPEDEFS_H_ -#define COMPLEX_TYPEDEFS_H_ - +#ifndef MODEL_COMPLEX_TYPEDEFS_H_ +#define MODEL_COMPLEX_TYPEDEFS_H_ - -#include "gudhi/Skeleton_blocker/Skeleton_blocker_simple_geometric_traits.h" -#include "gudhi/Skeleton_blocker_geometric_complex.h" +#include +#include #include - #include #include - struct Geometry_trait : public CGAL::Cartesian_d { - typedef CGAL::Cartesian::Point_3 Point_3; - typedef CGAL::Cartesian::Vector_3 Vector_3; - typedef CGAL::Point_d> Point; - typedef CGAL::Vector_d> Vector; + typedef CGAL::Cartesian::Point_3 Point_3; + typedef CGAL::Cartesian::Vector_3 Vector_3; + typedef CGAL::Point_d> Point; + typedef CGAL::Vector_d> Vector; }; typedef Geometry_trait::Point Point; - using namespace Gudhi; using namespace Gudhi::skbl; typedef Skeleton_blocker_simple_geometric_traits Complex_geometric_traits; typedef Skeleton_blocker_geometric_complex< Complex_geometric_traits > Complex; - -#endif /* COMPLEX_TYPEDEFS_H_ */ +#endif // MODEL_COMPLEX_TYPEDEFS_H_ diff --git a/src/GudhUI/model/Model.h b/src/GudhUI/model/Model.h index 17a7d278..d78cbad9 100644 --- a/src/GudhUI/model/Model.h +++ b/src/GudhUI/model/Model.h @@ -1,16 +1,41 @@ -/* - * Model.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. * - * Created on: Aug 25, 2014 - * Author: david + * 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 MODEL_H_ -#define MODEL_H_ +#ifndef MODEL_MODEL_H_ +#define MODEL_MODEL_H_ + +#include +#include +#include +#include + +#include #include #include -#include "gudhi/Clock.h" +#include +#include + #include "utils/UI_utils.h" #include "utils/Lloyd_builder.h" #include "utils/Rips_builder.h" @@ -22,328 +47,309 @@ #include "utils/Critical_points.h" #include "utils/Is_manifold.h" -#include "gudhi/Skeleton_blocker/Skeleton_blocker_simple_geometric_traits.h" -#include "gudhi/Skeleton_blocker_geometric_complex.h" - -#include "gudhi/Off_reader.h" - #include "Complex_typedefs.h" - -#include - - template -class CGAL_geometric_flag_complex_wrapper{ - Complex& complex_; - typedef typename Complex::Vertex_handle Vertex_handle; - typedef typename Complex::Point Point; - - const bool load_only_points_; - -public: - CGAL_geometric_flag_complex_wrapper(Complex& complex,bool load_only_points = false): - complex_(complex), - load_only_points_(load_only_points){ - } - - void init(int dim,int num_vertices,int num_max_faces,int num_edges) const{ - } - - void point(const std::vector& coords){ - Point p(coords.size(),coords.begin(),coords.end()); - complex_.add_vertex(p); - } - - void maximal_face(std::vector vertices){ - if (!load_only_points_){ - std::cout<<"size:"<& coords) { + Point p(coords.size(), coords.begin(), coords.end()); + complex_.add_vertex(p); + } + + void maximal_face(std::vector vertices) { + if (!load_only_points_) { + std::cout << "size:" << vertices.size() << std::endl; + for (int i = 0; i < vertices.size(); ++i) + for (int j = i + 1; j < vertices.size(); ++j) + complex_.add_edge(Vertex_handle(vertices[i]), Vertex_handle(vertices[j])); + } + } + + void done() const { } }; - -class Model{ - -public: - Complex complex_; - typedef Complex::Vertex_handle Vertex_handle; - - Model():complex_(){ - } - -public: - void off_file_open(const std::string& name_file){ - UIDBGMSG("load off file",name_file); - complex_.clear(); - CGAL_geometric_flag_complex_wrapper read_wraper(complex_,false); - Gudhi::read_off(name_file,read_wraper); - } - - void off_points_open(const std::string& name_file){ - UIDBGMSG("load off points",name_file); - complex_.clear(); - CGAL_geometric_flag_complex_wrapper read_wraper(complex_,true); - Gudhi::read_off(name_file,read_wraper); - } - - void off_file_save(const std::string& name_file){ - UIDBG("save off file"); - UIDBG("save off off_points_save"); - std::ofstream file(name_file); - if(file.is_open()){ - file<<"OFF\n"; - file< new_point(point.dimension()); - for(int i = 0 ; i < point.dimension();++i){ - new_point[i] = point[i] + (rand() % 2 - .5) * amplitude; - } - return Point(point.dimension(), new_point.begin(),new_point.end()); - } - -public: - - void lloyd(int num_iterations,int num_closest_neighbors){ - UIDBG("lloyd"); - Lloyd_builder lloyd_builder(complex_,1); - } - - double squared_eucl_distance(const Point& p1,const Point& p2) const{ - return Geometry_trait::Squared_distance_d()(p1,p2); - } - - // complex operations from points - void build_rips(double alpha){ - UIDBG("build_rips"); - Rips_builder rips_builder(complex_,alpha); - } - - void build_k_nearest_neighbors(unsigned k){ - UIDBG("build_k_nearest"); - complex_.keep_only_vertices(); - K_nearest_builder k_nearest_builder(complex_,k); - } - - void build_delaunay(){ - UIDBG("build_delaunay"); - complex_.keep_only_vertices(); - } - - - - void contract_edges(unsigned num_contractions){ - Clock c; - Edge_contractor contractor(complex_,num_contractions); - std::cout<<"Time to simplify: "< collapsor(complex_,complex_.num_vertices()); - UIDBGMSG("num vertices collapsed:",old_num_vertices - complex_.num_vertices()); - } - - void collapse_edges(unsigned num_collapses){ - Edge_collapsor collapsor(complex_,num_collapses); - } - - - void show_graph_stats(){ - std::cout << "++++++ Graph stats +++++++"<< std::endl; - std::cout << "Num vertices : " << complex_.num_vertices()<::max)(); - for(auto v : complex_.vertex_range()) - res= (std::min)(res,complex_.degree(v)); - return res; - } - - int max_degree() const{ - int res = 0; - for(auto v : complex_.vertex_range()) - res= (std::max)(res,complex_.degree(v)); - return res; - } - - int avg_degree() const{ - int res = 0; - for(auto v : complex_.vertex_range()) - res+= complex_.degree(v); - return res / complex_.num_vertices(); - } - -public: - - - - void show_complex_stats(){ - std::cout << "++++++ Mesh stats +++++++"<< std::endl; - std::cout << "Num vertices : " << complex_.num_vertices()< read_wraper(complex_, false); + Gudhi::read_off(name_file, read_wraper); + } + + void off_points_open(const std::string& name_file) { + UIDBGMSG("load off points", name_file); + complex_.clear(); + CGAL_geometric_flag_complex_wrapper read_wraper(complex_, true); + Gudhi::read_off(name_file, read_wraper); + } + + void off_file_save(const std::string& name_file) { + UIDBG("save off file"); + UIDBG("save off off_points_save"); + std::ofstream file(name_file); + if (file.is_open()) { + file << "OFF\n"; + file << complex_.num_vertices() << " " << complex_.num_edges() << " 0\n"; + for (auto v : complex_.vertex_range()) { + const auto& pt(complex_.point(v)); + for (auto it = pt.cartesian_begin(); it != pt.cartesian_end(); ++it) + file << *it << " "; + file << std::endl; + } + for (auto e : complex_.edge_range()) + file << "2 " << complex_.first_vertex(e) << " " << complex_.second_vertex(e) << "\n"; + file.close(); + } else { + std::cerr << "Could not open file " << name_file << std::endl; + } + } + + void off_points_save(const std::string& name_file) { + UIDBG("save off off_points_save"); + std::ofstream file(name_file); + if (file.is_open()) { + file << "OFF\n"; + file << complex_.num_vertices() << " 0 0\n"; + for (auto v : complex_.vertex_range()) { + const auto& pt(complex_.point(v)); + for (auto it = pt.cartesian_begin(); it != pt.cartesian_end(); ++it) + file << *it << " "; + file << std::endl; + } + file.close(); + } else { + std::cerr << "Could not open file " << name_file << std::endl; + } + } + + // point sets operations + void uniform_noise(double amplitude) { + UIDBG("unif noise"); + for (auto v : complex_.vertex_range()) + complex_.point(v) = add_uniform_noise(complex_.point(v), amplitude); + } + + private: + Point add_uniform_noise(const Point& point, double amplitude) { + std::vector new_point(point.dimension()); + for (int i = 0; i < point.dimension(); ++i) { + new_point[i] = point[i] + (rand() % 2 - .5) * amplitude; + } + return Point(point.dimension(), new_point.begin(), new_point.end()); + } + + public: + void lloyd(int num_iterations, int num_closest_neighbors) { + UIDBG("lloyd"); + Lloyd_builder lloyd_builder(complex_, 1); + } + + double squared_eucl_distance(const Point& p1, const Point& p2) const { + return Geometry_trait::Squared_distance_d()(p1, p2); + } + + // complex operations from points + + void build_rips(double alpha) { + UIDBG("build_rips"); + Rips_builder rips_builder(complex_, alpha); + } + + void build_k_nearest_neighbors(unsigned k) { + UIDBG("build_k_nearest"); + complex_.keep_only_vertices(); + K_nearest_builder k_nearest_builder(complex_, k); + } + + void build_delaunay() { + UIDBG("build_delaunay"); + complex_.keep_only_vertices(); + } + + void contract_edges(unsigned num_contractions) { + Clock c; + Edge_contractor contractor(complex_, num_contractions); + std::cout << "Time to simplify: " << c.num_seconds() << "s" << std::endl; + } + + void collapse_vertices(unsigned num_collapses) { + auto old_num_vertices = complex_.num_vertices(); + Vertex_collapsor collapsor(complex_, complex_.num_vertices()); + UIDBGMSG("num vertices collapsed:", old_num_vertices - complex_.num_vertices()); + } + + void collapse_edges(unsigned num_collapses) { + Edge_collapsor collapsor(complex_, num_collapses); + } + + void show_graph_stats() { + std::cout << "++++++ Graph stats +++++++" << std::endl; + std::cout << "Num vertices : " << complex_.num_vertices() << std::endl; + std::cout << "Num edges : " << complex_.num_edges() << std::endl; + std::cout << "Num connected components : " << complex_.num_connected_components() << std::endl; + std::cout << "Min/avg/max degree : " << min_degree() << "/" << avg_degree() << "/" << max_degree() << std::endl; + std::cout << "Num connected components : " << complex_.num_connected_components() << std::endl; + std::cout << "Num connected components : " << complex_.num_connected_components() << std::endl; + std::cout << "+++++++++++++++++++++++++" << std::endl; + } + + private: + int min_degree() const { + int res = (std::numeric_limits::max)(); + for (auto v : complex_.vertex_range()) + res = (std::min)(res, complex_.degree(v)); + return res; + } + + int max_degree() const { + int res = 0; + for (auto v : complex_.vertex_range()) + res = (std::max)(res, complex_.degree(v)); + return res; + } + + int avg_degree() const { + int res = 0; + for (auto v : complex_.vertex_range()) + res += complex_.degree(v); + return res / complex_.num_vertices(); + } + + public: + void show_complex_stats() { + std::cout << "++++++ Mesh stats +++++++" << std::endl; + std::cout << "Num vertices : " << complex_.num_vertices() << std::endl; + std::cout << "Num edges : " << complex_.num_edges() << std::endl; + std::cout << "Num connected components : " << complex_.num_connected_components() << std::endl; + std::cout << "+++++++++++++++++++++++++" << std::endl; + } + + void show_complex_dimension() { + unsigned num_simplices = 0; + int euler = 0; + int dimension = 0; + Clock clock; + for (const auto &s : complex_.simplex_range()) { + num_simplices++; + dimension = (std::max)(s.dimension(), dimension); + if (s.dimension() % 2 == 0) + euler += 1; + else + euler -= 1; + } + clock.end(); + std::cout << "++++++ Mesh dimension +++++++" << std::endl; + std::cout << "Dimension : " << dimension << std::endl; + std::cout << "Euler characteristic : " << euler << std::endl; + std::cout << "Num simplices : " << num_simplices << std::endl; + std::cout << "Total time: " << clock << std::endl; + std::cout << "Time per simplex: " << clock.num_seconds() / num_simplices << " s" << std::endl; + std::cout << "+++++++++++++++++++++++++" << std::endl; + } + + void show_homology_group() { #ifdef _WIN32 - std::cout << "Works only on linux x64 for the moment\n"; + std::cout << "Works only on linux x64 for the moment\n"; #else - Clock clock; - run_chomp(); - clock.end(); + Clock clock; + run_chomp(); + clock.end(); #endif - } - - void show_euler_characteristic(){ - unsigned num_simplices = 0; - int euler = 0; - int dimension = 0; - for(const auto &s : complex_.simplex_range()){ - num_simplices++; - dimension = (std::max)(s.dimension(),dimension); - if(s.dimension()%2==0) - euler+=1; - else - euler-=1; - } - std::cout << "Saw "< persistence(complex_,std::cout,Persistence_params(p,threshold,max_dim,min_pers)); - } - - void show_critical_points(double max_distance){ - Critical_points critical_points(complex_,std::cout,max_distance); - } - - void show_is_manifold(){ - unsigned dim; - bool is_manifold; - Is_manifold test_manifold(complex_,dim,is_manifold); - - if(is_manifold) std::cout << "The complex is a "<=4 and may or may not be a manifold\n"; - } - - -private: - void run_chomp(){ - save_complex_in_file_for_chomp(); - std::cout << "Call CHOMP library\n"; - int returnValue = system("utils/homsimpl chomp.sim"); - std::cout << "CHOMP returns" << returnValue << std::endl; - } - - void save_complex_in_file_for_chomp(){ - std::ofstream file; - file.open("chomp.sim"); - for(const auto &s : complex_.simplex_range()){ - bool first = true; - file<<"("; - for(auto x : s){ - if(first) first = false; - else file<<","; - file << x; - } - file<<")\n"; - } - } -public: - - - unsigned num_vertices() const{ - return complex_.num_vertices(); - } - - unsigned num_edges() const{ - return complex_.num_edges(); - } - + } + + void show_euler_characteristic() { + unsigned num_simplices = 0; + int euler = 0; + int dimension = 0; + for (const auto &s : complex_.simplex_range()) { + num_simplices++; + dimension = (std::max)(s.dimension(), dimension); + if (s.dimension() % 2 == 0) + euler += 1; + else + euler -= 1; + } + std::cout << "Saw " << num_simplices << " simplices with maximum dimension " << dimension << std::endl; + std::cout << "The euler characteristic is : " << euler << std::endl; + } + + void show_persistence(int p, double threshold, int max_dim, double min_pers) { + Persistence_compute persistence(complex_, std::cout, Persistence_params(p, threshold, max_dim, min_pers)); + } + + void show_critical_points(double max_distance) { + Critical_points critical_points(complex_, std::cout, max_distance); + } + + void show_is_manifold() { + unsigned dim; + bool is_manifold; + Is_manifold test_manifold(complex_, dim, is_manifold); + + if (is_manifold) { + std::cout << "The complex is a " << dim << "-manifold\n"; + } else { + if (dim < 4) { + std::cout << "The complex has dimension greater than " << dim << " and is not a manifold\n"; + } else { + std::cout << "The complex has dimension>=4 and may or may not be a manifold\n"; + } + } + } + + private: + void run_chomp() { + save_complex_in_file_for_chomp(); + std::cout << "Call CHOMP library\n"; + int returnValue = system("utils/homsimpl chomp.sim"); + std::cout << "CHOMP returns" << returnValue << std::endl; + } + + void save_complex_in_file_for_chomp() { + std::ofstream file; + file.open("chomp.sim"); + for (const auto &s : complex_.simplex_range()) { + bool first = true; + file << "("; + for (auto x : s) { + if (first) + first = false; + else + file << ","; + file << x; + } + file << ")\n"; + } + } + + public: + unsigned num_vertices() const { + return complex_.num_vertices(); + } + + unsigned num_edges() const { + return complex_.num_edges(); + } }; -#endif /* MODEL_H_ */ +#endif // MODEL_MODEL_H_ diff --git a/src/GudhUI/utils/Critical_points.h b/src/GudhUI/utils/Critical_points.h index 92392d4a..3021a5fe 100644 --- a/src/GudhUI/utils/Critical_points.h +++ b/src/GudhUI/utils/Critical_points.h @@ -1,13 +1,10 @@ -/* - * Critical_points.h - * Created on: Jan 27, 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,11 +21,13 @@ * */ - -#ifndef CRITICAL_POINTS_H_ -#define CRITICAL_POINTS_H_ +#ifndef UTILS_CRITICAL_POINTS_H_ +#define UTILS_CRITICAL_POINTS_H_ #include +#include // for pair<> +#include // for sort + #include "utils/Edge_contractor.h" /** @@ -37,101 +36,97 @@ * * todo do a sparsification with some parameter eps while growing */ -template class Critical_points{ -private: - SkBlComplex filled_complex_; - const SkBlComplex& input_complex_; - double max_length_; - std::ostream& stream_; -public: - typedef typename SkBlComplex::Vertex_handle Vertex_handle; - typedef typename SkBlComplex::Edge_handle Edge_handle; - typedef typename std::pair Edge; - - /** - * @brief check all pair of points with length smaller than max_length - */ - Critical_points(const SkBlComplex& input_complex,std::ostream& stream,double max_length): - input_complex_(input_complex),max_length_(max_length),stream_(stream) - { - - std::deque edges; - auto vertices = input_complex.vertex_range(); - for(auto p = vertices.begin(); p!= vertices.end(); ++p){ - filled_complex_.add_vertex(input_complex.point(*p)); - for (auto q = p; ++q != vertices.end(); /**/) - if (squared_eucl_distance(input_complex.point(*p),input_complex.point(*q)) < max_length_*max_length_) - edges.emplace_back(*p,*q); - } - - std::sort(edges.begin(),edges.end(), - [&](Edge e1,Edge e2){ - return squared_edge_length(e1) < squared_edge_length(e2); - }); - - anti_collapse_edges(edges); - - } - -private: - double squared_eucl_distance(const Point& p1,const Point& p2) const{ - return Geometry_trait::Squared_distance_d()(p1,p2); - } - - - void anti_collapse_edges(const std::deque& edges){ - unsigned pos = 0; - for(Edge e : edges){ - std::cout<<"edge "< not - //1 -> yes - //2 -> maybe - int is_link_reducible(Edge_handle e){ - auto link = filled_complex_.link(e); - - if(link.empty()) return 0; - - Edge_contractor contractor(link,link.num_vertices()-1); - - if(link.num_connected_components()>1) return 0; //one than more CC -> not contractible - - if (link.num_vertices()==1) return 1; //reduced to one point -> contractible - else return 2; //we dont know - } - - - double squared_edge_length(Edge_handle e) const{ - return squared_eucl_distance(input_complex_.point(input_complex_.first_vertex(e)),input_complex_.point(input_complex_.second_vertex(e))); - } - - double squared_edge_length(Edge e) const{ - return squared_eucl_distance(input_complex_.point(e.first),input_complex_.point(e.second)); - } - - - +template class Critical_points { + private: + SkBlComplex filled_complex_; + const SkBlComplex& input_complex_; + double max_length_; + std::ostream& stream_; + + public: + typedef typename SkBlComplex::Vertex_handle Vertex_handle; + typedef typename SkBlComplex::Edge_handle Edge_handle; + typedef typename std::pair Edge; + + /** + * @brief check all pair of points with length smaller than max_length + */ + Critical_points(const SkBlComplex& input_complex, std::ostream& stream, double max_length) : + input_complex_(input_complex), max_length_(max_length), stream_(stream) { + std::deque edges; + auto vertices = input_complex.vertex_range(); + for (auto p = vertices.begin(); p != vertices.end(); ++p) { + filled_complex_.add_vertex(input_complex.point(*p)); + for (auto q = p; ++q != vertices.end(); /**/) + if (squared_eucl_distance(input_complex.point(*p), input_complex.point(*q)) < max_length_ * max_length_) + edges.emplace_back(*p, *q); + } + + std::sort(edges.begin(), edges.end(), + [&](Edge e1, Edge e2) { + return squared_edge_length(e1) < squared_edge_length(e2); + }); + + anti_collapse_edges(edges); + } + + private: + double squared_eucl_distance(const Point& p1, const Point& p2) const { + return Geometry_trait::Squared_distance_d()(p1, p2); + } + + void anti_collapse_edges(const std::deque& edges) { + unsigned pos = 0; + for (Edge e : edges) { + std::cout << "edge " << pos++ << "/" << edges.size() << "\n"; + auto eh = filled_complex_.add_edge(e.first, e.second); + int is_contractible(is_link_reducible(eh)); + + switch (is_contractible) { + case 0: + stream_ << "alpha=" << std::sqrt(squared_edge_length(e)) << " topological change" << std::endl; + break; + case 2: + stream_ << "alpha=" << std::sqrt(squared_edge_length(e)) << " maybe a topological change" << std::endl; + break; + default: + break; + } + } + } + + // 0 -> not + // 1 -> yes + // 2 -> maybe + + int is_link_reducible(Edge_handle e) { + auto link = filled_complex_.link(e); + + if (link.empty()) + return 0; + + Edge_contractor contractor(link, link.num_vertices() - 1); + + if (link.num_connected_components() > 1) + // one than more CC -> not contractible + return 0; + + if (link.num_vertices() == 1) + // reduced to one point -> contractible + return 1; + else + // we dont know + return 2; + } + + double squared_edge_length(Edge_handle e) const { + return squared_eucl_distance(input_complex_.point(input_complex_.first_vertex(e)), + input_complex_.point(input_complex_.second_vertex(e))); + } + + double squared_edge_length(Edge e) const { + return squared_eucl_distance(input_complex_.point(e.first), input_complex_.point(e.second)); + } }; - - - - -#endif /* CRITICAL_POINTS_H_ */ +#endif // UTILS_CRITICAL_POINTS_H_ diff --git a/src/GudhUI/utils/Edge_collapsor.h b/src/GudhUI/utils/Edge_collapsor.h index 4dcd18ac..fcf2a248 100644 --- a/src/GudhUI/utils/Edge_collapsor.h +++ b/src/GudhUI/utils/Edge_collapsor.h @@ -1,12 +1,28 @@ -/* - * Collapsor.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. * - * Created on: Sep 25, 2014 - * Author: dsalinas + * 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 COLLAPSOR_H_ -#define COLLAPSOR_H_ +#ifndef UTILS_COLLAPSOR_H_ +#define UTILS_COLLAPSOR_H_ #include #include "utils/Edge_contractor.h" @@ -15,71 +31,67 @@ /** * Iteratively puts every vertex at the center of its neighbors */ -template class Edge_collapsor{ -private: - SkBlComplex& complex_; - unsigned num_collapses_; -public: - typedef typename SkBlComplex::Vertex_handle Vertex_handle; - typedef typename SkBlComplex::Edge_handle Edge_handle; - - /** - * @brief Collapse num_collapses edges. If num_collapses<0 then it collapses all possible edges. - * Largest edges are collapsed first. - * - */ - Edge_collapsor(SkBlComplex& complex,unsigned num_collapses): - complex_(complex),num_collapses_(num_collapses) - { - std::list edges; - edges.insert(edges.begin(),complex_.edge_range().begin(),complex_.edge_range().end()); - - edges.sort( - [&](Edge_handle e1,Edge_handle e2){ - return squared_edge_length(e1) < squared_edge_length(e2); - }); - - collapse_edges(edges); - - } - -private: - - void collapse_edges(std::list& edges){ - while(!edges.empty() && num_collapses_--){ - Edge_handle current_edge = edges.front(); - edges.pop_front(); - if(is_link_reducible(current_edge)) - complex_.remove_edge(current_edge); - } - - } - - bool is_link_reducible(Edge_handle e){ - auto link = complex_.link(e); - - if(link.empty()) return false; - - if(link.is_cone()) return true; - - if(link.num_connected_components()>1) return false; - - Edge_contractor contractor(link,link.num_vertices()-1); - - return (link.num_vertices()==1); - } - - - double squared_edge_length(Edge_handle e) const{ - return squared_eucl_distance(complex_.point(complex_.first_vertex(e)),complex_.point(complex_.second_vertex(e))); - } - - double squared_eucl_distance(const Point& p1,const Point& p2) const{ - return Geometry_trait::Squared_distance_d()(p1,p2); - } - +template class Edge_collapsor { + private: + SkBlComplex& complex_; + unsigned num_collapses_; + + public: + typedef typename SkBlComplex::Vertex_handle Vertex_handle; + typedef typename SkBlComplex::Edge_handle Edge_handle; + + /** + * @brief Collapse num_collapses edges. If num_collapses<0 then it collapses all possible edges. + * Largest edges are collapsed first. + * + */ + Edge_collapsor(SkBlComplex& complex, unsigned num_collapses) : + complex_(complex), num_collapses_(num_collapses) { + std::list edges; + edges.insert(edges.begin(), complex_.edge_range().begin(), complex_.edge_range().end()); + + edges.sort( + [&](Edge_handle e1, Edge_handle e2) { + return squared_edge_length(e1) < squared_edge_length(e2); + }); + + collapse_edges(edges); + } + + private: + void collapse_edges(std::list& edges) { + while (!edges.empty() && num_collapses_--) { + Edge_handle current_edge = edges.front(); + edges.pop_front(); + if (is_link_reducible(current_edge)) + complex_.remove_edge(current_edge); + } + } + + bool is_link_reducible(Edge_handle e) { + auto link = complex_.link(e); + + if (link.empty()) + return false; + + if (link.is_cone()) + return true; + + if (link.num_connected_components() > 1) + return false; + + Edge_contractor contractor(link, link.num_vertices() - 1); + + return (link.num_vertices() == 1); + } + + double squared_edge_length(Edge_handle e) const { + return squared_eucl_distance(complex_.point(complex_.first_vertex(e)), complex_.point(complex_.second_vertex(e))); + } + + double squared_eucl_distance(const Point& p1, const Point& p2) const { + return Geometry_trait::Squared_distance_d()(p1, p2); + } }; - - -#endif /* COLLAPSOR_H_ */ +#endif // UTILS_COLLAPSOR_H_ diff --git a/src/GudhUI/utils/Edge_contractor.h b/src/GudhUI/utils/Edge_contractor.h index d0a1f866..053aac04 100644 --- a/src/GudhUI/utils/Edge_contractor.h +++ b/src/GudhUI/utils/Edge_contractor.h @@ -1,85 +1,97 @@ -/* - * Contractor.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. * - * Created on: Sep 25, 2014 - * Author: dsalinas + * 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 EDGE_CONTRACTOR_H_ -#define EDGE_CONTRACTOR_H_ +#ifndef UTILS_EDGE_CONTRACTOR_H_ +#define UTILS_EDGE_CONTRACTOR_H_ -#include "gudhi/Skeleton_blocker_contractor.h" - -#include "gudhi/Contraction/Edge_profile.h" -#include "gudhi/Contraction/policies/Cost_policy.h" +#include +#include +#include +#include /** * Iteratively puts every vertex at the center of its neighbors */ -template class Edge_contractor{ -private: - SkBlComplex& complex_; - unsigned num_contractions_; - - /** - * @brief return a cost corresponding to the squared length of the edge - */ - template< typename EdgeProfile> class Length_cost : public contraction::Cost_policy{ - public: - typedef typename contraction::Cost_policy::Cost_type Cost_type; - typedef typename EdgeProfile::Point Point; - Cost_type operator()(const EdgeProfile& profile, const boost::optional& placement) const override{ - Cost_type res; - if(!placement) return res; - return Geometry_trait::Squared_distance_d()(profile.p0(),profile.p1()); //not working?? - } - }; - - - /** - * @brief return a cost corresponding to the squared length of the edge - */ - template< typename EdgeProfile> class Middle_placement : public contraction::Placement_policy{ - public: - typedef typename contraction::Placement_policy::Placement_type Placement_type; - typedef typename EdgeProfile::Point Point; - Placement_type operator()(const EdgeProfile& profile) const override{ - std::vector mid_coords(profile.p0().dimension(),0); - for (size_t i = 0; i < profile.p0().dimension(); ++i){ - mid_coords[i] = (profile.p0()[i] + profile.p1()[i]) / 2.; - } - return Point(profile.p0().dimension(),mid_coords.begin(), mid_coords.end()); - } - }; - - public: - typedef typename SkBlComplex::Vertex_handle Vertex_handle; - typedef typename SkBlComplex::Edge_handle Edge_handle; - - /** - * @brief Modify complex to be the expansion of the k-nearest neighbor - * symetric graph. - */ - Edge_contractor(SkBlComplex& complex,unsigned num_contractions): - complex_(complex),num_contractions_(num_contractions) - { - typedef typename contraction::Edge_profile Profile; - num_contractions = (std::min)((int)num_contractions,(int)(complex_.num_vertices()-1)); - contraction::Skeleton_blocker_contractor contractor( - complex_, - new Length_cost>(), - new Middle_placement>(), - contraction::make_link_valid_contraction(), - contraction::make_remove_popable_blockers_visitor() - ); - contractor.contract_edges(num_contractions); - } - - +template class Edge_contractor { + private: + SkBlComplex& complex_; + unsigned num_contractions_; + + /** + * @brief return a cost corresponding to the squared length of the edge + */ + template< typename EdgeProfile> class Length_cost : public contraction::Cost_policy { + public: + typedef typename contraction::Cost_policy::Cost_type Cost_type; + typedef typename EdgeProfile::Point Point; + + Cost_type operator()(const EdgeProfile& profile, const boost::optional& placement) const override { + Cost_type res; + if (!placement) + return res; + return Geometry_trait::Squared_distance_d()(profile.p0(), profile.p1()); // not working?? + } + }; + + /** + * @brief return a cost corresponding to the squared length of the edge + */ + template< typename EdgeProfile> class Middle_placement : public contraction::Placement_policy { + public: + typedef typename contraction::Placement_policy::Placement_type Placement_type; + typedef typename EdgeProfile::Point Point; + + Placement_type operator()(const EdgeProfile& profile) const override { + std::vector mid_coords(profile.p0().dimension(), 0); + for (size_t i = 0; i < profile.p0().dimension(); ++i) { + mid_coords[i] = (profile.p0()[i] + profile.p1()[i]) / 2.; + } + return Point(profile.p0().dimension(), mid_coords.begin(), mid_coords.end()); + } + }; + + public: + typedef typename SkBlComplex::Vertex_handle Vertex_handle; + typedef typename SkBlComplex::Edge_handle Edge_handle; + + /** + * @brief Modify complex to be the expansion of the k-nearest neighbor + * symetric graph. + */ + Edge_contractor(SkBlComplex& complex, unsigned num_contractions) : + complex_(complex), num_contractions_(num_contractions) { + typedef typename contraction::Edge_profile Profile; + num_contractions = (std::min)(static_cast(num_contractions), static_cast(complex_.num_vertices() - 1)); + typedef typename contraction::Skeleton_blocker_contractor Contractor; + Contractor contractor(complex_, + new Length_cost> (), + new Middle_placement> (), + contraction::make_link_valid_contraction(), + contraction::make_remove_popable_blockers_visitor()); + contractor.contract_edges(num_contractions); + } }; - - #endif /* EDGE_CONTRACTOR_H_ */ diff --git a/src/GudhUI/utils/Furthest_point_epsilon_net.h b/src/GudhUI/utils/Furthest_point_epsilon_net.h index 590b65c4..f2a216f6 100644 --- a/src/GudhUI/utils/Furthest_point_epsilon_net.h +++ b/src/GudhUI/utils/Furthest_point_epsilon_net.h @@ -1,134 +1,132 @@ -/* - * Furthest_point_epsilon_net.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. * - * Created on: Sep 26, 2014 - * Author: dsalinas + * 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 FURTHEST_POINT_EPSILON_NET_H_ -#define FURTHEST_POINT_EPSILON_NET_H_ +#ifndef UTILS_FURTHEST_POINT_EPSILON_NET_H_ +#define UTILS_FURTHEST_POINT_EPSILON_NET_H_ -#include "utils/UI_utils.h" #include +#include // for sort + +#include "utils/UI_utils.h" /** * Computes an epsilon net with furthest point strategy. */ -template class Furthest_point_epsilon_net{ -private: - SkBlComplex& complex_; - typedef typename SkBlComplex::Vertex_handle Vertex_handle; - typedef typename SkBlComplex::Edge_handle Edge_handle; - - /** - * Let V be the set of vertices. - * Initially v0 is one arbitrarly vertex and the set V0 is {v0}. - * Then Vk is computed as follows. - * First we compute the vertex pk that is the furthest from Vk - * then Vk = Vk \cup pk. - * The radius of pk is its distance to Vk and its meeting vertex - * is the vertex of Vk for which this distance is achieved. - */ - struct Net_filtration_vertex{ - Vertex_handle vertex_handle; - Vertex_handle meeting_vertex; - double radius; - - - Net_filtration_vertex( - Vertex_handle vertex_handle_, - Vertex_handle meeting_vertex_, - double radius_): - vertex_handle(vertex_handle_),meeting_vertex(meeting_vertex_),radius(radius_) - {} - - bool operator<(const Net_filtration_vertex& other ) const{ - return radius < other.radius; - } - - }; - -public: - - - std::vector net_filtration_; - - /** - * @brief Modify complex to be the expansion of the k-nearest neighbor - * symetric graph. - */ - Furthest_point_epsilon_net(SkBlComplex& complex): - complex_(complex) - { - if(!complex.empty()){ - init_filtration(); - for(int k = 2; k < net_filtration_.size(); ++k){ - update_radius_value(k); - } - } - } - - //xxx does not work if complex not full - double radius(Vertex_handle v){ - return net_filtration_[v.vertex].radius; - } - - - - -private: - - void init_filtration(){ - Vertex_handle v0 = *(complex_.vertex_range().begin()); - net_filtration_.reserve(complex_.num_vertices()); - for(auto v : complex_.vertex_range()){ - if(v != v0) - net_filtration_.push_back( - Net_filtration_vertex(v, - Vertex_handle(-1), - squared_eucl_distance(v,v0)) - ); - } - net_filtration_.push_back(Net_filtration_vertex(v0,Vertex_handle(-1),1e10)); - auto n = net_filtration_.size(); - sort_filtration(n-1); - } - - void update_radius_value(int k){ - int n = net_filtration_.size(); - int index_to_update = n-k; - for(int i = 0; i< index_to_update; ++i){ - net_filtration_[i].radius = (std::min)(net_filtration_[i].radius , - squared_eucl_distance( - net_filtration_[i].vertex_handle, - net_filtration_[index_to_update].vertex_handle - ) - ); - } - sort_filtration(n-k); - } - - /** - * sort all i first elements. - */ - void sort_filtration(int i){ - std::sort(net_filtration_.begin(),net_filtration_.begin()+ i); - } - - double squared_eucl_distance(Vertex_handle v1,Vertex_handle v2) const{ - return std::sqrt(Geometry_trait::Squared_distance_d()( - complex_.point(v1),complex_.point(v2)) - ); - } - - void print_filtration() const{ - for(auto v : net_filtration_){ - std::cerr <<"v="< d="< class Furthest_point_epsilon_net { + private: + SkBlComplex& complex_; + typedef typename SkBlComplex::Vertex_handle Vertex_handle; + typedef typename SkBlComplex::Edge_handle Edge_handle; + + /** + * Let V be the set of vertices. + * Initially v0 is one arbitrarly vertex and the set V0 is {v0}. + * Then Vk is computed as follows. + * First we compute the vertex pk that is the furthest from Vk + * then Vk = Vk \cup pk. + * The radius of pk is its distance to Vk and its meeting vertex + * is the vertex of Vk for which this distance is achieved. + */ + struct Net_filtration_vertex { + Vertex_handle vertex_handle; + Vertex_handle meeting_vertex; + double radius; + + Net_filtration_vertex(Vertex_handle vertex_handle_, + Vertex_handle meeting_vertex_, + double radius_) : + vertex_handle(vertex_handle_), meeting_vertex(meeting_vertex_), radius(radius_) { } + + bool operator<(const Net_filtration_vertex& other) const { + return radius < other.radius; + } + }; + + public: + std::vector net_filtration_; + + /** + * @brief Modify complex to be the expansion of the k-nearest neighbor + * symetric graph. + */ + Furthest_point_epsilon_net(SkBlComplex& complex) : + complex_(complex) { + if (!complex.empty()) { + init_filtration(); + for (int k = 2; k < net_filtration_.size(); ++k) { + update_radius_value(k); + } + } + } + + // xxx does not work if complex not full + + double radius(Vertex_handle v) { + return net_filtration_[v.vertex].radius; + } + + private: + void init_filtration() { + Vertex_handle v0 = *(complex_.vertex_range().begin()); + net_filtration_.reserve(complex_.num_vertices()); + for (auto v : complex_.vertex_range()) { + if (v != v0) + net_filtration_.push_back(Net_filtration_vertex(v, + Vertex_handle(-1), + squared_eucl_distance(v, v0))); + } + net_filtration_.push_back(Net_filtration_vertex(v0, Vertex_handle(-1), 1e10)); + auto n = net_filtration_.size(); + sort_filtration(n - 1); + } + + void update_radius_value(int k) { + int n = net_filtration_.size(); + int index_to_update = n - k; + for (int i = 0; i < index_to_update; ++i) { + net_filtration_[i].radius = (std::min)(net_filtration_[i].radius, + squared_eucl_distance(net_filtration_[i].vertex_handle, + net_filtration_[index_to_update].vertex_handle)); + } + sort_filtration(n - k); + } + + /** + * sort all i first elements. + */ + void sort_filtration(int i) { + std::sort(net_filtration_.begin(), net_filtration_.begin() + i); + } + + double squared_eucl_distance(Vertex_handle v1, Vertex_handle v2) const { + return std::sqrt(Geometry_trait::Squared_distance_d()(complex_.point(v1), complex_.point(v2))); + } + + void print_filtration() const { + for (auto v : net_filtration_) { + std::cerr << "v=" << v.vertex_handle << "-> d=" << v.radius << std::endl; + } + } }; - - -#endif /* FURTHEST_POINT_EPSILON_NET_H_ */ +#endif // UTILS_FURTHEST_POINT_EPSILON_NET_H_ diff --git a/src/GudhUI/utils/Is_manifold.h b/src/GudhUI/utils/Is_manifold.h index e708a6a4..1b25df34 100644 --- a/src/GudhUI/utils/Is_manifold.h +++ b/src/GudhUI/utils/Is_manifold.h @@ -7,7 +7,7 @@ * * 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,11 +25,10 @@ */ -#ifndef IS_MANIFOLD_H_ -#define IS_MANIFOLD_H_ +#ifndef UTILS_IS_MANIFOLD_H_ +#define UTILS_IS_MANIFOLD_H_ #include "utils/UI_utils.h" - #include "utils/Edge_contractor.h" /** @@ -38,67 +37,67 @@ * * todo do a sparsification with some parameter eps while growing */ -template class Is_manifold{ -private: - const SkBlComplex& input_complex_; - typedef typename SkBlComplex::Vertex_handle Vertex_handle; +template class Is_manifold { + private: + const SkBlComplex& input_complex_; + typedef typename SkBlComplex::Vertex_handle Vertex_handle; + public: + /* + * return dim the maximum dimension around one simplex and res which is true if the complex is a manifold. + * If the complex has dimension <= 3 then if res is false, the complex is not a manifold. + * For d-manifold with d>=4, res may be false while the complex is a manifold. + */ + Is_manifold(const SkBlComplex& input_complex, unsigned& dim, bool & res) : input_complex_(input_complex) { + res = true; + dim = -1; + if (!input_complex_.empty()) { + for (auto v : input_complex_.vertex_range()) { + dim = local_dimension(v); + break; + } + //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; + break; + } + } + } + } -public: - /* - * return dim the maximum dimension around one simplex and res which is true if the complex is a manifold. - * If the complex has dimension <= 3 then if res is false, the complex is not a manifold. - * For d-manifold with d>=4, res may be false while the complex is a manifold. - */ - Is_manifold(const SkBlComplex& input_complex,unsigned& dim,bool & res):input_complex_(input_complex){ - res = true; - dim = -1; - if(!input_complex_.empty()){ - for(auto v : input_complex_.vertex_range()){ - dim = local_dimension(v); - break; - } - //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; - break; - } - } - } - } + private: + unsigned local_dimension(Vertex_handle v) { + unsigned dim = 0; + for (const auto& s : input_complex_.simplex_range(v)) + dim = (std::max)(dim, (unsigned) s.dimension()); + return dim; + } -private: - unsigned local_dimension(Vertex_handle v){ - unsigned dim = 0; - for(const auto& s: input_complex_.simplex_range(v)) - dim = (std::max)(dim,(unsigned)s.dimension()); - return dim; - } + bool is_k_sphere(Vertex_handle v, int k) { + auto link = input_complex_.link(v); + Edge_contractor contractor(link, link.num_vertices() - 1); + return (is_sphere_simplex(link) == k); + } - bool is_k_sphere(Vertex_handle v,int k){ - auto link = input_complex_.link(v); - Edge_contractor contractor(link,link.num_vertices()-1); - return (is_sphere_simplex(link)==k); - } + // A minimal sphere is a complex that contains vertices v1...vn and all faces + // made upon this set except the face {v1,...,vn} + // return -2 if not a minimal sphere + // and d otherwise if complex is a d minimal sphere - // A minimal sphere is a complex that contains vertices v1...vn and all faces - // made upon this set except the face {v1,...,vn} - // return -2 if not a minimal sphere - // and d otherwise if complex is a d minimal sphere - template - int is_sphere_simplex(const SubComplex& complex){ - if(complex.empty()) return -1; - if(complex.num_blockers()!=1) return -2; + template + int is_sphere_simplex(const SubComplex& complex) { + 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 - auto first_blocker = *(complex.const_blocker_range().begin()); + //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()) - return -2; - else - return (first_blocker->dimension()-1); - } + if (first_blocker->dimension() + 1 != complex.num_vertices()) + return -2; + else + return (first_blocker->dimension() - 1); + } }; -#endif /* IS_MANIFOLD_H_ */ +#endif // UTILS_IS_MANIFOLD_H_ diff --git a/src/GudhUI/utils/K_nearest_builder.h b/src/GudhUI/utils/K_nearest_builder.h index b65a79e0..cab24b7c 100644 --- a/src/GudhUI/utils/K_nearest_builder.h +++ b/src/GudhUI/utils/K_nearest_builder.h @@ -1,81 +1,92 @@ -/* - * K_nearest_builder.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. * - * Created on: Sep 10, 2014 - * Author: dsalinas + * 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 K_NEAREST_BUILDER_H_ -#define K_NEAREST_BUILDER_H_ +#ifndef UTILS_K_NEAREST_BUILDER_H_ +#define UTILS_K_NEAREST_BUILDER_H_ -#include -#include #include #include #include #include -#include +#include +#include #include +#include +#include +#include + #include "utils/UI_utils.h" #include "model/Complex_typedefs.h" - - -template class K_nearest_builder{ -private: - - typedef Geometry_trait Kernel; - typedef Point Point_d; - typedef boost::tuple Point_d_with_id; - typedef CGAL::Search_traits_d Traits_base; - typedef CGAL::Search_traits_adapter, Traits_base> Traits; - typedef CGAL::Orthogonal_k_neighbor_search Neighbor_search; - typedef Neighbor_search::Tree Tree; - typedef Neighbor_search::Distance Distance; - - SkBlComplex& complex_; -public: - - /** - * @brief Modify complex to be the expansion of the k-nearest neighbor - * symetric graph. - */ - K_nearest_builder(SkBlComplex& complex,unsigned k):complex_(complex){ - complex.keep_only_vertices(); - compute_edges(k); - } - -private: - - - - double squared_eucl_distance(const Point& p1,const Point& p2) const{ - return Geometry_trait::Squared_distance_d()(p1,p2); - } - - void compute_edges(unsigned k){ - - std::list points_with_id; - for(auto v: complex_.vertex_range()){ - Point_d_with_id point_v(complex_.point(v),v.vertex); - points_with_id.push_back(point_v); - } - - Tree tree(points_with_id.begin(),points_with_id.end()); - - typedef typename SkBlComplex::Vertex_handle Vertex_handle; - for (auto p : complex_.vertex_range()){ - Neighbor_search search(tree, complex_.point(p),k+1); - for(auto it = ++search.begin(); it != search.end(); ++it){ - Vertex_handle q(boost::get<1>(it->first)); - if (p != q && complex_.contains_vertex(p) && complex_.contains_vertex(q)) - complex_.add_edge(p,q); - } - } - } - - +template class K_nearest_builder { + private: + typedef Geometry_trait Kernel; + typedef Point Point_d; + typedef boost::tuple Point_d_with_id; + typedef CGAL::Search_traits_d Traits_base; + typedef CGAL::Search_traits_adapter, + Traits_base> Traits; + typedef CGAL::Orthogonal_k_neighbor_search Neighbor_search; + typedef Neighbor_search::Tree Tree; + typedef Neighbor_search::Distance Distance; + + SkBlComplex& complex_; + + public: + /** + * @brief Modify complex to be the expansion of the k-nearest neighbor + * symetric graph. + */ + K_nearest_builder(SkBlComplex& complex, unsigned k) : complex_(complex) { + complex.keep_only_vertices(); + compute_edges(k); + } + + private: + double squared_eucl_distance(const Point& p1, const Point& p2) const { + return Geometry_trait::Squared_distance_d()(p1, p2); + } + + void compute_edges(unsigned k) { + std::list points_with_id; + for (auto v : complex_.vertex_range()) { + Point_d_with_id point_v(complex_.point(v), v.vertex); + points_with_id.push_back(point_v); + } + + Tree tree(points_with_id.begin(), points_with_id.end()); + + typedef typename SkBlComplex::Vertex_handle Vertex_handle; + for (auto p : complex_.vertex_range()) { + Neighbor_search search(tree, complex_.point(p), k + 1); + for (auto it = ++search.begin(); it != search.end(); ++it) { + Vertex_handle q(boost::get<1>(it->first)); + if (p != q && complex_.contains_vertex(p) && complex_.contains_vertex(q)) + complex_.add_edge(p, q); + } + } + } }; -#endif /* K_NEAREST_BUILDER_H_ */ +#endif // UTILS_K_NEAREST_BUILDER_H_ diff --git a/src/GudhUI/utils/Lloyd_builder.h b/src/GudhUI/utils/Lloyd_builder.h index db2a7973..18ec9fac 100644 --- a/src/GudhUI/utils/Lloyd_builder.h +++ b/src/GudhUI/utils/Lloyd_builder.h @@ -1,78 +1,91 @@ -/* - * Lloyd.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. * - * Created on: Sep 25, 2014 - * Author: dsalinas + * 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 LLOYD_H_ -#define LLOYD_H_ - +#ifndef UTILS_LLOYD_BUILDER_H_ +#define UTILS_LLOYD_BUILDER_H_ #include +#include /** * Iteratively puts every vertex at the center of its neighbors */ -template class Lloyd_builder{ -private: - SkBlComplex& complex_; - int dim; -public: - typedef typename SkBlComplex::Vertex_handle Vertex_handle; - /** - * @brief Modify complex to be the expansion of the k-nearest neighbor - * symetric graph. - */ - Lloyd_builder(SkBlComplex& complex,unsigned num_iterations):complex_(complex),dim(-1){ - if(!complex_.empty()){ - dim = get_dimension(); - while(num_iterations--){ - std::list new_points; - for(auto v : complex.vertex_range()) - new_points.push_back(barycenter_neighbors(v)); - - auto new_points_it = new_points.begin(); - for(auto v : complex.vertex_range()) - complex_.point(v) = *(new_points_it++); - } - } - } +template class Lloyd_builder { + private: + SkBlComplex& complex_; + int dim; -private: + public: + typedef typename SkBlComplex::Vertex_handle Vertex_handle; - int get_dimension(){ - assert(!complex_.empty()); - for(auto v : complex_.vertex_range()) - return complex_.point(v).dimension(); - return -1; - } + /** + * @brief Modify complex to be the expansion of the k-nearest neighbor + * symetric graph. + */ + Lloyd_builder(SkBlComplex& complex, unsigned num_iterations) : complex_(complex), dim(-1) { + if (!complex_.empty()) { + dim = get_dimension(); + while (num_iterations--) { + std::list new_points; + for (auto v : complex.vertex_range()) + new_points.push_back(barycenter_neighbors(v)); - Point barycenter_neighbors(Vertex_handle v) const{ - if(complex_.degree(v)==0) - return complex_.point(v); + auto new_points_it = new_points.begin(); + for (auto v : complex.vertex_range()) + complex_.point(v) = *(new_points_it++); + } + } + } - std::vector res(dim,0); - unsigned num_points = 0; - for(auto nv : complex_.vertex_range(v)){ - ++num_points; - const Point& point = complex_.point(nv); - assert(point.dimension() == dim); - for(int i = 0; i < point.dimension() ; ++i) - res[i] += point[i]; - } - for(auto& x : res) - x/= num_points; - return Point(dim,res.begin(),res.end()); - } + private: + int get_dimension() { + assert(!complex_.empty()); + for (auto v : complex_.vertex_range()) + return complex_.point(v).dimension(); + return -1; + } + Point barycenter_neighbors(Vertex_handle v) const { + if (complex_.degree(v) == 0) + return complex_.point(v); + std::vector res(dim, 0); + unsigned num_points = 0; + for (auto nv : complex_.vertex_range(v)) { + ++num_points; + const Point& point = complex_.point(nv); + assert(point.dimension() == dim); + for (int i = 0; i < point.dimension(); ++i) + res[i] += point[i]; + } + for (auto& x : res) + x /= num_points; + return Point(dim, res.begin(), res.end()); + } - double squared_eucl_distance(const Point& p1,const Point& p2) const{ - return Geometry_trait::Squared_distance_d()(p1,p2); - } - + double squared_eucl_distance(const Point& p1, const Point& p2) const { + return Geometry_trait::Squared_distance_d()(p1, p2); + } }; - -#endif /* LLOYD_H_ */ +#endif // UTILS_LLOYD_BUILDER_H_ diff --git a/src/GudhUI/utils/MClock.h b/src/GudhUI/utils/MClock.h index b5c7d191..e8d8918a 100644 --- a/src/GudhUI/utils/MClock.h +++ b/src/GudhUI/utils/MClock.h @@ -1,57 +1,70 @@ -/* - * 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. * - * Created on: Jun 17, 2014 - * Author: dsalinas + * 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_ +#ifndef UTILS_MCLOCK_H_ +#define UTILS_MCLOCK_H_ #include +class MClock { + public: + MClock() { + end_called = false; + begin(); + } -class MClock{ - -public: - MClock(){ - end_called = false; - begin(); - } - - void begin() const{ - end_called = false; - gettimeofday(&startTime, NULL); - } - - void end() const{ - end_called = true; - gettimeofday(&endTime, NULL); - } - - friend std::ostream& operator<< (std::ostream& stream,const MClock& clock){ - // if(!clock.end_called) clock.end(); - if(!clock.end_called) stream << "end not called"; - else{ - long totalTime = (clock.endTime.tv_sec - clock.startTime.tv_sec) * 1000000L; - totalTime += (clock.endTime.tv_usec - clock.startTime.tv_usec); - stream << clock.num_seconds() <<"s"; - } - return stream; - - } - - double num_seconds() const{ - if(!end_called) end(); - long totalTime = (endTime.tv_sec - startTime.tv_sec) * 1000000L; - totalTime += (endTime.tv_usec - startTime.tv_usec); - return (totalTime / 1000L)/(double) 1000; - } - -private: - mutable struct timeval startTime, endTime; - mutable bool end_called; -}; + void begin() const { + end_called = false; + gettimeofday(&startTime, NULL); + } + void end() const { + end_called = true; + gettimeofday(&endTime, NULL); + } + + friend std::ostream& operator<<(std::ostream& stream, const MClock& clock) { + // if(!clock.end_called) clock.end(); + if (!clock.end_called) { + stream << "end not called"; + } else { + long totalTime = (clock.endTime.tv_sec - clock.startTime.tv_sec) * 1000000L; + totalTime += (clock.endTime.tv_usec - clock.startTime.tv_usec); + stream << clock.num_seconds() << "s"; + } + return stream; + } + + double num_seconds() const { + if (!end_called) end(); + long totalTime = (endTime.tv_sec - startTime.tv_sec) * 1000000L; + totalTime += (endTime.tv_usec - startTime.tv_usec); + return (totalTime / 1000L) / static_cast(1000); + } + + private: + mutable struct timeval startTime, endTime; + mutable bool end_called; +}; -#endif /* CLOCK_H_ */ +#endif // UTILS_MCLOCK_H_ diff --git a/src/GudhUI/utils/Persistence_compute.h b/src/GudhUI/utils/Persistence_compute.h index 50d340b8..0b9961d3 100644 --- a/src/GudhUI/utils/Persistence_compute.h +++ b/src/GudhUI/utils/Persistence_compute.h @@ -1,13 +1,10 @@ -/* - * Persistence_compute.h - * Created on: Jan 26, 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 @@ -25,83 +22,76 @@ */ -#ifndef PERSISTENCE_COMPUTE_H_ -#define PERSISTENCE_COMPUTE_H_ +#ifndef UTILS_PERSISTENCE_COMPUTE_H_ +#define UTILS_PERSISTENCE_COMPUTE_H_ +#include +#include +#include +#include -#include "gudhi/graph_simplicial_complex.h" -#include "gudhi/Simplex_tree.h" -#include "gudhi/distance_functions.h" -#include "gudhi/Persistent_cohomology.h" +#include +struct Persistence_params { + int p; + double threshold; + int max_dim; + double min_pers; -struct Persistence_params{ - int p; - double threshold; - int max_dim; - double min_pers; - - Persistence_params(int p_,double th_,int max_dim_=10,double min_pers_=0) - :p(p_),threshold(th_),max_dim(max_dim_),min_pers(min_pers_){} + Persistence_params(int p_, double th_, int max_dim_ = 10, double min_pers_ = 0) + : p(p_), threshold(th_), max_dim(max_dim_), min_pers(min_pers_) { } }; - /** * Show persistence into output stream */ -template class Persistence_compute{ -private: - SkBlComplex& complex_; - std::ostream& stream_; -public: - typedef typename SkBlComplex::Vertex_handle Vertex_handle; - typedef typename SkBlComplex::Edge_handle Edge_handle; - - /** - * @brief Compute persistence - * parameters : - * unsigned dim_max - * double threshold - * int p for coefficient Z_p - */ - Persistence_compute(SkBlComplex& complex,std::ostream& stream,const Persistence_params& params): -// -// double threshold = 0.5,unsigned dim_max = 8): - complex_(complex),stream_(stream){ - - //for now everything is copied, todo boost adapt iterators to points of SkBlComplex instead of copying to an intial vector - typedef std::vector Point_t; - std::vector< Point_t > points; - points.reserve(complex.num_vertices()); - for(auto v : complex.vertex_range()){ - const auto & pt = complex.point(v); - Point_t pt_to_add(pt.cartesian_begin(),pt.cartesian_end()); - points.emplace_back(std::move(pt_to_add)); - } - - - Graph_t prox_graph = compute_proximity_graph( points, params.threshold, euclidean_distance ); - Gudhi::Simplex_tree<> st; - st.insert_graph(prox_graph); - st.expansion( params.max_dim ); - - Gudhi::persistent_cohomology::Persistent_cohomology< Gudhi::Simplex_tree<>,Gudhi::persistent_cohomology::Field_Zp > pcoh (st); - pcoh.init_coefficients( params.p ); //initilizes the coefficient field for homology - pcoh.compute_persistent_cohomology( params.min_pers ); //put params.min_pers - stream_<<"persistence: \n"; - stream_<<"p dimension birth death: \n"; - - pcoh.output_diagram(stream_); - } - -private: - - +template class Persistence_compute { + private: + SkBlComplex& complex_; + std::ostream& stream_; + + public: + typedef typename SkBlComplex::Vertex_handle Vertex_handle; + typedef typename SkBlComplex::Edge_handle Edge_handle; + + /** + * @brief Compute persistence + * parameters : + * unsigned dim_max + * double threshold + * int p for coefficient Z_p + */ + Persistence_compute(SkBlComplex& complex, std::ostream& stream, const Persistence_params& params) : + // double threshold = 0.5,unsigned dim_max = 8): + complex_(complex), stream_(stream) { + // for now everything is copied, todo boost adapt iterators to points of SkBlComplex instead of copying to an + // initial vector + typedef std::vector Point_t; + std::vector< Point_t > points; + points.reserve(complex.num_vertices()); + for (auto v : complex.vertex_range()) { + const auto & pt = complex.point(v); + Point_t pt_to_add(pt.cartesian_begin(), pt.cartesian_end()); + points.emplace_back(std::move(pt_to_add)); + } + + + Graph_t prox_graph = compute_proximity_graph(points, params.threshold, euclidean_distance); + Gudhi::Simplex_tree<> st; + st.insert_graph(prox_graph); + st.expansion(params.max_dim); + + Gudhi::persistent_cohomology::Persistent_cohomology< Gudhi::Simplex_tree<>, + Gudhi::persistent_cohomology::Field_Zp > pcoh(st); + // initializes the coefficient field for homology + pcoh.init_coefficients(params.p); + // put params.min_pers + pcoh.compute_persistent_cohomology(params.min_pers); + stream_ << "persistence: \n"; + stream_ << "p dimension birth death: \n"; + + pcoh.output_diagram(stream_); + } }; - - - - - -#endif /* PERSISTENCE_COMPUTE_H_ */ +#endif // UTILS_PERSISTENCE_COMPUTE_H_ diff --git a/src/GudhUI/utils/Rips_builder.h b/src/GudhUI/utils/Rips_builder.h index 9484f9ab..b22f4db6 100644 --- a/src/GudhUI/utils/Rips_builder.h +++ b/src/GudhUI/utils/Rips_builder.h @@ -1,56 +1,69 @@ -/* - * Rips_builder.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. * - * Created on: Sep 10, 2014 - * Author: dsalinas + * 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 RIPS_BUILDER_H_ -#define RIPS_BUILDER_H_ +#ifndef UTILS_RIPS_BUILDER_H_ +#define UTILS_RIPS_BUILDER_H_ #include -#include "utils/UI_utils.h" -#include "model/Complex_typedefs.h" #include - #include #include -template class Rips_builder{ -private: - SkBlComplex& complex_; -public: - - /** - * @brief Modify complex to be the Rips complex - * of its points with offset alpha. - */ - Rips_builder(SkBlComplex& complex,double alpha):complex_(complex){ - complex.keep_only_vertices(); - if (alpha<=0) return; - compute_edges(alpha); - } - -private: - - - double squared_eucl_distance(const Point& p1,const Point& p2) const{ - return Geometry_trait::Squared_distance_d()(p1,p2); - } - - void compute_edges(double alpha){ - auto vertices = complex_.vertex_range(); - for(auto p = vertices.begin(); p!= vertices.end(); ++p){ - std::cout << *p << " "; std::cout.flush(); - for (auto q = p; ++q != vertices.end(); /**/) - if (squared_eucl_distance(complex_.point(*p),complex_.point(*q)) < 4*alpha*alpha) - complex_.add_edge(*p,*q); - } - std::cout << std::endl; - } +#include "utils/UI_utils.h" +#include "model/Complex_typedefs.h" -}; +template class Rips_builder { + private: + SkBlComplex& complex_; + public: + /** + * @brief Modify complex to be the Rips complex + * of its points with offset alpha. + */ + Rips_builder(SkBlComplex& complex, double alpha) : complex_(complex) { + complex.keep_only_vertices(); + if (alpha <= 0) return; + compute_edges(alpha); + } + + private: + double squared_eucl_distance(const Point& p1, const Point& p2) const { + return Geometry_trait::Squared_distance_d()(p1, p2); + } + + void compute_edges(double alpha) { + auto vertices = complex_.vertex_range(); + for (auto p = vertices.begin(); p != vertices.end(); ++p) { + std::cout << *p << " "; + std::cout.flush(); + for (auto q = p; ++q != vertices.end(); /**/) + if (squared_eucl_distance(complex_.point(*p), complex_.point(*q)) < 4 * alpha * alpha) + complex_.add_edge(*p, *q); + } + std::cout << std::endl; + } +}; -#endif /* RIPS_BUILDER_H_ */ +#endif // UTILS_RIPS_BUILDER_H_ diff --git a/src/GudhUI/utils/UI_utils.h b/src/GudhUI/utils/UI_utils.h index 4ade4b98..9cc209d3 100644 --- a/src/GudhUI/utils/UI_utils.h +++ b/src/GudhUI/utils/UI_utils.h @@ -1,30 +1,45 @@ -/* - * UI_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. * - * Created on: Aug 25, 2014 - * Author: david + * 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 UI_UTILS_H_ -#define UI_UTILS_H_ +#ifndef UTILS_UI_UTILS_H_ +#define UTILS_UI_UTILS_H_ #define UIDBG_VERBOSE #ifdef UIDBG_VERBOSE -#define UIDBG(a) std::cerr << "UIDBG: " << (a)< "; 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 DBGMSG(a, b) b // #define DBGVALUE(a) a // #define DBGCONT(a) a #define UIDBG(a) -#define UIDBGMSG(a,b) +#define UIDBGMSG(a, b) #define UIDBGVALUE(a) #define UIDBGCONT(a) #endif - -#endif // UI_UTILS_H_ +#endif // UTILS_UI_UTILS_H_ diff --git a/src/GudhUI/utils/Vertex_collapsor.h b/src/GudhUI/utils/Vertex_collapsor.h index d4911a35..be03c765 100644 --- a/src/GudhUI/utils/Vertex_collapsor.h +++ b/src/GudhUI/utils/Vertex_collapsor.h @@ -1,76 +1,86 @@ -/* - * Vertex_collapsor.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. * - * Created on: Sep 25, 2014 - * Author: dsalinas + * 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 VERTEX_COLLAPSOR_H_ -#define VERTEX_COLLAPSOR_H_ +#ifndef UTILS_VERTEX_COLLAPSOR_H_ +#define UTILS_VERTEX_COLLAPSOR_H_ #include "utils/Edge_contractor.h" #include "utils/Furthest_point_epsilon_net.h" #include "utils/UI_utils.h" + /** * Iteratively puts every vertex at the center of its neighbors */ -template class Vertex_collapsor{ -private: - SkBlComplex& complex_; - size_t num_collapses_; -public: - typedef typename SkBlComplex::Vertex_handle Vertex_handle; - typedef typename SkBlComplex::Edge_handle Edge_handle; - - /** - * @brief Modify complex to be the expansion of the k-nearest neighbor - * symetric graph. - */ - Vertex_collapsor(SkBlComplex& complex, size_t num_collapses) : - complex_(complex),num_collapses_(num_collapses) - { -// std::list vertices; -// vertices.insert(vertices.begin(),complex_.vertex_range().begin(),complex_.vertex_range().end()); -// UIDBG("Collapse vertices"); -// collapse_vertices(vertices); - - std::list vertices; - - UIDBG("Compute eps net"); - Furthest_point_epsilon_net eps_net(complex_); - - for(auto vh : eps_net.net_filtration_) - vertices.push_back(vh.vertex_handle); - - UIDBG("Collapse vertices"); - collapse_vertices(vertices); - - - - } - -private: - - - void collapse_vertices(std::list& vertices){ - while(!vertices.empty() && num_collapses_--){ - Vertex_handle current_vertex = vertices.front(); - vertices.pop_front(); - if(is_link_reducible(current_vertex)) - complex_.remove_vertex(current_vertex); - } - } - - bool is_link_reducible(Vertex_handle v){ - auto link = complex_.link(v); - if(link.empty()) return false; - if(link.is_cone()) return true; - if(link.num_connected_components()>1) return false; - Edge_contractor contractor(link,link.num_vertices()-1); - return (link.num_vertices()==1); - } - +template class Vertex_collapsor { + private: + SkBlComplex& complex_; + size_t num_collapses_; + + public: + typedef typename SkBlComplex::Vertex_handle Vertex_handle; + typedef typename SkBlComplex::Edge_handle Edge_handle; + + /** + * @brief Modify complex to be the expansion of the k-nearest neighbor + * symetric graph. + */ + Vertex_collapsor(SkBlComplex& complex, size_t num_collapses) : + complex_(complex), num_collapses_(num_collapses) { + // std::list vertices; + // vertices.insert(vertices.begin(),complex_.vertex_range().begin(),complex_.vertex_range().end()); + // UIDBG("Collapse vertices"); + // collapse_vertices(vertices); + + std::list vertices; + + UIDBG("Compute eps net"); + Furthest_point_epsilon_net eps_net(complex_); + + for (auto vh : eps_net.net_filtration_) + vertices.push_back(vh.vertex_handle); + + UIDBG("Collapse vertices"); + collapse_vertices(vertices); + } + + private: + void collapse_vertices(std::list& vertices) { + while (!vertices.empty() && num_collapses_--) { + Vertex_handle current_vertex = vertices.front(); + vertices.pop_front(); + if (is_link_reducible(current_vertex)) + complex_.remove_vertex(current_vertex); + } + } + + bool is_link_reducible(Vertex_handle v) { + auto link = complex_.link(v); + if (link.empty()) return false; + if (link.is_cone()) return true; + if (link.num_connected_components() > 1) return false; + Edge_contractor contractor(link, link.num_vertices() - 1); + return (link.num_vertices() == 1); + } }; - -#endif /* VERTEX_COLLAPSOR_H_ */ +#endif // UTILS_VERTEX_COLLAPSOR_H_ diff --git a/src/GudhUI/view/Color.h b/src/GudhUI/view/Color.h index a63456cb..ba0592e1 100644 --- a/src/GudhUI/view/Color.h +++ b/src/GudhUI/view/Color.h @@ -1,21 +1,35 @@ -/* - * Color.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. * - * Created on: Aug 26, 2014 - * Author: dsalinas + * 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 COLOR_H_ -#define COLOR_H_ - +#ifndef VIEW_COLOR_H_ +#define VIEW_COLOR_H_ +struct Color { + double r; + double g; + double b; -struct Color{ - double r; - double g; - double b; - Color(double r_,double g_,double b_):r(r_),g(g_),b(b_){} + Color(double r_, double g_, double b_) : r(r_), g(g_), b(b_) { } }; - -#endif /* COLOR_H_ */ +#endif // VIEW_COLOR_H_ diff --git a/src/GudhUI/view/FirstCoordProjector.h b/src/GudhUI/view/FirstCoordProjector.h index 2659eef1..529d2d42 100644 --- a/src/GudhUI/view/FirstCoordProjector.h +++ b/src/GudhUI/view/FirstCoordProjector.h @@ -1,24 +1,40 @@ -/* - * FirstCoordProjector.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. * - * Created on: Aug 27, 2014 - * Author: dsalinas + * 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 FIRSTCOORDPROJECTOR_H_ -#define FIRSTCOORDPROJECTOR_H_ +#ifndef VIEW_FIRSTCOORDPROJECTOR_H_ +#define VIEW_FIRSTCOORDPROJECTOR_H_ #include "utils/UI_utils.h" #include "Projector3D.h" -class FirstCoordProjector3D : public Projector3D{ - typedef Projector3D::Point Point; - typedef Projector3D::Point_3 Point_3; +class FirstCoordProjector3D : public Projector3D { + typedef Projector3D::Point Point; + typedef Projector3D::Point_3 Point_3; - Point_3 operator()(const Point& p) const{ - assert(p.dimension()>=3); - return Point_3(p.x(),p.y(),p.z()); - } + Point_3 operator()(const Point& p) const { + assert(p.dimension() >= 3); + return Point_3(p.x(), p.y(), p.z()); + } }; -#endif /* FIRSTCOORDPROJECTOR_H_ */ +#endif // VIEW_FIRSTCOORDPROJECTOR_H_ diff --git a/src/GudhUI/view/Projector3D.h b/src/GudhUI/view/Projector3D.h index 503b35c5..2a756541 100644 --- a/src/GudhUI/view/Projector3D.h +++ b/src/GudhUI/view/Projector3D.h @@ -1,28 +1,39 @@ -/* - * Projector.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. * - * Created on: Aug 27, 2014 - * Author: dsalinas + * 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 PROJECTOR3D_H_ -#define PROJECTOR3D_H_ +#ifndef VIEW_PROJECTOR3D_H_ +#define VIEW_PROJECTOR3D_H_ #include "model/Complex_typedefs.h" +class Projector3D { + public: + typedef Geometry_trait::Point Point; + typedef Geometry_trait::Point_3 Point_3; -class Projector3D{ -public: - typedef Geometry_trait::Point Point; - typedef Geometry_trait::Point_3 Point_3; - - virtual Point_3 operator()(const Point&) const = 0; - - virtual ~Projector3D(){ - } + virtual Point_3 operator()(const Point&) const = 0; + virtual ~Projector3D() { } }; - - -#endif /* PROJECTOR3D_H_ */ +#endif // VIEW_PROJECTOR3D_H_ diff --git a/src/GudhUI/view/View_parameter.h b/src/GudhUI/view/View_parameter.h index 39c5d7dd..9805abc2 100644 --- a/src/GudhUI/view/View_parameter.h +++ b/src/GudhUI/view/View_parameter.h @@ -1,13 +1,28 @@ -/* - * View_parameter.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. * - * Created on: Mar 10, 2014 - * Author: David Salinas - * Copyright 2013 INRIA. All rights reserved + * 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 VIEW_PARAMETER_H_ -#define VIEW_PARAMETER_H_ +#ifndef VIEW_VIEW_PARAMETER_H_ +#define VIEW_VIEW_PARAMETER_H_ #include @@ -15,123 +30,122 @@ * Different parameters for the view such as the camera angle, * the light, options for vertices/edges/triangles. */ -class View_parameter{ -public: - bool light; - bool relative_light; - - double size_vertices; - double size_edges; - double light_edges; // in 0-1 - double light_triangles;// in 0-1 - - /** - * light angle - */ - double theta; - double phi; - - enum VERTEX_MODE{ V_NONE,V_SIMPLE,V_COUNT}; - enum EDGE_MODE{ E_NONE,E_SIMPLE,E_COUNT}; - enum TRIANGLE_MODE{ T_NONE,T_SIMPLE,T_COUNT}; - - - - - VERTEX_MODE vertex_mode; - EDGE_MODE edge_mode; - TRIANGLE_MODE triangle_mode; - - void change_vertex_mode(){ - int current_value = vertex_mode; - vertex_mode = static_cast(++current_value % V_COUNT); - std::cout<<"Vertex mode : "; - switch (vertex_mode) { - case V_NONE: - std::cout<<"empty\n"; - break; - case V_SIMPLE: - std::cout<<"simple\n"; - break; - default: - break; - } - } - - void change_vertex_mode(int new_mode){ - vertex_mode = static_cast(new_mode % V_COUNT); - } - - void change_edge_mode(){ - int current_value = edge_mode; - edge_mode = static_cast(++current_value % E_COUNT); - } - - void change_edge_mode(int new_mode){ - edge_mode = static_cast(new_mode % E_COUNT); - } - - - void change_triangle_mode(){ - int current_value = triangle_mode; - triangle_mode = static_cast(++current_value % T_COUNT); - } - - - - - - View_parameter(){ - light = true; - relative_light = true; - vertex_mode = V_SIMPLE; - edge_mode = E_SIMPLE; - triangle_mode = T_NONE; - - size_vertices = 3; - size_edges = 2; - - light_edges = 0.3; - light_triangles = 0.85; - theta = 0; - phi = 0; - } - - friend std::ostream& operator<<(std::ostream& stream, const View_parameter& param){ - stream << param.light<< " "; - stream << param.relative_light<< " "; - stream << param.vertex_mode<< " "; - stream << param.edge_mode<< " "; - stream << param.triangle_mode<< " "; - stream << param.size_vertices<< " "; - stream << param.size_edges<< " "; - stream << param.light_edges<< " "; - stream << param.light_triangles<< " "; - stream << param.theta<< " "; - stream << param.phi<< " "; - return stream; - } - - friend std::istream& operator>>(std::istream& stream, View_parameter& param){ - stream >> param.light; - stream >> param.relative_light; - int a; - stream>>a; - param.vertex_mode = static_cast(a % V_COUNT); - stream>>a; - param.edge_mode = static_cast(a % E_COUNT); - stream>>a; - param.triangle_mode = static_cast(a % T_COUNT); - stream>>a; - stream >> param.size_vertices; - stream >> param.size_edges; - stream >> param.light_edges; - stream >> param.light_triangles; - stream >> param.theta; - stream >> param.phi; - return stream; - } - +class View_parameter { + public: + bool light; + bool relative_light; + + double size_vertices; + double size_edges; + double light_edges; // in 0-1 + double light_triangles; // in 0-1 + + /** + * light angle + */ + double theta; + double phi; + + enum VERTEX_MODE { + V_NONE, V_SIMPLE, V_COUNT + }; + + enum EDGE_MODE { + E_NONE, E_SIMPLE, E_COUNT + }; + + enum TRIANGLE_MODE { + T_NONE, T_SIMPLE, T_COUNT + }; + + VERTEX_MODE vertex_mode; + EDGE_MODE edge_mode; + TRIANGLE_MODE triangle_mode; + + void change_vertex_mode() { + int current_value = vertex_mode; + vertex_mode = static_cast (++current_value % V_COUNT); + std::cout << "Vertex mode : "; + switch (vertex_mode) { + case V_NONE: + std::cout << "empty\n"; + break; + case V_SIMPLE: + std::cout << "simple\n"; + break; + default: + break; + } + } + + void change_vertex_mode(int new_mode) { + vertex_mode = static_cast (new_mode % V_COUNT); + } + + void change_edge_mode() { + int current_value = edge_mode; + edge_mode = static_cast (++current_value % E_COUNT); + } + + void change_edge_mode(int new_mode) { + edge_mode = static_cast (new_mode % E_COUNT); + } + + void change_triangle_mode() { + int current_value = triangle_mode; + triangle_mode = static_cast (++current_value % T_COUNT); + } + + View_parameter() { + light = true; + relative_light = true; + vertex_mode = V_SIMPLE; + edge_mode = E_SIMPLE; + triangle_mode = T_NONE; + + size_vertices = 3; + size_edges = 2; + + light_edges = 0.3; + light_triangles = 0.85; + theta = 0; + phi = 0; + } + + friend std::ostream& operator<<(std::ostream& stream, const View_parameter& param) { + stream << param.light << " "; + stream << param.relative_light << " "; + stream << param.vertex_mode << " "; + stream << param.edge_mode << " "; + stream << param.triangle_mode << " "; + stream << param.size_vertices << " "; + stream << param.size_edges << " "; + stream << param.light_edges << " "; + stream << param.light_triangles << " "; + stream << param.theta << " "; + stream << param.phi << " "; + return stream; + } + + friend std::istream& operator>>(std::istream& stream, View_parameter& param) { + stream >> param.light; + stream >> param.relative_light; + int a; + stream >> a; + param.vertex_mode = static_cast (a % V_COUNT); + stream >> a; + param.edge_mode = static_cast (a % E_COUNT); + stream >> a; + param.triangle_mode = static_cast (a % T_COUNT); + stream >> a; + stream >> param.size_vertices; + stream >> param.size_edges; + stream >> param.light_edges; + stream >> param.light_triangles; + stream >> param.theta; + stream >> param.phi; + return stream; + } }; -#endif /* VIEW_PARAMETER_H_ */ +#endif // VIEW_VIEW_PARAMETER_H_ diff --git a/src/GudhUI/view/Viewer.cpp b/src/GudhUI/view/Viewer.cpp index d8a35faf..c6c2b345 100644 --- a/src/GudhUI/view/Viewer.cpp +++ b/src/GudhUI/view/Viewer.cpp @@ -1,197 +1,186 @@ -/* - * Viewer.cpp +/* This file is part of the Gudhi Library. The Gudhi library + * (Geometric Understanding in Higher Dimensions) is a generic C++ + * library for computational topology. * - * Created on: Aug 26, 2014 - * Author: dsalinas + * 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 . + * */ #include "Viewer.h" #include "utils/UI_utils.h" -Viewer::Viewer(QWidget* parent): QGLViewer(QGLFormat(QGL::SampleBuffers),parent),instructor(0),theta(0),phi(0){ -} +Viewer::Viewer(QWidget* parent) : QGLViewer(QGLFormat(QGL::SampleBuffers), parent), instructor(0), theta(0), phi(0) { } -void -Viewer::set_instructor(Viewer_instructor* instructor_){ - instructor = instructor_; +void Viewer::set_instructor(Viewer_instructor* instructor_) { + instructor = instructor_; } -void -Viewer::show_entire_scene(){ - this->showEntireScene(); +void Viewer::show_entire_scene() { + this->showEntireScene(); } -void -Viewer::draw(){ - instructor->give_instructions(); +void Viewer::draw() { + instructor->give_instructions(); } - -void -Viewer::set_bounding_box(const Point_3 & lower_left,const Point_3 & upper_right){ - this->camera()->setSceneBoundingBox( - qglviewer::Vec(lower_left[0], lower_left[1], lower_left[2]), - qglviewer::Vec(upper_right[0], upper_right[1], upper_right[2]) - ); +void Viewer::set_bounding_box(const Point_3 & lower_left, const Point_3 & upper_right) { + this->camera()->setSceneBoundingBox(qglviewer::Vec(lower_left[0], lower_left[1], lower_left[2]), + qglviewer::Vec(upper_right[0], upper_right[1], upper_right[2])); } -void -Viewer::update_GL(){ - this->updateGL(); - +void Viewer::update_GL() { + this->updateGL(); } -void -Viewer::init_scene(){ - this->setBackgroundColor(Qt::white); - ::glEnable(GL_LINE_SMOOTH); - init_light(); +void Viewer::init_scene() { + this->setBackgroundColor(Qt::white); + ::glEnable(GL_LINE_SMOOTH); + init_light(); } -void -Viewer::init_light(){ - ::glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE); +void Viewer::init_light() { + ::glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE); } -void -Viewer::set_light(){ - if(theta>=0 && phi >=0){ - const GLfloat pos[4] = {(float)(sin(phi)*cos(theta)),(float)(sin(phi)*sin(theta)),(float)(cos(phi)),0.}; - glLightfv(GL_LIGHT0, GL_POSITION, pos); - } +void Viewer::set_light() { + if (theta >= 0 && phi >= 0) { + const GLfloat pos[4] = {static_cast (sin(phi) * cos(theta)), + static_cast (sin(phi) * sin(theta)), + static_cast (cos(phi)), 0.}; + glLightfv(GL_LIGHT0, GL_POSITION, pos); + } } -void -Viewer::set_light_direction(double theta_,double phi_){ - theta = theta_; - phi = phi_; +void Viewer::set_light_direction(double theta_, double phi_) { + theta = theta_; + phi = phi_; } /** * set the light in the direction of the observer */ -void -Viewer::set_light_direction(){ - theta = -1; - phi = -1; +void Viewer::set_light_direction() { + theta = -1; + phi = -1; } +void Viewer::postSelection(const QPoint& point) { + bool found; -void -Viewer::postSelection(const QPoint& point){ - bool found; + auto vec = this->camera()->pointUnderPixel(point, found); - auto vec = this->camera()->pointUnderPixel(point,found); - - if(found){ - Point_3 position(vec[0],vec[1],vec[2]); - emit(click(position)); - } + if (found) { + Point_3 position(vec[0], vec[1], vec[2]); + emit(click(position)); + } } //////////////////////// // draw //////////////////////// -void -Viewer::set_size_point(double size_points){ - ::glPointSize(size_points); -} - -void -Viewer::draw_point(const Point_3& p,const Color& color,double size_points){ - ::glColor3f(color.r,color.g,color.b); - ::glDisable(GL_LIGHTING); - ::glEnable(GL_POINT_SMOOTH); - ::glPointSize(size_points); - ::glBegin(GL_POINTS); - ::glVertex3d(p.x(), p.y(), p.z()); - ::glEnd(); - ::glDisable(GL_POINT_SMOOTH); -} - -void -Viewer::begin_draw_points(double size,bool light){ - light?glEnable(GL_LIGHTING):glDisable(GL_LIGHTING); - ::glEnable(GL_POINT_SMOOTH); - ::glPointSize(size); - ::glBegin(GL_POINTS); -} - -void -Viewer::set_color(const Color& color){ - ::glColor3f(color.r,color.g,color.b); -} - -void -Viewer::draw_points(const Point_3 & point){ - ::glVertex3d(point.x(),point.y(),point.z()); -} - -void -Viewer::end_draw_points(){ - ::glEnd(); - ::glDisable(GL_POINT_SMOOTH); -} - -void -Viewer::draw_edge(const Point_3 &a,const Point_3 &b,const Color& color,double size){ - ::glColor3f(color.r,color.g,color.b); - ::glPointSize(3.0); - ::glLineWidth(size); - ::glBegin(GL_LINES); - ::glVertex3f(a.x(),a.y(),a.z()); - ::glVertex3f(b.x(),b.y(),b.z()); - ::glEnd(); -} - -void -Viewer::begin_draw_edges(double size,bool light){ - ::glLineWidth(size); - ::glPolygonMode(GL_FRONT_AND_BACK,GL_LINE); - ::glEnable(GL_POLYGON_OFFSET_LINE); - ::glPolygonOffset(3.0f,-3.0f); - light?glEnable(GL_LIGHTING):glDisable(GL_LIGHTING); - ::glBegin(GL_LINES); -} - -void -Viewer::draw_edges(const Point_3 &a,const Point_3 &b){ - ::glVertex3f(a.x(),a.y(),a.z()); - ::glVertex3f(b.x(),b.y(),b.z()); -} - -void -Viewer::end_draw_edges(){ - ::glEnd(); -} - -void -Viewer::begin_draw_triangles(double size,bool light,bool transparent){ - if(transparent){ - ::glEnable (GL_BLEND); - ::glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - } - ::glPolygonMode(GL_FRONT_AND_BACK,GL_FILL); - ::glEnable(GL_POLYGON_OFFSET_FILL); - ::glPolygonOffset(3.0f,-3.0f); - light?glEnable(GL_LIGHTING):glDisable(GL_LIGHTING); - ::glBegin(GL_TRIANGLES); -} - -void -Viewer::draw_triangles(const Point_3& p1,const Point_3& p2,const Point_3& p3){ - if(!CGAL::collinear(p1,p2,p3)){ - auto triangle_normal = CGAL::unit_normal(p1,p2,p3); - ::glNormal3d(triangle_normal.x(),triangle_normal.y(),triangle_normal.z()); - ::glVertex3d(p1.x(),p1.y(),p1.z()); - ::glVertex3d(p2.x(),p2.y(),p2.z()); - ::glVertex3d(p3.x(),p3.y(),p3.z()); - } -} - -void -Viewer::end_draw_triangles(){ - ::glEnd(); + +void Viewer::set_size_point(double size_points) { + ::glPointSize(size_points); +} + +void Viewer::draw_point(const Point_3& p, const Color& color, double size_points) { + ::glColor3f(color.r, color.g, color.b); + ::glDisable(GL_LIGHTING); + ::glEnable(GL_POINT_SMOOTH); + ::glPointSize(size_points); + ::glBegin(GL_POINTS); + ::glVertex3d(p.x(), p.y(), p.z()); + ::glEnd(); + ::glDisable(GL_POINT_SMOOTH); +} + +void Viewer::begin_draw_points(double size, bool light) { + light ? glEnable(GL_LIGHTING) : glDisable(GL_LIGHTING); + ::glEnable(GL_POINT_SMOOTH); + ::glPointSize(size); + ::glBegin(GL_POINTS); +} + +void Viewer::set_color(const Color& color) { + ::glColor3f(color.r, color.g, color.b); +} + +void Viewer::draw_points(const Point_3 & point) { + ::glVertex3d(point.x(), point.y(), point.z()); +} + +void Viewer::end_draw_points() { + ::glEnd(); + ::glDisable(GL_POINT_SMOOTH); +} + +void Viewer::draw_edge(const Point_3 &a, const Point_3 &b, const Color& color, double size) { + ::glColor3f(color.r, color.g, color.b); + ::glPointSize(3.0); + ::glLineWidth(size); + ::glBegin(GL_LINES); + ::glVertex3f(a.x(), a.y(), a.z()); + ::glVertex3f(b.x(), b.y(), b.z()); + ::glEnd(); +} + +void Viewer::begin_draw_edges(double size, bool light) { + ::glLineWidth(size); + ::glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + ::glEnable(GL_POLYGON_OFFSET_LINE); + ::glPolygonOffset(3.0f, -3.0f); + light ? glEnable(GL_LIGHTING) : glDisable(GL_LIGHTING); + ::glBegin(GL_LINES); +} + +void Viewer::draw_edges(const Point_3 &a, const Point_3 &b) { + ::glVertex3f(a.x(), a.y(), a.z()); + ::glVertex3f(b.x(), b.y(), b.z()); +} + +void Viewer::end_draw_edges() { + ::glEnd(); +} + +void Viewer::begin_draw_triangles(double size, bool light, bool transparent) { + if (transparent) { + ::glEnable(GL_BLEND); + ::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + } + ::glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + ::glEnable(GL_POLYGON_OFFSET_FILL); + ::glPolygonOffset(3.0f, -3.0f); + light ? glEnable(GL_LIGHTING) : glDisable(GL_LIGHTING); + ::glBegin(GL_TRIANGLES); +} + +void Viewer::draw_triangles(const Point_3& p1, const Point_3& p2, const Point_3& p3) { + if (!CGAL::collinear(p1, p2, p3)) { + auto triangle_normal = CGAL::unit_normal(p1, p2, p3); + ::glNormal3d(triangle_normal.x(), triangle_normal.y(), triangle_normal.z()); + ::glVertex3d(p1.x(), p1.y(), p1.z()); + ::glVertex3d(p2.x(), p2.y(), p2.z()); + ::glVertex3d(p3.x(), p3.y(), p3.z()); + } +} + +void Viewer::end_draw_triangles() { + ::glEnd(); } #include "Viewer.moc" diff --git a/src/GudhUI/view/Viewer.h b/src/GudhUI/view/Viewer.h index 00f9b245..99bd63e4 100644 --- a/src/GudhUI/view/Viewer.h +++ b/src/GudhUI/view/Viewer.h @@ -1,10 +1,36 @@ -#ifndef VIEWER_H -#define VIEWER_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 VIEW_VIEWER_H +#define VIEW_VIEWER_H // Workaround for moc-qt4 not parsing boost headers #include #include + +#include + #include "View_parameter.h" #include "model/Complex_typedefs.h" #include "Color.h" @@ -13,87 +39,82 @@ class Viewer_instructor; class Viewer : public QGLViewer { - Q_OBJECT - - Viewer_instructor * instructor; - - /** - * light angles - */ - double theta,phi; - typedef Complex::GT Gudhi_kernel; - typedef Gudhi_kernel::Point_3 Point_3; -public: - Viewer(QWidget* parent); + Q_OBJECT - void set_instructor(Viewer_instructor* instructor_); + Viewer_instructor * instructor; - void show_entire_scene(); + /** + * light angles + */ + double theta, phi; + typedef Complex::GT Gudhi_kernel; + typedef Gudhi_kernel::Point_3 Point_3; - void draw(); + public: + Viewer(QWidget* parent); + void set_instructor(Viewer_instructor* instructor_); - void set_bounding_box(const Point_3 & lower_left,const Point_3 & upper_right); + void show_entire_scene(); - void update_GL(); + void draw(); - void init_scene(); + void set_bounding_box(const Point_3 & lower_left, const Point_3 & upper_right); - void init_light(); + void update_GL(); - void set_light(); + void init_scene(); - void set_light_direction(double theta,double phi); + void init_light(); - /** - * set the light in the direction of the observer - */ - void set_light_direction(); + void set_light(); + void set_light_direction(double theta, double phi); -protected: - virtual void postSelection(const QPoint& point); + /** + * set the light in the direction of the observer + */ + void set_light_direction(); + protected: + virtual void postSelection(const QPoint& point); -public: + public: + //////////////////////// + // draw + //////////////////////// + void set_size_point(double size_points); - //////////////////////// - // draw - //////////////////////// - void set_size_point(double size_points); + void set_color(const Color& color); - void set_color(const Color& color); + void draw_point(const Point_3& p, const Color& color, double size_points); - void draw_point(const Point_3& p,const Color& color,double size_points); + void begin_draw_points(double size, bool light = false); - void begin_draw_points(double size,bool light=false); + void draw_points(const Point_3 & point); - void draw_points(const Point_3 & point); + void end_draw_points(); - void end_draw_points(); + void draw_edge(const Point_3 &a, const Point_3 &b, const Color& color, double size); - void draw_edge(const Point_3 &a,const Point_3 &b,const Color& color,double size); + void begin_draw_edges(double size, bool light = false); - void begin_draw_edges(double size,bool light=false); + void draw_edges(const Point_3 &a, const Point_3 &b); - void draw_edges(const Point_3 &a,const Point_3 &b); + void end_draw_edges(); - void end_draw_edges(); + void begin_draw_triangles(double size, bool light, bool transparent = false); - void begin_draw_triangles(double size,bool light,bool transparent = false); + void draw_triangles(const Point_3& p1, const Point_3& p2, const Point_3& p3); - void draw_triangles(const Point_3& p1,const Point_3& p2,const Point_3& p3); + // todo remove + void draw_triangles(const std::vector& points); - //todo remove - void draw_triangles(const std::vector& points); + void end_draw_triangles(); - void end_draw_triangles(); - - signals: - void click(const Point_3& position); + signals: + void click(const Point_3& position); }; - - -#endif +#endif // VIEW_VIEWER_H diff --git a/src/GudhUI/view/Viewer_instructor.cpp b/src/GudhUI/view/Viewer_instructor.cpp index 3cb8f152..4446d209 100644 --- a/src/GudhUI/view/Viewer_instructor.cpp +++ b/src/GudhUI/view/Viewer_instructor.cpp @@ -1,206 +1,192 @@ -/* - * Viewer_instructor.cpp +/* This file is part of the Gudhi Library. The Gudhi library + * (Geometric Understanding in Higher Dimensions) is a generic C++ + * library for computational topology. * - * Created on: Aug 26, 2014 - * Author: dsalinas + * 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 . + * */ #include + #include "Viewer_instructor.h" #include "utils/UI_utils.h" #include "FirstCoordProjector.h" - Viewer_instructor::Viewer_instructor(QWidget* parent, - Viewer* viewer, - const Complex& mesh -):viewer_(viewer),mesh_(mesh),projector_(new FirstCoordProjector3D()){ - viewer_->set_instructor(this); + Viewer* viewer, + const Complex& mesh + ) + : viewer_(viewer), mesh_(mesh), projector_(new FirstCoordProjector3D()) { + viewer_->set_instructor(this); +} + +void Viewer_instructor::initialize_bounding_box() { + auto pair_bounding_box = compute_bounding_box_corners(); + viewer_->set_bounding_box(proj(pair_bounding_box.first), proj(pair_bounding_box.second)); + viewer_->init_scene(); } +std::pair Viewer_instructor::compute_bounding_box_corners() { + if (mesh_.empty()) { + return std::make_pair(Point(-1, -1, -1, 1), Point(1, 1, 1, 1)); + } else { + double x_min = 1e10; + double y_min = 1e10; + double z_min = 1e10; + double x_max = -1e10; + double y_max = -1e10; + double z_max = -1e10; + for (auto vi : mesh_.vertex_range()) { + auto pt = proj(mesh_.point(vi)); + x_min = (std::min)(x_min, pt.x()); + y_min = (std::min)(y_min, pt.y()); + z_min = (std::min)(z_min, pt.z()); -void -Viewer_instructor::initialize_bounding_box(){ - auto pair_bounding_box = compute_bounding_box_corners(); - viewer_->set_bounding_box(proj(pair_bounding_box.first),proj(pair_bounding_box.second)); - viewer_->init_scene(); -} - -std::pair -Viewer_instructor::compute_bounding_box_corners(){ - if(mesh_.empty()){ - return std::make_pair(Point(-1,-1,-1,1),Point(1,1,1,1)); - } - else{ - double x_min = 1e10; - double y_min = 1e10; - double z_min = 1e10; - double x_max = -1e10; - double y_max = -1e10; - double z_max = -1e10; - for( auto vi : mesh_.vertex_range()) - { - auto pt = proj(mesh_.point(vi)); - x_min = (std::min)(x_min,pt.x()); - y_min = (std::min)(y_min,pt.y()); - z_min = (std::min)(z_min,pt.z()); - - x_max = (std::max)(x_max,pt.x()); - y_max = (std::max)(y_max,pt.y()); - z_max = (std::max)(z_max,pt.z()); - - } - return std::make_pair( - Point(x_min,y_min,z_min,1.), - Point(x_max,y_max,z_max,1.) - ); - } + x_max = (std::max)(x_max, pt.x()); + y_max = (std::max)(y_max, pt.y()); + z_max = (std::max)(z_max, pt.z()); + } + return std::make_pair(Point(x_min, y_min, z_min, 1.), + Point(x_max, y_max, z_max, 1.)); + } } -void -Viewer_instructor::show_entire_scene(){ - viewer_->show_entire_scene(); +void Viewer_instructor::show_entire_scene() { + viewer_->show_entire_scene(); } -const qglviewer::Camera* -Viewer_instructor::camera() const{ - return viewer_->camera(); +const qglviewer::Camera* Viewer_instructor::camera() const { + return viewer_->camera(); } int -Viewer_instructor::width() const{ - return viewer_->width(); +Viewer_instructor::width() const { + return viewer_->width(); } + int -Viewer_instructor::height() const{ - return viewer_->height(); +Viewer_instructor::height() const { + return viewer_->height(); } /** * to change display parameters */ -View_parameter& -Viewer_instructor::view_params(){ - return view_params_; +View_parameter& Viewer_instructor::view_params() { + return view_params_; } - void -Viewer_instructor::give_instructions(){ - if(view_params_.relative_light) - viewer_->set_light_direction(); - else - viewer_->set_light_direction(view_params_.theta,view_params_.phi); - viewer_->set_light(); - - if (view_params_.edge_mode) draw_edges(); - if (view_params_.triangle_mode) draw_triangles(); - if (view_params_.vertex_mode) draw_points(); +Viewer_instructor::give_instructions() { + if (view_params_.relative_light) + viewer_->set_light_direction(); + else + viewer_->set_light_direction(view_params_.theta, view_params_.phi); + viewer_->set_light(); + if (view_params_.edge_mode) draw_edges(); + if (view_params_.triangle_mode) draw_triangles(); + if (view_params_.vertex_mode) draw_points(); } -void -Viewer_instructor::draw_edges(){ - viewer_->begin_draw_edges(view_params_.size_edges,false); +void Viewer_instructor::draw_edges() { + viewer_->begin_draw_edges(view_params_.size_edges, false); - for(auto edge : mesh_.edge_range()){ - set_color_edge(edge); - const Point& a = mesh_.point(mesh_.first_vertex(edge)); - const Point& b = mesh_.point(mesh_.second_vertex(edge)) ; - viewer_->draw_edges(proj(a),proj(b)); - } + for (auto edge : mesh_.edge_range()) { + set_color_edge(edge); + const Point& a = mesh_.point(mesh_.first_vertex(edge)); + const Point& b = mesh_.point(mesh_.second_vertex(edge)); + viewer_->draw_edges(proj(a), proj(b)); + } - viewer_->end_draw_edges(); + viewer_->end_draw_edges(); } -void -Viewer_instructor::draw_triangles(){ - const double size_triangles = 1.0; - viewer_->begin_draw_triangles(size_triangles,view_params_.light); - - for(const auto& fit : mesh_.triangle_range()) { - set_color_triangle(fit); - if(view_params_.triangle_mode){ - auto fit_it = fit.begin(); - const Point& p1 = mesh_.point(*fit_it); - const Point& p2 = mesh_.point(*(++fit_it)); - const Point& p3 = mesh_.point(*(++fit_it)); - viewer_->draw_triangles(proj(p1),proj(p2),proj(p3)); - } - } - viewer_->end_draw_triangles(); -} +void Viewer_instructor::draw_triangles() { + const double size_triangles = 1.0; + viewer_->begin_draw_triangles(size_triangles, view_params_.light); -void -Viewer_instructor::draw_points(){ - viewer_->begin_draw_points( view_params_.size_vertices); - for( auto vi : mesh_.vertex_range()) - { - viewer_->set_size_point(view_params_.size_vertices); - set_color_vertex(vi); - viewer_->draw_points(proj(mesh_.point(vi))); - } - viewer_->end_draw_points(); + for (const auto& fit : mesh_.triangle_range()) { + set_color_triangle(fit); + if (view_params_.triangle_mode) { + auto fit_it = fit.begin(); + const Point& p1 = mesh_.point(*fit_it); + const Point& p2 = mesh_.point(*(++fit_it)); + const Point& p3 = mesh_.point(*(++fit_it)); + viewer_->draw_triangles(proj(p1), proj(p2), proj(p3)); + } + } + viewer_->end_draw_triangles(); } - -void -Viewer_instructor::draw_edge(const Point&,const Point&){ - +void Viewer_instructor::draw_points() { + viewer_->begin_draw_points(view_params_.size_vertices); + for (auto vi : mesh_.vertex_range()) { + viewer_->set_size_point(view_params_.size_vertices); + set_color_vertex(vi); + viewer_->draw_points(proj(mesh_.point(vi))); + } + viewer_->end_draw_points(); } -void -Viewer_instructor::draw_point(const Point&){ - -} +void Viewer_instructor::draw_edge(const Point&, const Point&) { } +void Viewer_instructor::draw_point(const Point&) { } /** * set the right color of vertex/edge/triangle considering the view_params choice */ -void -Viewer_instructor::set_color_vertex(Vertex_handle vh){ - viewer_->set_color(Color(view_params_.light_edges,view_params_.light_edges,view_params_.light_edges)); +void Viewer_instructor::set_color_vertex(Vertex_handle vh) { + viewer_->set_color(Color(view_params_.light_edges, view_params_.light_edges, view_params_.light_edges)); } -void -Viewer_instructor::set_color_edge(Edge_handle eh) { - viewer_->set_color(Color(view_params_.light_edges,view_params_.light_edges,view_params_.light_edges)); +void Viewer_instructor::set_color_edge(Edge_handle eh) { + viewer_->set_color(Color(view_params_.light_edges, view_params_.light_edges, view_params_.light_edges)); } -void -Viewer_instructor::set_color_triangle(const Simplex_handle& triangle){ - viewer_->set_color(Color(view_params_.light_triangles,view_params_.light_triangles,view_params_.light_triangles)); +void Viewer_instructor::set_color_triangle(const Simplex_handle& triangle) { + viewer_->set_color(Color(view_params_.light_triangles, view_params_.light_triangles, view_params_.light_triangles)); } - Viewer_instructor::Point_3 -Viewer_instructor::proj(const Point& p) const{ - return (*projector_)(p); +Viewer_instructor::proj(const Point& p) const { + return (*projector_)(p); } - -void -Viewer_instructor::sceneChanged(){ - UIDBG("sceneChanged"); - viewer_->update_GL(); +void Viewer_instructor::sceneChanged() { + UIDBG("sceneChanged"); + viewer_->update_GL(); } -void -Viewer_instructor::change_draw_vertices(){ - view_params_.change_vertex_mode(); +void Viewer_instructor::change_draw_vertices() { + view_params_.change_vertex_mode(); } -void -Viewer_instructor::change_draw_edges(){ - view_params_.change_edge_mode(); + +void Viewer_instructor::change_draw_edges() { + view_params_.change_edge_mode(); } -void -Viewer_instructor::change_draw_triangles(){ - view_params_.change_triangle_mode(); + +void Viewer_instructor::change_draw_triangles() { + view_params_.change_triangle_mode(); } -void -Viewer_instructor::change_light(){ - view_params_.light =! view_params_.light ; + +void Viewer_instructor::change_light() { + view_params_.light = !view_params_.light; } #include "Viewer_instructor.moc" diff --git a/src/GudhUI/view/Viewer_instructor.h b/src/GudhUI/view/Viewer_instructor.h index 62b3755e..e1c6af8b 100644 --- a/src/GudhUI/view/Viewer_instructor.h +++ b/src/GudhUI/view/Viewer_instructor.h @@ -1,17 +1,40 @@ -#ifndef VIEWER_INSTRUCTOR_H -#define VIEWER_INSTRUCTOR_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 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 // Workaround for moc-qt4 not parsing boost headers #include -#include - #include #include #include +#include +#include // for pair<> #include "model/Complex_typedefs.h" @@ -22,89 +45,73 @@ class Viewer; class Viewer_parameter; -class Viewer_instructor : public QWidget{ - Q_OBJECT - - typedef Geometry_trait::Point_3 Point_3; - typedef Complex::Point Point; - typedef Complex::Vertex_handle Vertex_handle; - typedef Complex::Edge_handle Edge_handle; - typedef Complex::Simplex_handle Simplex_handle; - - - Viewer* viewer_; - View_parameter view_params_; - const Complex& mesh_; - std::unique_ptr projector_; - - -public: - - Viewer_instructor(QWidget* parent, - Viewer* viewer, - const Complex& mesh - ); - - - void initialize_bounding_box(); - - std::pair compute_bounding_box_corners(); - - void show_entire_scene(); - - const qglviewer::Camera* camera() const; - - int width() const; - int height() const; - - /** - * to change display parameters - */ - View_parameter& view_params(); +class Viewer_instructor : public QWidget { + Q_OBJECT + typedef Geometry_trait::Point_3 Point_3; + typedef Complex::Point Point; + typedef Complex::Vertex_handle Vertex_handle; + typedef Complex::Edge_handle Edge_handle; + typedef Complex::Simplex_handle Simplex_handle; -public: + Viewer* viewer_; + View_parameter view_params_; + const Complex& mesh_; + std::unique_ptr projector_; - /** - * gives instructions to the viewer - */ - void give_instructions(); + public: + Viewer_instructor(QWidget* parent, Viewer* viewer, const Complex& mesh); - void draw_edges(); - void draw_triangles(); - void draw_points(); + void initialize_bounding_box(); + std::pair compute_bounding_box_corners(); - void draw_edge(const Point&,const Point&); + void show_entire_scene(); - void draw_point(const Point&); + const qglviewer::Camera* camera() const; + int width() const; + int height() const; - /** - * set the right color of vertex/edge/triangle considering the view_params choice - */ - void set_color_vertex(Vertex_handle vh); - void set_color_edge(Edge_handle eh); + /** + * to change display parameters + */ + View_parameter& view_params(); - void set_color_triangle(const Simplex_handle& triangle); + public: + /** + * gives instructions to the viewer + */ + void give_instructions(); -private: - /** - * Projection to 3D needed for the viewer. - */ - Point_3 proj(const Point& p) const; + void draw_edges(); + void draw_triangles(); + void draw_points(); - public slots : + void draw_edge(const Point&, const Point&); - void sceneChanged(); + void draw_point(const Point&); - void change_draw_vertices(); - void change_draw_edges(); - void change_draw_triangles(); - void change_light(); + /** + * set the right color of vertex/edge/triangle considering the view_params choice + */ + void set_color_vertex(Vertex_handle vh); + void set_color_edge(Edge_handle eh); + void set_color_triangle(const Simplex_handle& triangle); + private: + /** + * Projection to 3D needed for the viewer. + */ + Point_3 proj(const Point& p) const; + public slots: + void sceneChanged(); + void change_draw_vertices(); + void change_draw_edges(); + void change_draw_triangles(); + void change_light(); }; -#endif //VIEWER_INSTRUCTOR_H +#endif // VIEW_VIEWER_INSTRUCTOR_H -- 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/GudhUI') 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/GudhUI') 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