summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorvrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2015-10-05 09:04:17 +0000
committervrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2015-10-05 09:04:17 +0000
commite6962acc2045831e8b2f1b0b4f10717b4c89971c (patch)
tree913a17ce0455b23f44d393ca0c046511a6c4c01d /src
parenta19368075090f5409dc12081df944f90353eb5df (diff)
cpplint fixes
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@822 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 1cab7ed83b02fd90ab57550ad5363dc36f8b8d05
Diffstat (limited to 'src')
-rw-r--r--src/Simplex_tree/example/mini_simplex_tree.cpp11
-rw-r--r--src/Simplex_tree/example/simple_simplex_tree.cpp27
-rw-r--r--src/Simplex_tree/example/simplex_tree_from_alpha_shapes_3.cpp440
-rw-r--r--src/Simplex_tree/example/simplex_tree_from_file.cpp108
-rw-r--r--src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_iterators.h6
-rw-r--r--src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_node_explicit_storage.h8
-rw-r--r--src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_siblings.h14
-rw-r--r--src/Simplex_tree/include/gudhi/Simplex_tree/indexing_tag.h6
-rw-r--r--src/common/include/gudhi/Clock.h151
-rw-r--r--src/common/include/gudhi/Off_reader.h289
-rw-r--r--src/common/include/gudhi/Point.h286
-rw-r--r--src/common/include/gudhi/Simple_object_pool.h57
-rw-r--r--src/common/include/gudhi/Test.h156
-rw-r--r--src/common/include/gudhi/Utils.h74
-rw-r--r--src/common/include/gudhi/distance_functions.h64
-rw-r--r--src/common/include/gudhi/graph_simplicial_complex.h121
-rw-r--r--src/common/include/gudhi/reader_utils.h179
17 files changed, 1015 insertions, 982 deletions
diff --git a/src/Simplex_tree/example/mini_simplex_tree.cpp b/src/Simplex_tree/example/mini_simplex_tree.cpp
index 08d626d3..7e48aaaf 100644
--- a/src/Simplex_tree/example/mini_simplex_tree.cpp
+++ b/src/Simplex_tree/example/mini_simplex_tree.cpp
@@ -58,11 +58,12 @@ int main() {
auto edge02 = {0, 2};
ST::Simplex_handle e = st.find(edge02);
- assert(st.filtration(e) == 0); // We are not using filtrations so everything has value 0
- for(ST::Simplex_handle t : st.cofaces_simplex_range(e, 1)) // Only coface is 012
- {
- for(ST::Vertex_handle v : st.simplex_vertex_range(t)) // v in { 0, 1, 2 }
+ // We are not using filtrations so everything has value 0
+ assert(st.filtration(e) == 0);
+ for (ST::Simplex_handle t : st.cofaces_simplex_range(e, 1)) {
+ // Only coface is 012
+ for (ST::Vertex_handle v : st.simplex_vertex_range(t)) // v in { 0, 1, 2 }
std::cout << v;
std::cout << '\n';
- }
+ }
}
diff --git a/src/Simplex_tree/example/simple_simplex_tree.cpp b/src/Simplex_tree/example/simple_simplex_tree.cpp
index a2e1f0e9..5146b906 100644
--- a/src/Simplex_tree/example/simple_simplex_tree.cpp
+++ b/src/Simplex_tree/example/simple_simplex_tree.cpp
@@ -20,9 +20,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <gudhi/graph_simplicial_complex.h>
+#include <gudhi/Simplex_tree.h>
+
#include <iostream>
-#include "gudhi/graph_simplicial_complex.h"
-#include "gudhi/Simplex_tree.h"
+#include <utility> // for pair
+#include <vector>
using namespace Gudhi;
@@ -38,7 +41,7 @@ int main(int argc, char * const argv[]) {
// TEST OF INSERTION
std::cout << "********************************************************************" << std::endl;
std::cout << "EXAMPLE OF SIMPLE INSERTION" << std::endl;
- //Construct the Simplex Tree
+ // Construct the Simplex Tree
Simplex_tree<> simplexTree;
/* Simplex to be inserted: */
@@ -159,8 +162,8 @@ int main(int argc, char * const argv[]) {
// ++ TENTH
std::cout << " * INSERT 0 (already inserted)" << std::endl;
typeVectorVertex tenthSimplexVector = { 0 };
- returnValue =
- simplexTree.insert_simplex(tenthSimplexVector, Filtration_value(FOURTH_FILTRATION_VALUE)); // With a different filtration value
+ // With a different filtration value
+ returnValue = simplexTree.insert_simplex(tenthSimplexVector, Filtration_value(FOURTH_FILTRATION_VALUE));
if (returnValue.second == true) {
std::cout << " + 0 INSERTED" << std::endl;
@@ -181,18 +184,18 @@ int main(int argc, char * const argv[]) {
}
// ++ GENERAL VARIABLE SET
- simplexTree.set_filtration(FOURTH_FILTRATION_VALUE); // Max filtration value
- simplexTree.set_dimension(2); // Max dimension = 2 -> (2,1,0)
+ simplexTree.set_filtration(FOURTH_FILTRATION_VALUE); // Max filtration value
+ simplexTree.set_dimension(2); // Max dimension = 2 -> (2,1,0)
- std::cout << "********************************************************************" << std::endl;
+ std::cout << "********************************************************************\n";
// Display the Simplex_tree - Can not be done in the middle of 2 inserts
- std::cout << "* The complex contains " << simplexTree.num_simplices() << " simplices" << std::endl;
- std::cout << " - dimension " << simplexTree.dimension() << " - filtration " << simplexTree.filtration() << std::endl;
- std::cout << "* Iterator on Simplices in the filtration, with [filtration value]:" << std::endl;
+ std::cout << "* The complex contains " << simplexTree.num_simplices() << " simplices\n";
+ std::cout << " - dimension " << simplexTree.dimension() << " - filtration " << simplexTree.filtration() << "\n";
+ std::cout << "* Iterator on Simplices in the filtration, with [filtration value]:\n";
for (auto f_simplex : simplexTree.filtration_simplex_range()) {
std::cout << " " << "[" << simplexTree.filtration(f_simplex) << "] ";
for (auto vertex : simplexTree.simplex_vertex_range(f_simplex)) {
- std::cout << (int) vertex << " ";
+ std::cout << static_cast<int>(vertex) << " ";
}
std::cout << std::endl;
}
diff --git a/src/Simplex_tree/example/simplex_tree_from_alpha_shapes_3.cpp b/src/Simplex_tree/example/simplex_tree_from_alpha_shapes_3.cpp
index 5f797e93..45efe3ed 100644
--- a/src/Simplex_tree/example/simplex_tree_from_alpha_shapes_3.cpp
+++ b/src/Simplex_tree/example/simplex_tree_from_alpha_shapes_3.cpp
@@ -1,24 +1,28 @@
- /* This file is part of the Gudhi Library. The Gudhi library
- * (Geometric Understanding in Higher Dimensions) is a generic C++
- * library for computational topology.
- *
- * Author(s): Vincent Rouvreau
- *
- * Copyright (C) 2014 INRIA Saclay (France)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
+/* This file is part of the Gudhi Library. The Gudhi library
+ * (Geometric Understanding in Higher Dimensions) is a generic C++
+ * library for computational topology.
+ *
+ * Author(s): Vincent Rouvreau
+ *
+ * Copyright (C) 2014 INRIA Saclay (France)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <gudhi/graph_simplicial_complex.h>
+#include <gudhi/Simplex_tree.h>
+#include <boost/variant.hpp>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Delaunay_triangulation_3.h>
@@ -27,32 +31,34 @@
#include <fstream>
#include <cmath>
-
-#include "gudhi/graph_simplicial_complex.h"
-#include "gudhi/Simplex_tree.h"
-#include <boost/variant.hpp>
+#include <string>
+#include <tuple> // for tuple<>
+#include <map>
+#include <utility> // for pair<>
+#include <list>
+#include <vector>
// Alpha_shape_3 templates type definitions
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
-typedef CGAL::Alpha_shape_vertex_base_3<Kernel> Vb;
-typedef CGAL::Alpha_shape_cell_base_3<Kernel> Fb;
-typedef CGAL::Triangulation_data_structure_3<Vb,Fb> Tds;
-typedef CGAL::Delaunay_triangulation_3<Kernel,Tds> Triangulation_3;
-typedef CGAL::Alpha_shape_3<Triangulation_3> Alpha_shape_3;
+typedef CGAL::Alpha_shape_vertex_base_3<Kernel> Vb;
+typedef CGAL::Alpha_shape_cell_base_3<Kernel> Fb;
+typedef CGAL::Triangulation_data_structure_3<Vb, Fb> Tds;
+typedef CGAL::Delaunay_triangulation_3<Kernel, Tds> Triangulation_3;
+typedef CGAL::Alpha_shape_3<Triangulation_3> Alpha_shape_3;
// From file type definition
-typedef Kernel::Point_3 Point;
+typedef Kernel::Point_3 Point;
// filtration with alpha values needed type definition
typedef Alpha_shape_3::FT Alpha_value_type;
-typedef CGAL::Object Object;
+typedef CGAL::Object Object;
typedef CGAL::Dispatch_output_iterator<
- CGAL::cpp11::tuple<Object, Alpha_value_type>,
- CGAL::cpp11::tuple<std::back_insert_iterator< std::vector<Object> >, std::back_insert_iterator< std::vector<Alpha_value_type> >
- > > Dispatch;
-typedef Alpha_shape_3::Cell_handle Cell_handle;
-typedef Alpha_shape_3::Facet Facet;
-typedef Alpha_shape_3::Edge Edge;
+CGAL::cpp11::tuple<Object, Alpha_value_type>,
+CGAL::cpp11::tuple<std::back_insert_iterator< std::vector<Object> >,
+ std::back_insert_iterator< std::vector<Alpha_value_type> > > > Dispatch;
+typedef Alpha_shape_3::Cell_handle Cell_handle;
+typedef Alpha_shape_3::Facet Facet;
+typedef Alpha_shape_3::Edge Edge;
typedef std::list<Alpha_shape_3::Vertex_handle> Vertex_list;
// gudhi type definition
@@ -61,225 +67,209 @@ typedef std::map<Alpha_shape_3::Vertex_handle, Simplex_tree_vertex > Alpha_shape
typedef std::pair<Alpha_shape_3::Vertex_handle, Simplex_tree_vertex> Alpha_shape_simplex_tree_pair;
typedef std::vector< Simplex_tree_vertex > Simplex_tree_vector_vertex;
-//#define DEBUG_TRACES
-
-Vertex_list from (const Cell_handle& ch)
-{
- Vertex_list the_list;
- for (auto i = 0; i < 4; i++)
- {
+Vertex_list from(const Cell_handle& ch) {
+ Vertex_list the_list;
+ for (auto i = 0; i < 4; i++) {
#ifdef DEBUG_TRACES
- std::cout << "from cell[" << i << "]=" << ch->vertex(i)->point() << std::endl;
-#endif // DEBUG_TRACES
- the_list.push_back(ch->vertex(i));
- }
- return the_list;
+ std::cout << "from cell[" << i << "]=" << ch->vertex(i)->point() << std::endl;
+#endif // DEBUG_TRACES
+ the_list.push_back(ch->vertex(i));
+ }
+ return the_list;
}
-Vertex_list from (const Facet& fct)
-{
- Vertex_list the_list;
- for (auto i = 0; i < 4; i++)
- {
- if (fct.second != i)
- {
+
+Vertex_list from(const Facet& fct) {
+ Vertex_list the_list;
+ for (auto i = 0; i < 4; i++) {
+ if (fct.second != i) {
#ifdef DEBUG_TRACES
- std::cout << "from facet=[" << i << "]" << fct.first->vertex(i)->point() << std::endl;
-#endif // DEBUG_TRACES
- the_list.push_back(fct.first->vertex(i));
- }
- }
- return the_list;
+ std::cout << "from facet=[" << i << "]" << fct.first->vertex(i)->point() << std::endl;
+#endif // DEBUG_TRACES
+ the_list.push_back(fct.first->vertex(i));
+ }
+ }
+ return the_list;
}
-Vertex_list from (const Edge& edg)
-{
- Vertex_list the_list;
- for (auto i = 0; i < 4; i++)
- {
- if ((edg.second == i) ||(edg.third == i))
- {
+
+Vertex_list from(const Edge& edg) {
+ Vertex_list the_list;
+ for (auto i = 0; i < 4; i++) {
+ if ((edg.second == i) || (edg.third == i)) {
#ifdef DEBUG_TRACES
- std::cout << "from edge[" << i << "]=" << edg.first->vertex(i)->point() << std::endl;
-#endif // DEBUG_TRACES
- the_list.push_back(edg.first->vertex(i));
- }
- }
- return the_list;
+ std::cout << "from edge[" << i << "]=" << edg.first->vertex(i)->point() << std::endl;
+#endif // DEBUG_TRACES
+ the_list.push_back(edg.first->vertex(i));
+ }
+ }
+ return the_list;
}
-Vertex_list from (const Alpha_shape_3::Vertex_handle& vh)
-{
- Vertex_list the_list;
+
+Vertex_list from(const Alpha_shape_3::Vertex_handle& vh) {
+ Vertex_list the_list;
#ifdef DEBUG_TRACES
- std::cout << "from vertex=" << vh->point() << std::endl;
-#endif // DEBUG_TRACES
- the_list.push_back(vh);
- return the_list;
+ std::cout << "from vertex=" << vh->point() << std::endl;
+#endif // DEBUG_TRACES
+ the_list.push_back(vh);
+ return the_list;
}
+int main(int argc, char * const argv[]) {
+ // program args management
+ if (argc != 2) {
+ std::cerr << "Usage: " << argv[0]
+ << " path_to_file_graph \n";
+ return 0;
+ }
-int main (int argc, char * const argv[])
-{
- // program args management
- if (argc != 2) {
- std::cerr << "Usage: " << argv[0]
- << " path_to_file_graph \n";
- return 0; // ----- >>
- }
-
- // Read points from file
- std::string filegraph = argv[1];
- std::list<Point> lp;
- std::ifstream is(filegraph.c_str());
- int n;
- is >> n;
+ // 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::cout << "Reading " << n << " points " << std::endl;
+#endif // DEBUG_TRACES
+ Point p;
+ for (; n > 0; n--) {
+ is >> p;
+ lp.push_back(p);
+ }
- // alpha shape construction from points. CGAL has a strange behavior in REGULARIZED mode.
- Alpha_shape_3 as(lp.begin(),lp.end(),0,Alpha_shape_3::GENERAL);
+ // alpha shape construction from points. CGAL has a strange behavior in REGULARIZED mode.
+ Alpha_shape_3 as(lp.begin(), lp.end(), 0, Alpha_shape_3::GENERAL);
#ifdef DEBUG_TRACES
- std::cout << "Alpha shape computed in GENERAL mode" << std::endl;
-#endif // DEBUG_TRACES
+ std::cout << "Alpha shape computed in GENERAL mode" << std::endl;
+#endif // DEBUG_TRACES
- // filtration with alpha values from alpha shape
- std::vector<Object> the_objects;
- std::vector<Alpha_value_type> the_alpha_values;
+ // filtration with alpha values from alpha shape
+ std::vector<Object> the_objects;
+ std::vector<Alpha_value_type> the_alpha_values;
- Dispatch disp = CGAL::dispatch_output<Object, Alpha_value_type>( std::back_inserter(the_objects), std::back_inserter(the_alpha_values));
+ Dispatch disp = CGAL::dispatch_output<Object, Alpha_value_type>(std::back_inserter(the_objects),
+ std::back_inserter(the_alpha_values));
- as.filtration_with_alpha_values(disp);
+ as.filtration_with_alpha_values(disp);
#ifdef DEBUG_TRACES
- std::cout << "filtration_with_alpha_values returns : " << the_objects.size() << " objects" << std::endl;
-#endif // DEBUG_TRACES
+ std::cout << "filtration_with_alpha_values returns : " << the_objects.size() << " objects" << std::endl;
+#endif // DEBUG_TRACES
- Alpha_shape_3::size_type count_vertices = 0;
- Alpha_shape_3::size_type count_edges = 0;
- Alpha_shape_3::size_type count_facets = 0;
- Alpha_shape_3::size_type count_cells = 0;
+ Alpha_shape_3::size_type count_vertices = 0;
+ Alpha_shape_3::size_type count_edges = 0;
+ Alpha_shape_3::size_type count_facets = 0;
+ Alpha_shape_3::size_type count_cells = 0;
- // Loop on objects vector
- Vertex_list vertex_list;
- Gudhi::Simplex_tree<> simplex_tree;
- Alpha_shape_simplex_tree_map map_cgal_simplex_tree;
- std::vector<Alpha_value_type>::iterator the_alpha_value_iterator = the_alpha_values.begin();
- for(auto object_iterator: the_objects)
- {
- // Retrieve Alpha shape vertex list from object
- if (const Cell_handle* cell = CGAL::object_cast<Cell_handle>(&object_iterator))
- {
- vertex_list = from(*cell);
- count_cells++;
- }
- else if (const Facet* facet = CGAL::object_cast<Facet>(&object_iterator))
- {
- vertex_list = from(*facet);
- count_facets++;
- }
- else if (const Edge* edge = CGAL::object_cast<Edge>(&object_iterator))
- {
- vertex_list = from(*edge);
- count_edges++;
- }
- else if (const Alpha_shape_3::Vertex_handle* vertex = CGAL::object_cast<Alpha_shape_3::Vertex_handle>(&object_iterator))
- {
- count_vertices++;
- vertex_list = from(*vertex);
- }
- // Construction of the vector of simplex_tree vertex from list of alpha_shapes vertex
- Simplex_tree_vector_vertex the_simplex_tree;
- for (auto the_alpha_shape_vertex:vertex_list)
- {
- Alpha_shape_simplex_tree_map::iterator the_map_iterator = map_cgal_simplex_tree.find(the_alpha_shape_vertex);
- if (the_map_iterator == map_cgal_simplex_tree.end())
- {
- // alpha shape not found
- Simplex_tree_vertex vertex = map_cgal_simplex_tree.size();
+ // Loop on objects vector
+ Vertex_list vertex_list;
+ Gudhi::Simplex_tree<> simplex_tree;
+ Alpha_shape_simplex_tree_map map_cgal_simplex_tree;
+ std::vector<Alpha_value_type>::iterator the_alpha_value_iterator = the_alpha_values.begin();
+ for (auto object_iterator : the_objects) {
+ // Retrieve Alpha shape vertex list from object
+ if (const Cell_handle * cell = CGAL::object_cast<Cell_handle>(&object_iterator)) {
+ vertex_list = from(*cell);
+ count_cells++;
+ } else if (const Facet * facet = CGAL::object_cast<Facet>(&object_iterator)) {
+ vertex_list = from(*facet);
+ count_facets++;
+ } else if (const Edge * edge = CGAL::object_cast<Edge>(&object_iterator)) {
+ vertex_list = from(*edge);
+ count_edges++;
+ } else if (const Alpha_shape_3::Vertex_handle * vertex =
+ CGAL::object_cast<Alpha_shape_3::Vertex_handle>(&object_iterator)) {
+ count_vertices++;
+ vertex_list = from(*vertex);
+ }
+ // Construction of the vector of simplex_tree vertex from list of alpha_shapes vertex
+ Simplex_tree_vector_vertex the_simplex_tree;
+ for (auto the_alpha_shape_vertex : vertex_list) {
+ Alpha_shape_simplex_tree_map::iterator the_map_iterator = map_cgal_simplex_tree.find(the_alpha_shape_vertex);
+ if (the_map_iterator == map_cgal_simplex_tree.end()) {
+ // alpha shape not found
+ Simplex_tree_vertex vertex = map_cgal_simplex_tree.size();
#ifdef DEBUG_TRACES
- std::cout << "vertex [" << the_alpha_shape_vertex->point() << "] not found - insert_simplex " << vertex << std::endl;
-#endif // DEBUG_TRACES
- the_simplex_tree.push_back(vertex);
- map_cgal_simplex_tree.insert(Alpha_shape_simplex_tree_pair(the_alpha_shape_vertex,vertex));
- } else
- {
- // alpha shape found
- Simplex_tree_vertex vertex = the_map_iterator->second;
+ std::cout << "vertex [" << the_alpha_shape_vertex->point() << "] not found - insert_simplex " << vertex << "\n";
+#endif // DEBUG_TRACES
+ the_simplex_tree.push_back(vertex);
+ map_cgal_simplex_tree.insert(Alpha_shape_simplex_tree_pair(the_alpha_shape_vertex, vertex));
+ } else {
+ // alpha shape found
+ Simplex_tree_vertex vertex = the_map_iterator->second;
#ifdef DEBUG_TRACES
- std::cout << "vertex [" << the_alpha_shape_vertex->point() << "] found in " << vertex << std::endl;
-#endif // DEBUG_TRACES
- the_simplex_tree.push_back(vertex);
- }
- }
- // Construction of the simplex_tree
+ std::cout << "vertex [" << the_alpha_shape_vertex->point() << "] found in " << vertex << std::endl;
+#endif // DEBUG_TRACES
+ the_simplex_tree.push_back(vertex);
+ }
+ }
+ // Construction of the simplex_tree
#ifdef DEBUG_TRACES
- std::cout << "filtration = " << *the_alpha_value_iterator << std::endl;
-#endif // DEBUG_TRACES
- simplex_tree.insert_simplex(the_simplex_tree, std::sqrt(*the_alpha_value_iterator));
- if (the_alpha_value_iterator != the_alpha_values.end())
- ++the_alpha_value_iterator;
- else
- std::cout << "This shall not happen" << std::endl;
- }
+ std::cout << "filtration = " << *the_alpha_value_iterator << std::endl;
+#endif // DEBUG_TRACES
+ simplex_tree.insert_simplex(the_simplex_tree, std::sqrt(*the_alpha_value_iterator));
+ if (the_alpha_value_iterator != the_alpha_values.end())
+ ++the_alpha_value_iterator;
+ else
+ std::cerr << "This shall not happen" << std::endl;
+ }
#ifdef DEBUG_TRACES
- std::cout << "vertices \t\t" << count_vertices << std::endl;
- std::cout << "edges \t\t" << count_edges << std::endl;
- std::cout << "facets \t\t" << count_facets << std::endl;
- std::cout << "cells \t\t" << count_cells << std::endl;
+ std::cout << "vertices \t\t" << count_vertices << std::endl;
+ std::cout << "edges \t\t" << count_edges << std::endl;
+ std::cout << "facets \t\t" << count_facets << std::endl;
+ std::cout << "cells \t\t" << count_cells << std::endl;
- std::cout << "Information of the Simplex Tree: " << std::endl;
- std::cout << " Number of vertices = " << simplex_tree.num_vertices() << " ";
- std::cout << " Number of simplices = " << simplex_tree.num_simplices() << std::endl << std::endl;
-#endif // DEBUG_TRACES
+ std::cout << "Information of the Simplex Tree:\n";
+ std::cout << " Number of vertices = " << simplex_tree.num_vertices() << " ";
+ std::cout << " Number of simplices = " << simplex_tree.num_simplices() << std::endl << std::endl;
+#endif // DEBUG_TRACES
#ifdef DEBUG_TRACES
- std::cout << "Iterator on vertices: " << std::endl;
- for( auto vertex : simplex_tree.complex_vertex_range() )
- { std::cout << vertex << " "; }
-#endif // DEBUG_TRACES
+ std::cout << "Iterator on vertices: \n";
+ for (auto vertex : simplex_tree.complex_vertex_range()) {
+ std::cout << vertex << " ";
+ }
+#endif // DEBUG_TRACES
- std::cout << simplex_tree << std::endl;
+ std::cout << simplex_tree << std::endl;
#ifdef DEBUG_TRACES
- std::cout << std::endl << std::endl << "Iterator on simplices: " << std::endl;
- for( auto simplex : simplex_tree.complex_simplex_range() )
- {
- std::cout << " ";
- for( auto vertex : simplex_tree.simplex_vertex_range(simplex) ) { std::cout << vertex << " "; }
- std::cout << std::endl;
- }
-#endif // DEBUG_TRACES
+ std::cout << std::endl << std::endl << "Iterator on simplices:\n";
+ for (auto simplex : simplex_tree.complex_simplex_range()) {
+ std::cout << " ";
+ for (auto vertex : simplex_tree.simplex_vertex_range(simplex)) {
+ std::cout << vertex << " ";
+ }
+ std::cout << std::endl;
+ }
+#endif // DEBUG_TRACES
#ifdef DEBUG_TRACES
- std::cout << std::endl << std::endl << "Iterator on Simplices in the filtration, with [filtration value]:" << std::endl;
- for( auto f_simplex : simplex_tree.filtration_simplex_range() )
- { std::cout << " " << "[" << simplex_tree.filtration(f_simplex) << "] ";
- for( auto vertex : simplex_tree.simplex_vertex_range(f_simplex) )
- { std::cout << vertex << " "; }
- std::cout << std::endl;
- }
-#endif // DEBUG_TRACES
+ std::cout << std::endl << std::endl << "Iterator on Simplices in the filtration, with [filtration value]:\n";
+ for (auto f_simplex : simplex_tree.filtration_simplex_range()) {
+ std::cout << " " << "[" << simplex_tree.filtration(f_simplex) << "] ";
+ for (auto vertex : simplex_tree.simplex_vertex_range(f_simplex)) {
+ std::cout << vertex << " ";
+ }
+ std::cout << std::endl;
+ }
+#endif // DEBUG_TRACES
#ifdef DEBUG_TRACES
- std::cout << std::endl << std::endl << "Iterator on Simplices in the filtration, and their boundary simplices:" << std::endl;
- for( auto f_simplex : simplex_tree.filtration_simplex_range() )
- {
- std::cout << " " << "[" << simplex_tree.filtration(f_simplex) << "] ";
- for( auto vertex : simplex_tree.simplex_vertex_range(f_simplex) )
- { std::cout << vertex << " "; }
- std::cout << std::endl;
+ std::cout << std::endl << std::endl << "Iterator on Simplices in the filtration, and their boundary simplices:\n";
+ for (auto f_simplex : simplex_tree.filtration_simplex_range()) {
+ std::cout << " " << "[" << simplex_tree.filtration(f_simplex) << "] ";
+ for (auto vertex : simplex_tree.simplex_vertex_range(f_simplex)) {
+ std::cout << vertex << " ";
+ }
+ std::cout << std::endl;
- for( auto b_simplex : simplex_tree.boundary_simplex_range(f_simplex) )
- {
- std::cout << " " << "[" << simplex_tree.filtration(b_simplex) << "] ";
- for( auto vertex : simplex_tree.simplex_vertex_range(b_simplex) )
- { std::cout << vertex << " "; }
- std::cout << std::endl;
- }
- }
-#endif // DEBUG_TRACES
+ for (auto b_simplex : simplex_tree.boundary_simplex_range(f_simplex)) {
+ std::cout << " " << "[" << simplex_tree.filtration(b_simplex) << "] ";
+ for (auto vertex : simplex_tree.simplex_vertex_range(b_simplex)) {
+ std::cout << vertex << " ";
+ }
+ std::cout << std::endl;
+ }
+ }
+#endif // DEBUG_TRACES
- return 0;
+ return 0;
}
diff --git a/src/Simplex_tree/example/simplex_tree_from_file.cpp b/src/Simplex_tree/example/simplex_tree_from_file.cpp
index 20e8f067..58085014 100644
--- a/src/Simplex_tree/example/simplex_tree_from_file.cpp
+++ b/src/Simplex_tree/example/simplex_tree_from_file.cpp
@@ -1,59 +1,62 @@
- /* This file is part of the Gudhi Library. The Gudhi library
- * (Geometric Understanding in Higher Dimensions) is a generic C++
- * library for computational topology.
- *
- * Author(s): Clément Maria
- *
- * Copyright (C) 2014 INRIA Sophia Antipolis-Méditerranée (France)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
+/* This file is part of the Gudhi Library. The Gudhi library
+ * (Geometric Understanding in Higher Dimensions) is a generic C++
+ * library for computational topology.
+ *
+ * Author(s): 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 <http://www.gnu.org/licenses/>.
+ */
+
+#include <gudhi/reader_utils.h>
+#include <gudhi/Simplex_tree.h>
#include <iostream>
#include <ctime>
-#include "gudhi/reader_utils.h"
-#include "gudhi/Simplex_tree.h"
+#include <string>
using namespace Gudhi;
-int main (int argc, char * const argv[])
-{
+int main(int argc, char * const argv[]) {
if (argc != 3) {
std::cerr << "Usage: " << argv[0]
- << " path_to_file_graph max_dim \n";
+ << " path_to_file_graph max_dim \n";
return 0;
}
- std::string filegraph = argv[1];
- int max_dim = atoi(argv[2]);
+ std::string filegraph = argv[1];
+ int max_dim = atoi(argv[2]);
clock_t start, end;
- //Construct the Simplex Tree
+ // Construct the Simplex Tree
Simplex_tree<> st;
start = clock();
auto g = read_graph(filegraph);
- st.insert_graph (g); //insert the graph in the simplex tree as 1-skeleton
+ // insert the graph in the simplex tree as 1-skeleton
+ st.insert_graph(g);
end = clock();
std::cout << "Insert the 1-skeleton in the simplex tree in "
- << (double)(end-start)/CLOCKS_PER_SEC << " s. \n";
+ << static_cast<double>(end - start) / CLOCKS_PER_SEC << " s. \n";
start = clock();
- st.expansion ( max_dim ); //expand the 1-skeleton until dimension max_dim
+ // expand the 1-skeleton until dimension max_dim
+ st.expansion(max_dim);
end = clock();
std::cout << "max_dim = " << max_dim << "\n";
std::cout << "Expand the simplex tree in "
- << (double)(end-start)/CLOCKS_PER_SEC << " s. \n";
+ << static_cast<double>(end - start) / CLOCKS_PER_SEC << " s. \n";
std::cout << "Information of the Simplex Tree: " << std::endl;
std::cout << " Number of vertices = " << st.num_vertices() << " ";
@@ -61,43 +64,50 @@ int main (int argc, char * const argv[])
std::cout << std::endl << std::endl;
std::cout << "Iterator on vertices: ";
- for( auto vertex : st.complex_vertex_range() ) { std::cout << vertex << " "; }
+ for (auto vertex : st.complex_vertex_range()) {
+ std::cout << vertex << " ";
+ }
std::cout << std::endl;
std::cout << std::endl << std::endl;
std::cout << "Iterator on simplices: " << std::endl;
- for( auto simplex : st.complex_simplex_range() )
- {
+ for (auto simplex : st.complex_simplex_range()) {
std::cout << " ";
- for( auto vertex : st.simplex_vertex_range(simplex) ) { std::cout << vertex << " "; }
+ for (auto vertex : st.simplex_vertex_range(simplex)) {
+ std::cout << vertex << " ";
+ }
std::cout << std::endl;
}
std::cout << std::endl << std::endl;
std::cout << "Iterator on Simplices in the filtration, with [filtration value]:" << std::endl;
- for( auto f_simplex : st.filtration_simplex_range() )
- { std::cout << " " << "[" << st.filtration(f_simplex) << "] ";
- for( auto vertex : st.simplex_vertex_range(f_simplex) )
- { std::cout << vertex << " "; } std::cout << std::endl;
+ for (auto f_simplex : st.filtration_simplex_range()) {
+ std::cout << " " << "[" << st.filtration(f_simplex) << "] ";
+ for (auto vertex : st.simplex_vertex_range(f_simplex)) {
+ std::cout << vertex << " ";
+ }
+ std::cout << std::endl;
}
std::cout << std::endl << std::endl;
std::cout << "Iterator on Simplices in the filtration, and their boundary simplices:" << std::endl;
- for( auto f_simplex : st.filtration_simplex_range() )
- {
+ for (auto f_simplex : st.filtration_simplex_range()) {
std::cout << " " << "[" << st.filtration(f_simplex) << "] ";
- for( auto vertex : st.simplex_vertex_range(f_simplex) )
- { std::cout << vertex << " "; } std::cout << std::endl;
+ for (auto vertex : st.simplex_vertex_range(f_simplex)) {
+ std::cout << vertex << " ";
+ }
+ std::cout << std::endl;
- for( auto b_simplex : st.boundary_simplex_range(f_simplex) )
- {
+ for (auto b_simplex : st.boundary_simplex_range(f_simplex)) {
std::cout << " " << "[" << st.filtration(b_simplex) << "] ";
- for( auto vertex : st.simplex_vertex_range(b_simplex) )
- { std::cout << vertex << " "; } std::cout << std::endl;
+ for (auto vertex : st.simplex_vertex_range(b_simplex)) {
+ std::cout << vertex << " ";
+ }
+ std::cout << std::endl;
}
}
return 0;
diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_iterators.h b/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_iterators.h
index 06462c88..8cf5a67e 100644
--- a/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_iterators.h
+++ b/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_iterators.h
@@ -20,8 +20,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef SRC_SIMPLEX_TREE_INCLUDE_GUDHI_SIMPLEX_TREE_SIMPLEX_TREE_ITERATORS_H_
-#define SRC_SIMPLEX_TREE_INCLUDE_GUDHI_SIMPLEX_TREE_SIMPLEX_TREE_ITERATORS_H_
+#ifndef SIMPLEX_TREE_ITERATORS_H_
+#define SIMPLEX_TREE_ITERATORS_H_
#include <boost/iterator/iterator_facade.hpp>
@@ -303,4 +303,4 @@ class Simplex_tree_skeleton_simplex_iterator : public boost::iterator_facade<
/* @} */ // end addtogroup simplex_tree
} // namespace Gudhi
-#endif // SRC_SIMPLEX_TREE_INCLUDE_GUDHI_SIMPLEX_TREE_SIMPLEX_TREE_ITERATORS_H_
+#endif // SIMPLEX_TREE_ITERATORS_H_
diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_node_explicit_storage.h b/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_node_explicit_storage.h
index c49e30b9..7f735b7e 100644
--- a/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_node_explicit_storage.h
+++ b/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_node_explicit_storage.h
@@ -20,8 +20,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef SRC_SIMPLEX_TREE_INCLUDE_GUDHI_SIMPLEX_TREE_SIMPLEX_TREE_NODE_EXPLICIT_STORAGE_H_
-#define SRC_SIMPLEX_TREE_INCLUDE_GUDHI_SIMPLEX_TREE_SIMPLEX_TREE_NODE_EXPLICIT_STORAGE_H_
+#ifndef SIMPLEX_TREE_NODE_EXPLICIT_STORAGE_H_
+#define SIMPLEX_TREE_NODE_EXPLICIT_STORAGE_H_
#include <vector>
@@ -47,7 +47,7 @@ struct Simplex_tree_node_explicit_storage : SimplexTree::Filtration_simplex_base
Simplex_tree_node_explicit_storage(Siblings * sib = nullptr,
Filtration_value filtration = 0)
: children_(sib) {
- this->assign_filtration(filtration);
+ this->assign_filtration(filtration);
}
/*
@@ -69,4 +69,4 @@ struct Simplex_tree_node_explicit_storage : SimplexTree::Filtration_simplex_base
/* @} */ // end addtogroup simplex_tree
} // namespace Gudhi
-#endif // SRC_SIMPLEX_TREE_INCLUDE_GUDHI_SIMPLEX_TREE_SIMPLEX_TREE_NODE_EXPLICIT_STORAGE_H_
+#endif // SIMPLEX_TREE_NODE_EXPLICIT_STORAGE_H_
diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_siblings.h b/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_siblings.h
index d20a91d7..52eeaaea 100644
--- a/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_siblings.h
+++ b/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_siblings.h
@@ -20,15 +20,15 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef SRC_SIMPLEX_TREE_INCLUDE_GUDHI_SIMPLEX_TREE_SIMPLEX_TREE_SIBLINGS_H_
-#define SRC_SIMPLEX_TREE_INCLUDE_GUDHI_SIMPLEX_TREE_SIMPLEX_TREE_SIBLINGS_H_
-
-#include "boost/container/flat_map.hpp"
-#include "Simplex_tree_node_explicit_storage.h"
+#ifndef SIMPLEX_TREE_SIBLINGS_H_
+#define SIMPLEX_TREE_SIBLINGS_H_
#include <utility>
#include <vector>
+#include "boost/container/flat_map.hpp"
+#include "Simplex_tree_node_explicit_storage.h"
+
namespace Gudhi {
/* \addtogroup simplex_tree
@@ -79,7 +79,7 @@ class Simplex_tree_siblings {
members.end()) {
for (auto& map_el : members_) {
map_el.second.assign_children(this);
- }
+ }
}
/*
@@ -123,4 +123,4 @@ class Simplex_tree_siblings {
/* @} */ // end addtogroup simplex_tree
} // namespace Gudhi
-#endif // SRC_SIMPLEX_TREE_INCLUDE_GUDHI_SIMPLEX_TREE_SIMPLEX_TREE_SIBLINGS_H_
+#endif // SIMPLEX_TREE_SIBLINGS_H_
diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree/indexing_tag.h b/src/Simplex_tree/include/gudhi/Simplex_tree/indexing_tag.h
index 69ffa44b..a00dac27 100644
--- a/src/Simplex_tree/include/gudhi/Simplex_tree/indexing_tag.h
+++ b/src/Simplex_tree/include/gudhi/Simplex_tree/indexing_tag.h
@@ -20,8 +20,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef SRC_SIMPLEX_TREE_INCLUDE_GUDHI_SIMPLEX_TREE_INDEXING_TAG_H_
-#define SRC_SIMPLEX_TREE_INCLUDE_GUDHI_SIMPLEX_TREE_INDEXING_TAG_H_
+#ifndef INDEXING_TAG_H_
+#define INDEXING_TAG_H_
namespace Gudhi {
@@ -36,4 +36,4 @@ struct linear_indexing_tag {
// struct zigzag_indexing_tag {};
} // namespace Gudhi
-#endif // SRC_SIMPLEX_TREE_INCLUDE_GUDHI_SIMPLEX_TREE_INDEXING_TAG_H_
+#endif // INDEXING_TAG_H_
diff --git a/src/common/include/gudhi/Clock.h b/src/common/include/gudhi/Clock.h
index 08096c05..04c6ffb9 100644
--- a/src/common/include/gudhi/Clock.h
+++ b/src/common/include/gudhi/Clock.h
@@ -1,82 +1,79 @@
- /* This file is part of the Gudhi Library. The Gudhi library
- * (Geometric Understanding in Higher Dimensions) is a generic C++
- * library for computational topology.
- *
- * Author(s): David Salinas
- *
- * Copyright (C) 2014 INRIA Sophia Antipolis-Mediterranee (France)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef GUDHI_CLOCK_H_
-#define GUDHI_CLOCK_H_
-
+/* This file is part of the Gudhi Library. The Gudhi library
+ * (Geometric Understanding in Higher Dimensions) is a generic C++
+ * library for computational topology.
+ *
+ * Author(s): David Salinas
+ *
+ * Copyright (C) 2014 INRIA Sophia Antipolis-Mediterranee (France)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef CLOCK_H_
+#define CLOCK_H_
#include <boost/date_time/posix_time/posix_time.hpp>
-class Clock{
-
-public:
- Clock():end_called(false){
- startTime = boost::posix_time::microsec_clock::local_time( );
- }
-
- Clock(const std::string& msg_){
- end_called = false;
- begin();
- msg = msg_;
- }
-
-
- void begin() const{
- end_called = false;
- startTime = boost::posix_time::microsec_clock::local_time( );
- }
-
- void end() const{
- end_called = true;
- endTime = boost::posix_time::microsec_clock::local_time( );
- }
-
- void print() const{
- std::cout << *this << std::endl;
- }
-
- friend std::ostream& operator<< (std::ostream& stream,const Clock& clock){
- if(!clock.end_called)
- clock.end();
-
- if(!clock.end_called) stream << "end not called";
- else{
- stream << clock.msg <<":"<<clock.num_seconds() <<"s";
- }
- return stream;
-
- }
-
- double num_seconds() const{
- if(!end_called) return -1;
- return (endTime-startTime).total_milliseconds()/1000.;
- }
-
-private:
- mutable boost::posix_time::ptime startTime, endTime;
- mutable bool end_called;
- std::string msg;
-
+#include <string>
+
+class Clock {
+ public:
+ Clock() : end_called(false) {
+ startTime = boost::posix_time::microsec_clock::local_time();
+ }
+
+ Clock(const std::string& msg_) {
+ end_called = false;
+ begin();
+ msg = msg_;
+ }
+
+ void begin() const {
+ end_called = false;
+ startTime = boost::posix_time::microsec_clock::local_time();
+ }
+
+ void end() const {
+ end_called = true;
+ endTime = boost::posix_time::microsec_clock::local_time();
+ }
+
+ void print() const {
+ std::cout << *this << std::endl;
+ }
+
+ friend std::ostream& operator<<(std::ostream& stream, const Clock& clock) {
+ if (!clock.end_called)
+ clock.end();
+
+ if (!clock.end_called) {
+ stream << "end not called";
+ } else {
+ stream << clock.msg << ":" << clock.num_seconds() << "s";
+ }
+ return stream;
+ }
+
+ double num_seconds() const {
+ if (!end_called) return -1;
+ return (endTime - startTime).total_milliseconds() / 1000.;
+ }
+
+ private:
+ mutable boost::posix_time::ptime startTime, endTime;
+ mutable bool end_called;
+ std::string msg;
};
-
-#endif /* GUDHI_CLOCK_H_ */
+#endif // CLOCK_H_
diff --git a/src/common/include/gudhi/Off_reader.h b/src/common/include/gudhi/Off_reader.h
index e29218d8..b70e7897 100644
--- a/src/common/include/gudhi/Off_reader.h
+++ b/src/common/include/gudhi/Off_reader.h
@@ -1,13 +1,10 @@
-/*
- * Off_reader.h
- * Created on: Nov 28, 2014
- * This file is part of the Gudhi Library. The Gudhi library
+/* This file is part of the Gudhi Library. The Gudhi library
* (Geometric Understanding in Higher Dimensions) is a generic C++
* library for computational topology.
*
* Author(s): David Salinas
*
- * Copyright (C) 2014 INRIA Sophia Antipolis-Méditerranée (France)
+ * Copyright (C) 2014 INRIA Sophia Antipolis-Mediterranee (France)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -25,14 +22,15 @@
*/
-#ifndef GUDHI_OFF_READER_H_
-#define GUDHI_OFF_READER_H_
+#ifndef OFF_READER_H_
+#define OFF_READER_H_
#include <sstream>
#include <iostream>
#include <iterator>
-
+#include <string>
+#include <vector>
namespace Gudhi {
@@ -48,151 +46,144 @@ namespace Gudhi {
*
* The number of edges num_edges is optional and can be left to zero.
*/
-class Off_reader{
-public:
- Off_reader(std::ifstream& stream):stream_(stream){
- }
-// Off_reader(const std::string& name):stream_(name){
-// if(!stream_.is_open())
-// std::cerr <<"could not open file \n";
-// }
-
- ~Off_reader(){
- stream_.close();
- }
-
- /**
- * read an off file and calls the following methods :
- * void init(int dim,int num_vertices,int num_faces,int num_edges); //num_edges may not be set
- * void point(const std::vector<double>& point);
- * void maximal_face(const std::list<int>& face);
- * void done();
- * of the visitor when reading a point or a maximal face.
- */
- template<typename OffVisitor>
- bool read(OffVisitor& off_visitor){
- bool success_read_off_preambule = read_off_preambule(off_visitor);
- if(!success_read_off_preambule) {
- std::cerr <<"could not read off preambule\n";
- return false;
- }
-
- bool success_read_off_points = read_off_points(off_visitor);
- if(!success_read_off_points) {
- std::cerr <<"could not read off points\n";
- return false;
- }
-
- bool success_read_off_faces = read_off_faces(off_visitor);
- if(!success_read_off_faces) {
- std::cerr <<"could not read off faces\n";
- return false;
- }
-
- off_visitor.done();
- return success_read_off_preambule && success_read_off_points && success_read_off_faces;
- }
-
-private:
- std::ifstream& stream_;
-
- struct Off_info{
- int dim;
- int num_vertices;
- int num_edges;
- int num_faces;
- };
-
- Off_info off_info_;
-
- template<typename OffVisitor>
- bool read_off_preambule(OffVisitor& off_visitor){
- std::string line;
- if(!goto_next_uncomment_line(line)) return false;
-
- bool is_off_file = (line.find("OFF") != std::string::npos);
- bool is_noff_file = (line.find("nOFF") != std::string::npos);
-
- if(!is_off_file && !is_noff_file) {
- std::cerr << line<<std::endl;
- std::cerr << "missing off header\n";
- return false;
- }
-
- if(!goto_next_uncomment_line(line)) return false;
- std::istringstream iss(line);
- if(is_off_file){
- off_info_.dim = 3;
- if(!(iss >> off_info_.num_vertices >> off_info_.num_faces >> off_info_.num_edges)){
- std::cerr << "incorrect number of vertices/faces/edges\n";
- return false;
- }
- }
- else
- if(!(iss >> off_info_.dim >> off_info_.num_vertices >> off_info_.num_faces >> off_info_.num_edges)){
- std::cerr << "incorrect number of vertices/faces/edges\n";
- return false;
- }
- off_visitor.init(off_info_.dim,off_info_.num_vertices,off_info_.num_faces,off_info_.num_edges);
-
- return true;
- }
-
- bool goto_next_uncomment_line(std::string& uncomment_line){
- uncomment_line.clear();
- do
- std::getline(stream_, uncomment_line);
- while(uncomment_line[0] == '%');// || uncomment_line.empty());
- return (uncomment_line.size()>0 && uncomment_line[0] != '%');
- }
-
-
- template<typename OffVisitor>
- bool read_off_points(OffVisitor& visitor){
- int num_vertices_to_read = off_info_.num_vertices;
- while(num_vertices_to_read--){
- std::string line;
- if(!goto_next_uncomment_line(line)) return false;
- std::vector<double> point;
- std::istringstream iss(line);
- point.assign(std::istream_iterator<double>(iss),std::istream_iterator<double>());
-// if(point.size() != off_info_.dim) return false;
- visitor.point(point);
- }
- return true;
- }
-
- template<typename OffVisitor>
- bool read_off_faces(OffVisitor& visitor){
- std::string line;
- while(goto_next_uncomment_line(line)){
- std::istringstream iss(line);
- int num_face_vertices;
- iss >> num_face_vertices;
- std::vector<int> face;
- face.assign(std::istream_iterator<int>(iss),std::istream_iterator<int>());
- if(!face.size() == off_info_.num_vertices) return false;
- visitor.maximal_face(face);
- }
- return true;
- }
+class Off_reader {
+ public:
+ Off_reader(std::ifstream& stream) : stream_(stream) { }
+ // Off_reader(const std::string& name):stream_(name){
+ // if(!stream_.is_open())
+ // std::cerr <<"could not open file \n";
+ // }
+
+ ~Off_reader() {
+ stream_.close();
+ }
+
+ /**
+ * read an off file and calls the following methods :
+ * void init(int dim,int num_vertices,int num_faces,int num_edges); //num_edges may not be set
+ * void point(const std::vector<double>& point);
+ * void maximal_face(const std::list<int>& face);
+ * void done();
+ * of the visitor when reading a point or a maximal face.
+ */
+ template<typename OffVisitor>
+ bool read(OffVisitor& off_visitor) {
+ bool success_read_off_preambule = read_off_preambule(off_visitor);
+ if (!success_read_off_preambule) {
+ std::cerr << "could not read off preambule\n";
+ return false;
+ }
+
+ bool success_read_off_points = read_off_points(off_visitor);
+ if (!success_read_off_points) {
+ std::cerr << "could not read off points\n";
+ return false;
+ }
+
+ bool success_read_off_faces = read_off_faces(off_visitor);
+ if (!success_read_off_faces) {
+ std::cerr << "could not read off faces\n";
+ return false;
+ }
+
+ off_visitor.done();
+ return success_read_off_preambule && success_read_off_points && success_read_off_faces;
+ }
+
+ private:
+ std::ifstream& stream_;
+
+ struct Off_info {
+ int dim;
+ int num_vertices;
+ int num_edges;
+ int num_faces;
+ };
+
+ Off_info off_info_;
+
+ template<typename OffVisitor>
+ bool read_off_preambule(OffVisitor& off_visitor) {
+ std::string line;
+ if (!goto_next_uncomment_line(line)) return false;
+
+ bool is_off_file = (line.find("OFF") != std::string::npos);
+ bool is_noff_file = (line.find("nOFF") != std::string::npos);
+
+ if (!is_off_file && !is_noff_file) {
+ std::cerr << line << std::endl;
+ std::cerr << "missing off header\n";
+ return false;
+ }
+
+ if (!goto_next_uncomment_line(line)) return false;
+ std::istringstream iss(line);
+ if (is_off_file) {
+ off_info_.dim = 3;
+ if (!(iss >> off_info_.num_vertices >> off_info_.num_faces >> off_info_.num_edges)) {
+ std::cerr << "incorrect number of vertices/faces/edges\n";
+ return false;
+ }
+ } else {
+ if (!(iss >> off_info_.dim >> off_info_.num_vertices >> off_info_.num_faces >> off_info_.num_edges)) {
+ std::cerr << "incorrect number of vertices/faces/edges\n";
+ return false;
+ }
+ }
+ off_visitor.init(off_info_.dim, off_info_.num_vertices, off_info_.num_faces, off_info_.num_edges);
+
+ return true;
+ }
+
+ bool goto_next_uncomment_line(std::string& uncomment_line) {
+ uncomment_line.clear();
+ do
+ std::getline(stream_, uncomment_line); while (uncomment_line[0] == '%'); // || uncomment_line.empty());
+ return (uncomment_line.size() > 0 && uncomment_line[0] != '%');
+ }
+
+ template<typename OffVisitor>
+ bool read_off_points(OffVisitor& visitor) {
+ int num_vertices_to_read = off_info_.num_vertices;
+ while (num_vertices_to_read--) {
+ std::string line;
+ if (!goto_next_uncomment_line(line)) return false;
+ std::vector<double> point;
+ std::istringstream iss(line);
+ point.assign(std::istream_iterator<double>(iss), std::istream_iterator<double>());
+ // if(point.size() != off_info_.dim) return false;
+ visitor.point(point);
+ }
+ return true;
+ }
+
+ template<typename OffVisitor>
+ bool read_off_faces(OffVisitor& visitor) {
+ std::string line;
+ while (goto_next_uncomment_line(line)) {
+ std::istringstream iss(line);
+ int num_face_vertices;
+ iss >> num_face_vertices;
+ std::vector<int> face;
+ face.assign(std::istream_iterator<int>(iss), std::istream_iterator<int>());
+ if (!face.size() == off_info_.num_vertices) return false;
+ visitor.maximal_face(face);
+ }
+ return true;
+ }
};
-
template<typename OFFVisitor>
-void read_off(const std::string& name_file_off,OFFVisitor& vis){
- std::ifstream stream(name_file_off);
- if(!stream.is_open())
- std::cerr <<"could not open file \n";
- else{
- Off_reader off_reader(stream);
- off_reader.read(vis);
- }
+void read_off(const std::string& name_file_off, OFFVisitor& vis) {
+ std::ifstream stream(name_file_off);
+ if (!stream.is_open()) {
+ std::cerr << "could not open file \n";
+ } else {
+ Off_reader off_reader(stream);
+ off_reader.read(vis);
+ }
}
-
-
} // namespace Gudhi
-
-#endif /* GUDHI_OFF_READER_H_ */
+#endif // OFF_READER_H_
diff --git a/src/common/include/gudhi/Point.h b/src/common/include/gudhi/Point.h
index 4023445b..0479e71e 100644
--- a/src/common/include/gudhi/Point.h
+++ b/src/common/include/gudhi/Point.h
@@ -1,13 +1,10 @@
-/*
- * Basic_geometry.h
- * Created on: Feb 10, 2015
- * This file is part of the Gudhi Library. The Gudhi library
+/* This file is part of the Gudhi Library. The Gudhi library
* (Geometric Understanding in Higher Dimensions) is a generic C++
* library for computational topology.
*
* Author(s): David Salinas
*
- * Copyright (C) 2014 INRIA Sophia Antipolis-Méditerranée (France)
+ * Copyright (C) 2014 INRIA Sophia Antipolis-Mediterranee (France)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -24,9 +21,8 @@
*
*/
-
-#ifndef BASIC_GEOMETRY_H_
-#define BASIC_GEOMETRY_H_
+#ifndef POINT_H_
+#define POINT_H_
#include <cmath>
#include <vector>
@@ -34,143 +30,141 @@
#include <cstddef>
#include <initializer_list>
-class Point_d{
-public:
- Point_d(size_t dim=3):coords_(dim,0){}
- Point_d(const Point_d& other):coords_(other.coords_){}
- Point_d(const std::initializer_list<double>& list):coords_(list) {
- }
- template<typename CoordsIt>
- Point_d(CoordsIt begin,CoordsIt end):coords_(begin,end){}
-
- size_t dimension() const{
- return coords_.size();
- }
-
- double x() const{
- return coords_[0];
- }
-
- double y() const{
- return coords_[1];
- }
-
- double z() const{
- return coords_[2];
- }
-
- double& x(){
- return coords_[0];
- }
-
- double& y(){
- return coords_[1];
- }
-
- double& z(){
- return coords_[2];
- }
-
- std::vector<double>::const_iterator begin() const{
- return coords_.begin();
- }
-
- std::vector<double>::const_iterator end() const{
- return coords_.end();
- }
-
- double& operator[](unsigned i){
- return coords_[i];
- }
- const double& operator[](unsigned i) const{
- return coords_[i];
- }
-
- double squared_norm() const{
- double res = 0;
- for(auto x : coords_)
- res+= x*x;
- return res;
- }
-
- friend double squared_dist(const Point_d& p1,const Point_d& p2){
- assert(p1.dimension()==p2.dimension());
- double res = 0;
- for(unsigned i = 0; i < p1.coords_.size(); ++i)
- res+= (p1[i]-p2[i])*(p1[i]-p2[i]);
- return res;
- }
-
- /**
- * dot product
- */
- double operator*(const Point_d& other) const{
- assert(dimension()==other.dimension());
- double res = 0;
- for(unsigned i = 0; i < coords_.size(); ++i)
- res+= coords_[i]*other[i];
- return res;
- }
-
- /**
- * only if points have dimension 3
- */
- Point_d cross_product(const Point_d& other){
- assert(dimension()==3 && other.dimension()==3);
- Point_d res(3);
- res[0] = (*this)[1] * other[2] - (*this)[2] * other[1];
- res[1] = (*this)[2] * other[0] - (*this)[0] * other[2];
- res[2] = (*this)[0] * other[1] - (*this)[1] * other[0];
- return res;
- }
-
- Point_d operator+(const Point_d& other) const{
- assert(dimension()==other.dimension());
- Point_d res(dimension());
- for(unsigned i = 0; i < coords_.size(); ++i)
- res[i] = (*this)[i] + other[i];
- return res;
- }
-
- Point_d operator*(double lambda) const{
- Point_d res(dimension());
- for(unsigned i = 0; i < coords_.size(); ++i)
- res[i] = (*this)[i] * lambda;
- return res;
- }
-
- Point_d operator/(double lambda) const{
- Point_d res(dimension());
- for(unsigned i = 0; i < coords_.size(); ++i)
- res[i] = (*this)[i] / lambda;
- return res;
- }
-
- Point_d operator-(const Point_d& other) const{
- assert(dimension()==other.dimension());
- Point_d res(dimension());
- for(unsigned i = 0; i < coords_.size(); ++i)
- res[i] = (*this)[i] - other[i];
- return res;
- }
-
- friend Point_d unit_normal(const Point_d& p1,const Point_d& p2,const Point_d& p3){
- assert(p1.dimension()==3);
- assert(p2.dimension()==3);
- assert(p3.dimension()==3);
- Point_d p1p2 = p2 - p1;
- Point_d p1p3 = p3 - p1;
- Point_d res(p1p2.cross_product(p1p3));
- return res / std::sqrt(res.squared_norm());
- }
-
-
-private:
- std::vector<double> coords_;
+class Point_d {
+ public:
+ Point_d(size_t dim = 3) : coords_(dim, 0) { }
+
+ Point_d(const Point_d& other) : coords_(other.coords_) { }
+
+ Point_d(const std::initializer_list<double>& list) : coords_(list) { }
+
+ template<typename CoordsIt>
+ Point_d(CoordsIt begin, CoordsIt end) : coords_(begin, end) { }
+
+ size_t dimension() const {
+ return coords_.size();
+ }
+
+ double x() const {
+ return coords_[0];
+ }
+
+ double y() const {
+ return coords_[1];
+ }
+
+ double z() const {
+ return coords_[2];
+ }
+
+ double& x() {
+ return coords_[0];
+ }
+
+ double& y() {
+ return coords_[1];
+ }
+
+ double& z() {
+ return coords_[2];
+ }
+
+ std::vector<double>::const_iterator begin() const {
+ return coords_.begin();
+ }
+
+ std::vector<double>::const_iterator end() const {
+ return coords_.end();
+ }
+
+ double& operator[](unsigned i) {
+ return coords_[i];
+ }
+
+ const double& operator[](unsigned i) const {
+ return coords_[i];
+ }
+
+ double squared_norm() const {
+ double res = 0;
+ for (auto x : coords_)
+ res += x * x;
+ return res;
+ }
+
+ friend double squared_dist(const Point_d& p1, const Point_d& p2) {
+ assert(p1.dimension() == p2.dimension());
+ double res = 0;
+ for (unsigned i = 0; i < p1.coords_.size(); ++i)
+ res += (p1[i] - p2[i])*(p1[i] - p2[i]);
+ return res;
+ }
+
+ /**
+ * dot product
+ */
+ double operator*(const Point_d& other) const {
+ assert(dimension() == other.dimension());
+ double res = 0;
+ for (unsigned i = 0; i < coords_.size(); ++i)
+ res += coords_[i] * other[i];
+ return res;
+ }
+
+ /**
+ * only if points have dimension 3
+ */
+ Point_d cross_product(const Point_d& other) {
+ assert(dimension() == 3 && other.dimension() == 3);
+ Point_d res(3);
+ res[0] = (*this)[1] * other[2] - (*this)[2] * other[1];
+ res[1] = (*this)[2] * other[0] - (*this)[0] * other[2];
+ res[2] = (*this)[0] * other[1] - (*this)[1] * other[0];
+ return res;
+ }
+
+ Point_d operator+(const Point_d& other) const {
+ assert(dimension() == other.dimension());
+ Point_d res(dimension());
+ for (unsigned i = 0; i < coords_.size(); ++i)
+ res[i] = (*this)[i] + other[i];
+ return res;
+ }
+
+ Point_d operator*(double lambda) const {
+ Point_d res(dimension());
+ for (unsigned i = 0; i < coords_.size(); ++i)
+ res[i] = (*this)[i] * lambda;
+ return res;
+ }
+
+ Point_d operator/(double lambda) const {
+ Point_d res(dimension());
+ for (unsigned i = 0; i < coords_.size(); ++i)
+ res[i] = (*this)[i] / lambda;
+ return res;
+ }
+
+ Point_d operator-(const Point_d& other) const {
+ assert(dimension() == other.dimension());
+ Point_d res(dimension());
+ for (unsigned i = 0; i < coords_.size(); ++i)
+ res[i] = (*this)[i] - other[i];
+ return res;
+ }
+
+ friend Point_d unit_normal(const Point_d& p1, const Point_d& p2, const Point_d& p3) {
+ assert(p1.dimension() == 3);
+ assert(p2.dimension() == 3);
+ assert(p3.dimension() == 3);
+ Point_d p1p2 = p2 - p1;
+ Point_d p1p3 = p3 - p1;
+ Point_d res(p1p2.cross_product(p1p3));
+ return res / std::sqrt(res.squared_norm());
+ }
+
+ private:
+ std::vector<double> coords_;
};
-
-
-
-
-#endif /* BASIC_GEOMETRY_H_ */
+#endif // POINT_H_
diff --git a/src/common/include/gudhi/Simple_object_pool.h b/src/common/include/gudhi/Simple_object_pool.h
index fffcb2ef..fb9c8e23 100644
--- a/src/common/include/gudhi/Simple_object_pool.h
+++ b/src/common/include/gudhi/Simple_object_pool.h
@@ -20,45 +20,62 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#ifndef SIMPLE_OBJECT_POOL_H_
+#define SIMPLE_OBJECT_POOL_H_
+
#include <boost/pool/pool.hpp>
#include <utility>
namespace Gudhi {
- /** \private
- * This is a simpler version of boost::object_pool, that requires
- * that users explicitly destroy all objects. This lets the
- * performance scale much better, see
- * https://svn.boost.org/trac/boost/ticket/3789 .
- */
+
+/** \private
+ * This is a simpler version of boost::object_pool, that requires
+ * that users explicitly destroy all objects. This lets the
+ * performance scale much better, see
+ * https://svn.boost.org/trac/boost/ticket/3789 .
+ */
template <class T>
-class Simple_object_pool : protected boost::pool<boost::default_user_allocator_malloc_free>
-{
- protected:
+class Simple_object_pool : protected boost::pool<boost::default_user_allocator_malloc_free> {
+ protected:
typedef boost::pool<boost::default_user_allocator_malloc_free> Base;
typedef T* pointer;
- Base& base(){return *this;}
- Base const& base()const{return *this;}
- public:
+
+ Base& base() {
+ return *this;
+ }
+
+ Base const& base()const {
+ return *this;
+ }
+
+ public:
typedef T element_type;
typedef boost::default_user_allocator_malloc_free user_allocator;
typedef typename Base::size_type size_type;
typedef typename Base::difference_type difference_type;
+
template<class...U>
- Simple_object_pool(U&&...u) : Base(sizeof(T), std::forward<U>(u)...) {}
+ Simple_object_pool(U&&...u) : Base(sizeof (T), std::forward<U>(u)...) { }
+
template<class...U>
- pointer construct(U&&...u){
- void* p=base().malloc BOOST_PREVENT_MACRO_SUBSTITUTION();
+ pointer construct(U&&...u) {
+ void* p = base().malloc BOOST_PREVENT_MACRO_SUBSTITUTION();
assert(p);
- try { new(p) T(std::forward<U>(u)...); }
- catch(...) {
+ try {
+ new(p) T(std::forward<U>(u)...);
+ } catch (...) {
base().free BOOST_PREVENT_MACRO_SUBSTITUTION(p);
throw;
}
- return static_cast<pointer>(p);
+ return static_cast<pointer> (p);
}
- void destroy(pointer p){
+
+ void destroy(pointer p) {
p->~T();
base().free BOOST_PREVENT_MACRO_SUBSTITUTION(p);
}
};
-}
+
+} // namespace Gudhi
+
+#endif // SIMPLE_OBJECT_POOL_H_
diff --git a/src/common/include/gudhi/Test.h b/src/common/include/gudhi/Test.h
index 18b7ca82..66f7bfd3 100644
--- a/src/common/include/gudhi/Test.h
+++ b/src/common/include/gudhi/Test.h
@@ -1,5 +1,28 @@
-#ifndef __TEST_H
-#define __TEST_H
+/* This file is part of the Gudhi Library. The Gudhi library
+ * (Geometric Understanding in Higher Dimensions) is a generic C++
+ * library for computational topology.
+ *
+ * Author(s): David Salinas
+ *
+ * Copyright (C) 2014 INRIA Sophia Antipolis-Mediterranee (France)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef TEST_H
+#define TEST_H
#include <list>
#include <string>
@@ -8,78 +31,75 @@
#include <iostream>
-#define TEST(a) std::cout << "TEST: " << (a)<<std::endl
-#define TESTMSG(a,b) std::cout << "TEST: " << a<<b<<std::endl
-#define TESTVALUE(a) std::cout << "TEST: " << #a << ": " << a<<std::endl
-
+#define TEST(a) std::cout << "TEST: " << (a) << std::endl
+#define TESTMSG(a, b) std::cout << "TEST: " << a << b << std::endl
+#define TESTVALUE(a) std::cout << "TEST: " << #a << ": " << a << std::endl
/**
* Class to perform test
*/
-class Test
-{
-private :
- std::string name;
- bool (*test)();
-
- std::string separation() const{
- return "+++++++++++++++++++++++++++++++++++++++++++++++++\n";
- }
-
- std::string print_between_plus(std::string& s) const{
- std::stringstream res;
- res << "+++++++++++++++++"<<s<<"+++++++++++++++++\n";
- return res.str();
- }
-
-
-public:
- Test(std::string name_,bool (*test_)()){
- name=name_;
- test =test_;
- }
-
- bool run(){
- std::cout << print_between_plus(name);
- return test();
- }
- std::string getName(){
- return name;
- }
+class Test {
+ private:
+ std::string name;
+ bool (*test)();
+
+ std::string separation() const {
+ return "+++++++++++++++++++++++++++++++++++++++++++++++++\n";
+ }
+
+ std::string print_between_plus(std::string& s) const {
+ std::stringstream res;
+ res << "+++++++++++++++++" << s << "+++++++++++++++++\n";
+ return res.str();
+ }
+
+ public:
+ Test(std::string name_, bool (*test_)()) {
+ name = name_;
+ test = test_;
+ }
+
+ bool run() {
+ std::cout << print_between_plus(name);
+ return test();
+ }
+
+ std::string getName() {
+ return name;
+ }
};
-
-class Tests
-{
-private:
- std::list<Test> tests;
-
-public:
- void add(std::string name_,bool (*test_)()){
- Test test(name_,test_);
- tests.push_back(test);
- }
- bool run(){
- bool tests_succesful(true);
- std::vector<bool> res;
- for (Test test : tests){
- res.push_back(test.run());
- }
- std::cout << "\n\n results of tests : "<<std::endl;
- int i=0;
- for (Test t : tests){
- std::cout << "Test "<<i<< " \""<<t.getName()<<"\" --> ";
- if (res[i++]) std::cout << "OK"<<std::endl;
- else {
- std::cout << "Fail"<<std::endl;
- tests_succesful = false;
- break;
- }
- }
- return tests_succesful;
-
- }
+class Tests {
+ private:
+ std::list<Test> tests;
+
+ public:
+ void add(std::string name_, bool (*test_)()) {
+ Test test(name_, test_);
+ tests.push_back(test);
+ }
+
+ bool run() {
+ bool tests_succesful(true);
+ std::vector<bool> res;
+ for (Test test : tests) {
+ res.push_back(test.run());
+ }
+ std::cout << "\n\n results of tests : " << std::endl;
+ int i = 0;
+ for (Test t : tests) {
+ std::cout << "Test " << i << " \"" << t.getName() << "\" --> ";
+ if (res[i++]) {
+ std::cout << "OK" << std::endl;
+ } else {
+ std::cout << "Fail" << std::endl;
+ tests_succesful = false;
+ break;
+ }
+ }
+ return tests_succesful;
+ }
};
-#endif
+#endif // TEST_H
diff --git a/src/common/include/gudhi/Utils.h b/src/common/include/gudhi/Utils.h
index 7678685c..43916f11 100644
--- a/src/common/include/gudhi/Utils.h
+++ b/src/common/include/gudhi/Utils.h
@@ -1,48 +1,46 @@
- /* This file is part of the Gudhi Library. The Gudhi library
- * (Geometric Understanding in Higher Dimensions) is a generic C++
- * library for computational topology.
- *
- * Author(s): David Salinas
- *
- * Copyright (C) 2014 INRIA Sophia Antipolis-Mediterranee (France)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-#ifndef GUDHI_UTILS_H_
-#define GUDHI_UTILS_H_
+/* This file is part of the Gudhi Library. The Gudhi library
+ * (Geometric Understanding in Higher Dimensions) is a generic C++
+ * library for computational topology.
+ *
+ * Author(s): David Salinas
+ *
+ * Copyright (C) 2014 INRIA Sophia Antipolis-Mediterranee (France)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef UTILS_H_
+#define UTILS_H_
-#define PRINT(a) std::cerr << #a << ": " << (a) << " (DISP)"<<std::endl
+#define PRINT(a) std::cerr << #a << ": " << (a) << " (DISP)" << std::endl
-//#define DBG_VERBOSE
+// #define DBG_VERBOSE
#ifdef DBG_VERBOSE
-#define DBG(a) std::cerr << "DBG: " << (a)<<std::endl
-#define DBGMSG(a,b) std::cerr << "DBG: " << a<<b<<std::endl
-#define DBGVALUE(a) std::cerr << "DBG: " << #a << ": " << a<<std::endl
-#define DBGCONT(a) std::cerr << "DBG: container "<< #a<<" -> "; for(auto x:a) std::cerr<< x << ","; std::cerr<<std::endl
+#define DBG(a) std::cerr << "DBG: " << (a) << std::endl
+#define DBGMSG(a, b) std::cerr << "DBG: " << a << b << std::endl
+#define DBGVALUE(a) std::cerr << "DBG: " << #a << ": " << a << std::endl
+#define DBGCONT(a) std::cerr << "DBG: container " << #a << " -> "; for (auto x : a) std::cerr << x << ","; std::cerr <<
+std::endl
#else
-//#define DBG(a) a
-//#define DBGMSG(a,b) b
-//#define DBGVALUE(a) a
-//#define DBGCONT(a) a
+// #define DBG(a) a
+// #define DBGMSG(a,b) b
+// #define DBGVALUE(a) a
+// #define DBGCONT(a) a
#define DBG(a)
-#define DBGMSG(a,b)
+#define DBGMSG(a, b)
#define DBGVALUE(a)
#define DBGCONT(a)
#endif
-
-
-
-#endif /* UTILS_H_ */
+#endif // UTILS_H_
diff --git a/src/common/include/gudhi/distance_functions.h b/src/common/include/gudhi/distance_functions.h
index 7a2ab035..de05be0c 100644
--- a/src/common/include/gudhi/distance_functions.h
+++ b/src/common/include/gudhi/distance_functions.h
@@ -1,37 +1,41 @@
- /* This file is part of the Gudhi Library. The Gudhi library
- * (Geometric Understanding in Higher Dimensions) is a generic C++
- * library for computational topology.
- *
- * Author(s): Clément Maria
- *
- * Copyright (C) 2014 INRIA Sophia Antipolis-Méditerranée (France)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
+/* This file is part of the Gudhi Library. The Gudhi library
+ * (Geometric Understanding in Higher Dimensions) is a generic C++
+ * library for computational topology.
+ *
+ * Author(s): 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 <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef DISTANCE_FUNCTION_H_
+#define DISTANCE_FUNCTION_H_
/* Compute the Euclidean distance between two Points given
* by a range of coordinates. The points are assumed to have
* the same dimension. */
template< typename Point >
-double euclidean_distance( Point &p1, Point &p2)
-{
+double euclidean_distance(Point &p1, Point &p2) {
double dist = 0.;
- auto it1 = p1.begin(); auto it2 = p2.begin();
- for(; it1 != p1.end(); ++it1, ++it2)
- {
- double tmp = *it1 - *it2;
- dist += tmp*tmp;
- }
- return sqrt(dist);
+ auto it1 = p1.begin();
+ auto it2 = p2.begin();
+ for (; it1 != p1.end(); ++it1, ++it2) {
+ double tmp = *it1 - *it2;
+ dist += tmp*tmp;
+ }
+ return sqrt(dist);
}
+
+#endif // DISTANCE_FUNCTION_H_
diff --git a/src/common/include/gudhi/graph_simplicial_complex.h b/src/common/include/gudhi/graph_simplicial_complex.h
index 1ad9dabd..25d92be5 100644
--- a/src/common/include/gudhi/graph_simplicial_complex.h
+++ b/src/common/include/gudhi/graph_simplicial_complex.h
@@ -1,27 +1,27 @@
- /* This file is part of the Gudhi Library. The Gudhi library
- * (Geometric Understanding in Higher Dimensions) is a generic C++
- * library for computational topology.
- *
- * Author(s): Clément Maria
- *
- * Copyright (C) 2014 INRIA Sophia Antipolis-Méditerranée (France)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
+/* This file is part of the Gudhi Library. The Gudhi library
+ * (Geometric Understanding in Higher Dimensions) is a generic C++
+ * library for computational topology.
+ *
+ * Author(s): 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 <http://www.gnu.org/licenses/>.
+ */
-#ifndef GUDHI_GRAPH_SIMPLICIAL_COMPLEX_FILTRATION_TAG_H
-#define GUDHI_GRAPH_SIMPLICIAL_COMPLEX_FILTRATION_TAG_H
+#ifndef GRAPH_SIMPLICIAL_COMPLEX_H
+#define GRAPH_SIMPLICIAL_COMPLEX_H
#include <boost/graph/adjacency_list.hpp>
@@ -29,68 +29,67 @@
struct edge_filtration_t {
typedef boost::edge_property_tag kind;
};
+
/* Vertex tag for Boost PropertyGraph. */
struct vertex_filtration_t {
typedef boost::vertex_property_tag kind;
};
-typedef int Vertex_handle;
-typedef double Filtration_value;
+typedef int Vertex_handle;
+typedef double Filtration_value;
typedef boost::adjacency_list < boost::vecS, boost::vecS, boost::undirectedS
- , boost::property < vertex_filtration_t, Filtration_value >
- , boost::property < edge_filtration_t, Filtration_value >
- > Graph_t;
+, boost::property < vertex_filtration_t, Filtration_value >
+, boost::property < edge_filtration_t, Filtration_value >
+> Graph_t;
typedef std::pair< Vertex_handle, Vertex_handle > Edge_t;
/** \brief Output the proximity graph of the points.
- *
- * If points contains n elements, the proximity graph is the graph
- * with n vertices, and an edge [u,v] iff the distance function between
- * points u and v is smaller than threshold.
- *
- * The type PointCloud furnishes .begin() and .end() methods, that return
- * iterators with value_type Point.
- */
+ *
+ * If points contains n elements, the proximity graph is the graph
+ * with n vertices, and an edge [u,v] iff the distance function between
+ * points u and v is smaller than threshold.
+ *
+ * The type PointCloud furnishes .begin() and .end() methods, that return
+ * iterators with value_type Point.
+ */
template< typename PointCloud
- , typename Point >
-Graph_t compute_proximity_graph( PointCloud &points
- , Filtration_value threshold
- , Filtration_value distance(Point p1, Point p2) )
-{
- std::vector< Edge_t > edges;
- std::vector< Filtration_value > edges_fil;
+, typename Point >
+Graph_t compute_proximity_graph(PointCloud &points
+ , Filtration_value threshold
+ , Filtration_value distance(Point p1, Point p2)) {
+ std::vector< Edge_t > edges;
+ std::vector< Filtration_value > edges_fil;
std::map< Vertex_handle, Filtration_value > vertices;
Vertex_handle idx_u, idx_v;
Filtration_value fil;
idx_u = 0;
- for(auto it_u = points.begin(); it_u != points.end(); ++it_u)
- {
- idx_v = idx_u+1;
- for(auto it_v = it_u+1; it_v != points.end(); ++it_v, ++idx_v)
- {
- fil = distance(*it_u,*it_v);
- if(fil <= threshold) {
- edges.emplace_back(idx_u,idx_v);
+ for (auto it_u = points.begin(); it_u != points.end(); ++it_u) {
+ idx_v = idx_u + 1;
+ for (auto it_v = it_u + 1; it_v != points.end(); ++it_v, ++idx_v) {
+ fil = distance(*it_u, *it_v);
+ if (fil <= threshold) {
+ edges.emplace_back(idx_u, idx_v);
edges_fil.push_back(fil);
}
}
++idx_u;
}
- Graph_t skel_graph( edges.begin()
- , edges.end()
- , edges_fil.begin()
- , idx_u); //number of points labeled from 0 to idx_u-1
+ Graph_t skel_graph(edges.begin()
+ , edges.end()
+ , edges_fil.begin()
+ , idx_u); //number of points labeled from 0 to idx_u-1
- auto vertex_prop = boost::get(vertex_filtration_t(),skel_graph);
+ auto vertex_prop = boost::get(vertex_filtration_t(), skel_graph);
boost::graph_traits<Graph_t>::vertex_iterator vi, vi_end;
- for ( std::tie(vi, vi_end) = boost::vertices(skel_graph);
- vi != vi_end; ++vi )
- { boost::put(vertex_prop, *vi, 0.); }
-
+ for (std::tie(vi, vi_end) = boost::vertices(skel_graph);
+ vi != vi_end; ++vi) {
+ boost::put(vertex_prop, *vi, 0.);
+ }
+
return skel_graph;
}
-#endif // GUDHI_GRAPH_SIMPLICIAL_COMPLEX_FILTRATION_TAG_H
+#endif // GRAPH_SIMPLICIAL_COMPLEX_H
diff --git a/src/common/include/gudhi/reader_utils.h b/src/common/include/gudhi/reader_utils.h
index ab12c268..99426dac 100644
--- a/src/common/include/gudhi/reader_utils.h
+++ b/src/common/include/gudhi/reader_utils.h
@@ -1,27 +1,27 @@
- /* This file is part of the Gudhi Library. The Gudhi library
- * (Geometric Understanding in Higher Dimensions) is a generic C++
- * library for computational topology.
- *
- * Author(s): Clément Maria
- *
- * Copyright (C) 2014 INRIA Sophia Antipolis-Méditerranée (France)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
+/* This file is part of the Gudhi Library. The Gudhi library
+ * (Geometric Understanding in Higher Dimensions) is a generic C++
+ * library for computational topology.
+ *
+ * Author(s): 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 <http://www.gnu.org/licenses/>.
+ */
-#ifndef GUDHI_READER_UTILS_H
-#define GUDHI_READER_UTILS_H
+#ifndef READER_UTILS_H
+#define READER_UTILS_H
#include <iostream>
#include <fstream>
@@ -37,22 +37,21 @@
* X21 X22 ... X2d
* etc
*/
-inline void
-read_points ( std::string file_name
- , std::vector< std::vector< double > > & points)
-{
- std::ifstream in_file (file_name.c_str(),std::ios::in);
- if(!in_file.is_open()) {
+inline void read_points(std::string file_name, std::vector< std::vector< double > > & points) {
+ std::ifstream in_file(file_name.c_str(), std::ios::in);
+ if (!in_file.is_open()) {
std::cerr << "Unable to open file " << file_name << std::endl;
- return;}
+ return;
+ }
std::string line;
double x;
- while( getline ( in_file , line ) )
- {
+ while (getline(in_file, line)) {
std::vector< double > point;
- std::istringstream iss( line );
- while(iss >> x) { point.push_back(x); }
+ std::istringstream iss(line);
+ while (iss >> x) {
+ point.push_back(x);
+ }
points.push_back(point);
}
in_file.close();
@@ -70,53 +69,64 @@ read_points ( std::string file_name
* Every simplex must appear exactly once.
* Simplices of dimension more than 1 are ignored.
*/
-inline Graph_t
-read_graph ( std::string file_name )
-{
- std::ifstream in_ (file_name.c_str(),std::ios::in);
- if(!in_.is_open()) { std::cerr << "Unable to open file " << file_name << std::endl; }
+inline Graph_t read_graph(std::string file_name) {
+ std::ifstream in_(file_name.c_str(), std::ios::in);
+ if (!in_.is_open()) {
+ std::cerr << "Unable to open file " << file_name << std::endl;
+ }
- std::vector< Edge_t > edges;
- std::vector< Filtration_value > edges_fil;
+ std::vector< Edge_t > edges;
+ std::vector< Filtration_value > edges_fil;
std::map< Vertex_handle, Filtration_value > vertices;
-
- std::string line;
- int dim;
- Vertex_handle u,v,max_h = -1;
+
+ std::string line;
+ int dim;
+ Vertex_handle u, v, max_h = -1;
Filtration_value fil;
- while( getline ( in_ , line ) )
- {
- std::istringstream iss( line );
- while(iss >> dim) {
- switch ( dim ) {
- case 0 : {
- iss >> u; iss >> fil;
+ while (getline(in_, line)) {
+ std::istringstream iss(line);
+ while (iss >> dim) {
+ switch (dim) {
+ case 0:
+ {
+ iss >> u;
+ iss >> fil;
vertices[u] = fil;
- if(max_h < u) { max_h = u; }
+ if (max_h < u) {
+ max_h = u;
+ }
break;
}
- case 1 : {
- iss >> u; iss >> v; iss >> fil;
- edges.push_back(Edge_t(u,v));
+ case 1:
+ {
+ iss >> u;
+ iss >> v;
+ iss >> fil;
+ edges.push_back(Edge_t(u, v));
edges_fil.push_back(fil);
break;
}
- default: {break;}
- }
+ default:
+ {
+ break;
+ }
+ }
}
}
in_.close();
- if((size_t)(max_h+1) != vertices.size())
- { std::cerr << "Error: vertices must be labeled from 0 to n-1 \n"; }
+ if ((size_t) (max_h + 1) != vertices.size()) {
+ std::cerr << "Error: vertices must be labeled from 0 to n-1 \n";
+ }
- Graph_t skel_graph(edges.begin(),edges.end(),edges_fil.begin(),vertices.size());
- auto vertex_prop = boost::get(vertex_filtration_t(),skel_graph);
+ Graph_t skel_graph(edges.begin(), edges.end(), edges_fil.begin(), vertices.size());
+ auto vertex_prop = boost::get(vertex_filtration_t(), skel_graph);
boost::graph_traits<Graph_t>::vertex_iterator vi, vi_end;
auto v_it = vertices.begin();
- for (std::tie(vi, vi_end) = boost::vertices(skel_graph); vi != vi_end; ++vi,++v_it)
- { boost::put(vertex_prop, *vi, v_it->second); }
+ for (std::tie(vi, vi_end) = boost::vertices(skel_graph); vi != vi_end; ++vi, ++v_it) {
+ boost::put(vertex_prop, *vi, v_it->second);
+ }
return skel_graph;
}
@@ -133,17 +143,15 @@ read_graph ( std::string file_name )
* Every simplex must appear exactly once.
* Simplices of dimension more than 1 are ignored.
*/
-template< typename Vertex_handle
- , typename Filtration_value >
-bool read_simplex ( std::istream & in_
- , std::vector< Vertex_handle > & simplex
- , Filtration_value & fil )
-{
- int dim=0;
- if(!(in_ >> dim)) return false;
+template< typename Vertex_handle, typename Filtration_value >
+bool read_simplex(std::istream & in_, std::vector< Vertex_handle > & simplex, Filtration_value & fil) {
+ int dim = 0;
+ if (!(in_ >> dim)) return false;
Vertex_handle v;
- for(int i=0; i<dim+1; ++i)
- { in_ >> v; simplex.push_back(v); }
+ for (int i = 0; i < dim + 1; ++i) {
+ in_ >> v;
+ simplex.push_back(v);
+ }
in_ >> fil;
in_.ignore((std::numeric_limits<std::streamsize>::max)(), '\n'); // ignore until the carriage return
return true;
@@ -162,20 +170,21 @@ bool read_simplex ( std::istream & in_
* Dimi ki1 ki2 ... kiDimi Fili means that the ith simplex in the
* filtration has dimension Dimi, filtration value fil1 and simplices with
* key ki1 ... kiDimi in its boundary.*/
-template< typename Simplex_key
- , typename Filtration_value >
-bool read_hasse_simplex ( std::istream & in_
- , std::vector< Simplex_key > & boundary
- , Filtration_value & fil )
-{
+template< typename Simplex_key, typename Filtration_value >
+bool read_hasse_simplex(std::istream & in_, std::vector< Simplex_key > & boundary, Filtration_value & fil) {
int dim;
- if(!(in_ >> dim)) return false;
- if(dim == 0) {in_ >> fil; return true;}
+ if (!(in_ >> dim)) return false;
+ if (dim == 0) {
+ in_ >> fil;
+ return true;
+ }
Simplex_key key;
- for(int i=0; i<dim+1; ++i)
- { in_ >> key; boundary.push_back(key); }
+ for (int i = 0; i < dim + 1; ++i) {
+ in_ >> key;
+ boundary.push_back(key);
+ }
in_ >> fil;
return true;
}
-#endif // GUDHI_READER_UTILS_H
+#endif // READER_UTILS_H