summaryrefslogtreecommitdiff
path: root/example/Simplex_tree
diff options
context:
space:
mode:
Diffstat (limited to 'example/Simplex_tree')
-rw-r--r--example/Simplex_tree/CMakeLists.txt29
-rw-r--r--example/Simplex_tree/README8
-rw-r--r--example/Simplex_tree/example_alpha_shapes_3_simplex_tree_from_off_file.cpp (renamed from example/Simplex_tree/simplex_tree_from_alpha_shapes_3.cpp)26
-rw-r--r--example/Simplex_tree/mini_simplex_tree.cpp9
-rw-r--r--example/Simplex_tree/simple_simplex_tree.cpp15
-rw-r--r--example/Simplex_tree/simplex_tree_from_cliques_of_graph.cpp11
6 files changed, 53 insertions, 45 deletions
diff --git a/example/Simplex_tree/CMakeLists.txt b/example/Simplex_tree/CMakeLists.txt
index 9314a805..b1ea98d4 100644
--- a/example/Simplex_tree/CMakeLists.txt
+++ b/example/Simplex_tree/CMakeLists.txt
@@ -1,29 +1,32 @@
cmake_minimum_required(VERSION 2.6)
project(Simplex_tree_examples)
-add_executable ( simplex_tree_from_cliques_of_graph simplex_tree_from_cliques_of_graph.cpp )
+add_executable ( Simplex_tree_example_from_cliques_of_graph simplex_tree_from_cliques_of_graph.cpp )
if (TBB_FOUND)
- target_link_libraries(simplex_tree_from_cliques_of_graph ${TBB_LIBRARIES})
+ target_link_libraries(Simplex_tree_example_from_cliques_of_graph ${TBB_LIBRARIES})
endif()
-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_test(NAME Simplex_tree_example_from_cliques_of_graph_2 COMMAND $<TARGET_FILE:Simplex_tree_example_from_cliques_of_graph>
+ "${CMAKE_SOURCE_DIR}/data/filtered_simplicial_complex/Klein_bottle_complex.fsc" "2")
+add_test(NAME Simplex_tree_example_from_cliques_of_graph_3 COMMAND $<TARGET_FILE:Simplex_tree_example_from_cliques_of_graph>
+ "${CMAKE_SOURCE_DIR}/data/filtered_simplicial_complex/Klein_bottle_complex.fsc" "3")
-add_executable ( simple_simplex_tree simple_simplex_tree.cpp )
+add_executable ( Simplex_tree_example_simple_simplex_tree simple_simplex_tree.cpp )
if (TBB_FOUND)
- target_link_libraries(simple_simplex_tree ${TBB_LIBRARIES})
+ target_link_libraries(Simplex_tree_example_simple_simplex_tree ${TBB_LIBRARIES})
endif()
-add_test(simple_simplex_tree ${CMAKE_CURRENT_BINARY_DIR}/simple_simplex_tree)
+add_test(NAME Simplex_tree_example_simple_simplex_tree COMMAND $<TARGET_FILE:Simplex_tree_example_simple_simplex_tree>)
-add_executable ( mini_simplex_tree mini_simplex_tree.cpp )
-add_test(mini_simplex_tree ${CMAKE_CURRENT_BINARY_DIR}/mini_simplex_tree)
+add_executable ( Simplex_tree_example_mini_simplex_tree mini_simplex_tree.cpp )
+add_test(NAME Simplex_tree_example_mini_simplex_tree COMMAND $<TARGET_FILE:Simplex_tree_example_mini_simplex_tree>)
# An example with Simplex-tree using CGAL alpha_shapes_3
if(GMP_FOUND AND CGAL_FOUND)
- add_executable ( simplex_tree_from_alpha_shapes_3 simplex_tree_from_alpha_shapes_3.cpp )
- target_link_libraries(simplex_tree_from_alpha_shapes_3 ${GMP_LIBRARIES} ${CGAL_LIBRARY} ${Boost_SYSTEM_LIBRARY})
+ add_executable ( Simplex_tree_example_alpha_shapes_3_from_off example_alpha_shapes_3_simplex_tree_from_off_file.cpp )
+ target_link_libraries(Simplex_tree_example_alpha_shapes_3_from_off ${GMP_LIBRARIES} ${CGAL_LIBRARY} ${Boost_SYSTEM_LIBRARY})
if (TBB_FOUND)
- target_link_libraries(simplex_tree_from_alpha_shapes_3 ${TBB_LIBRARIES})
+ target_link_libraries(Simplex_tree_example_alpha_shapes_3_from_off ${TBB_LIBRARIES})
endif()
- add_test(simplex_tree_from_alpha_shapes_3 ${CMAKE_CURRENT_BINARY_DIR}/simplex_tree_from_alpha_shapes_3 ${CMAKE_SOURCE_DIR}/data/points/bunny_5000)
+ add_test(NAME Simplex_tree_example_alpha_shapes_3_from_off COMMAND $<TARGET_FILE:Simplex_tree_example_alpha_shapes_3_from_off>
+ "${CMAKE_SOURCE_DIR}/data/points/bunny_5000.off")
endif()
diff --git a/example/Simplex_tree/README b/example/Simplex_tree/README
index e37af790..a9498173 100644
--- a/example/Simplex_tree/README
+++ b/example/Simplex_tree/README
@@ -10,7 +10,7 @@ Example of use :
*** Simple simplex tree construction
-./simple_simplex_tree
+./Simplex_tree_example_simple_simplex_tree
********************************************************************
EXAMPLE OF SIMPLE INSERTION
@@ -52,7 +52,7 @@ EXAMPLE OF SIMPLE INSERTION
*** Simplex tree construction with Z/2Z coefficients on weighted graph Klein bottle file:
-./simplex_tree_from_cliques_of_graph ../../../data/points/Klein_bottle_complex.txt 2
+./Simplex_tree_example_from_cliques_of_graph ../../../data/points/Klein_bottle_complex.txt 2
Insert the 1-skeleton in the simplex tree in 0 s.
Expand the simplex tree in 0 s.
Information of the Simplex Tree:
@@ -60,7 +60,7 @@ Information of the Simplex Tree:
with Z/3Z coefficients:
-./simplex_tree_from_cliques_of_graph ../../../data/points/Klein_bottle_complex.txt 3
+./Simplex_tree_example_from_cliques_of_graph ../../../data/points/Klein_bottle_complex.txt 3
Insert the 1-skeleton in the simplex tree in 0 s.
Expand the simplex tree in 0 s.
@@ -70,4 +70,4 @@ Information of the Simplex Tree:
*** Simplex_tree computed and displayed from a 3D alpha complex:
[ Requires CGAL, GMP and GMPXX to be installed]
-./simplex_tree_from_alpha_shapes_3 ../../../data/points/bunny_5000
+./Simplex_tree_example_alpha_shapes_3_from_off ../../../data/points/bunny_5000
diff --git a/example/Simplex_tree/simplex_tree_from_alpha_shapes_3.cpp b/example/Simplex_tree/example_alpha_shapes_3_simplex_tree_from_off_file.cpp
index 49d358ab..ff2eebcb 100644
--- a/example/Simplex_tree/simplex_tree_from_alpha_shapes_3.cpp
+++ b/example/Simplex_tree/example_alpha_shapes_3_simplex_tree_from_off_file.cpp
@@ -20,8 +20,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <gudhi/graph_simplicial_complex.h>
#include <gudhi/Simplex_tree.h>
+#include <gudhi/Points_3D_off_io.h>
+
#include <boost/variant.hpp>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
@@ -118,24 +119,21 @@ int main(int argc, char * const argv[]) {
// program args management
if (argc != 2) {
std::cerr << "Usage: " << argv[0]
- << " path_to_file_graph \n";
+ << " path_to_off_file \n";
return 0;
}
// Read points from file
- std::string filegraph = argv[1];
- std::list<Point> lp;
- std::ifstream is(filegraph.c_str());
- int n;
- is >> n;
-#ifdef DEBUG_TRACES
- std::cout << "Reading " << n << " points " << std::endl;
-#endif // DEBUG_TRACES
- Point p;
- for (; n > 0; n--) {
- is >> p;
- lp.push_back(p);
+ std::string offInputFile(argv[1]);
+ // Read the OFF file (input file name given as parameter) and triangulate points
+ Gudhi::Points_3D_off_reader<Point> off_reader(offInputFile);
+ // Check the read operation was correct
+ if (!off_reader.is_valid()) {
+ std::cerr << "Unable to read file " << argv[1] << std::endl;
+ return 0;
}
+ // Retrieve the triangulation
+ std::vector<Point> lp = off_reader.get_point_cloud();
// alpha shape construction from points. CGAL has a strange behavior in REGULARIZED mode.
Alpha_shape_3 as(lp.begin(), lp.end(), 0, Alpha_shape_3::GENERAL);
diff --git a/example/Simplex_tree/mini_simplex_tree.cpp b/example/Simplex_tree/mini_simplex_tree.cpp
index 7e48aaaf..ad99df23 100644
--- a/example/Simplex_tree/mini_simplex_tree.cpp
+++ b/example/Simplex_tree/mini_simplex_tree.cpp
@@ -24,19 +24,18 @@
#include <iostream>
#include <initializer_list>
-using namespace Gudhi;
-
-struct MyOptions : Simplex_tree_options_full_featured {
+struct MyOptions : Gudhi::Simplex_tree_options_full_featured {
// Not doing persistence, so we don't need those
static const bool store_key = false;
static const bool store_filtration = false;
// I have few vertices
typedef short Vertex_handle;
};
-typedef Simplex_tree<MyOptions> ST;
+
+using ST = Gudhi::Simplex_tree<MyOptions>;
// Dictionary should be private, but for now this is the easiest way.
-static_assert(sizeof(ST::Dictionary::value_type) < sizeof(Simplex_tree<>::Dictionary::value_type),
+static_assert(sizeof(ST::Dictionary::value_type) < sizeof(Gudhi::Simplex_tree<>::Dictionary::value_type),
"Not storing the filtration and key should save some space");
int main() {
diff --git a/example/Simplex_tree/simple_simplex_tree.cpp b/example/Simplex_tree/simple_simplex_tree.cpp
index 5146b906..60f9a35e 100644
--- a/example/Simplex_tree/simple_simplex_tree.cpp
+++ b/example/Simplex_tree/simple_simplex_tree.cpp
@@ -4,7 +4,7 @@
*
* Author(s): Vincent Rouvreau
*
- * Copyright (C) 2014 INRIA Sophia Antipolis-Méditerranée (France)
+ * Copyright (C) 2014
*
* 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,10 +27,11 @@
#include <utility> // for pair
#include <vector>
-using namespace Gudhi;
-
-typedef std::vector< Vertex_handle > typeVectorVertex;
-typedef std::pair< Simplex_tree<>::Simplex_handle, bool > typePairSimplexBool;
+using Simplex_tree = Gudhi::Simplex_tree<>;
+using Vertex_handle = Simplex_tree::Vertex_handle;
+using Filtration_value = Simplex_tree::Filtration_value;
+using typeVectorVertex = std::vector< Vertex_handle >;
+using typePairSimplexBool = std::pair< Simplex_tree::Simplex_handle, bool >;
int main(int argc, char * const argv[]) {
const Filtration_value FIRST_FILTRATION_VALUE = 0.1;
@@ -42,7 +43,7 @@ int main(int argc, char * const argv[]) {
std::cout << "********************************************************************" << std::endl;
std::cout << "EXAMPLE OF SIMPLE INSERTION" << std::endl;
// Construct the Simplex Tree
- Simplex_tree<> simplexTree;
+ Simplex_tree simplexTree;
/* Simplex to be inserted: */
/* 1 */
@@ -212,7 +213,7 @@ int main(int argc, char * const argv[]) {
// ------------------------------------------------------------------------------------------------------------------
// Find in the simplex_tree
// ------------------------------------------------------------------------------------------------------------------
- Simplex_tree<>::Simplex_handle simplexFound = simplexTree.find(secondSimplexVector);
+ Simplex_tree::Simplex_handle simplexFound = simplexTree.find(secondSimplexVector);
std::cout << "**************IS THE SIMPLEX {1} IN THE SIMPLEX TREE ?\n";
if (simplexFound != simplexTree.null_simplex())
std::cout << "***+ YES IT IS!\n";
diff --git a/example/Simplex_tree/simplex_tree_from_cliques_of_graph.cpp b/example/Simplex_tree/simplex_tree_from_cliques_of_graph.cpp
index 58085014..d1b8b2de 100644
--- a/example/Simplex_tree/simplex_tree_from_cliques_of_graph.cpp
+++ b/example/Simplex_tree/simplex_tree_from_cliques_of_graph.cpp
@@ -4,7 +4,7 @@
*
* Author(s): Clément Maria
*
- * Copyright (C) 2014 INRIA Sophia Antipolis-Méditerranée (France)
+ * Copyright (C) 2014 INRIA
*
* 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
@@ -26,9 +26,16 @@
#include <iostream>
#include <ctime>
#include <string>
+#include <utility> // for std::pair
using namespace Gudhi;
+typedef int Vertex_handle;
+typedef double Filtration_value;
+typedef boost::adjacency_list < boost::vecS, boost::vecS, boost::undirectedS,
+ boost::property < vertex_filtration_t, Filtration_value >,
+ boost::property < edge_filtration_t, Filtration_value > > Graph_t;
+
int main(int argc, char * const argv[]) {
if (argc != 3) {
std::cerr << "Usage: " << argv[0]
@@ -43,7 +50,7 @@ int main(int argc, char * const argv[]) {
Simplex_tree<> st;
start = clock();
- auto g = read_graph(filegraph);
+ auto g = read_graph<Graph_t, Filtration_value, Vertex_handle>(filegraph);
// insert the graph in the simplex tree as 1-skeleton
st.insert_graph(g);
end = clock();