diff options
author | vrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2017-12-14 14:14:31 +0000 |
---|---|---|
committer | vrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2017-12-14 14:14:31 +0000 |
commit | a07ddde0c7a12aa1ad1690d87ba105bb17356526 (patch) | |
tree | 9460b7edc36a83902cecef2a1e201a8db56f329d /src/Alpha_complex | |
parent | 51d5cdbb5e0d2ac632611811435eef798e496ac6 (diff) | |
parent | b3060b07620833d36519379acefd98c490bc4de1 (diff) |
Merge of branch misc-glisse
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@3074 636b058d-ea47-450e-bf9e-a15bfbe3eedb
Former-commit-id: d0842416dbf4ee1ff25a7421841efe8f097e5379
Diffstat (limited to 'src/Alpha_complex')
7 files changed, 43 insertions, 140 deletions
diff --git a/src/Alpha_complex/include/gudhi/Alpha_complex.h b/src/Alpha_complex/include/gudhi/Alpha_complex.h index 5f7d7622..63c6675c 100644 --- a/src/Alpha_complex/include/gudhi/Alpha_complex.h +++ b/src/Alpha_complex/include/gudhi/Alpha_complex.h @@ -175,7 +175,7 @@ class Alpha_complex { * * @return The number of vertices. */ - const std::size_t number_of_vertices() const { + std::size_t number_of_vertices() const { return vertex_handle_to_iterator_.size(); } diff --git a/src/Alpha_complex/utilities/alpha_complex_3d_helper.h b/src/Alpha_complex/utilities/alpha_complex_3d_helper.h index 6b3b7d5d..3747923f 100644 --- a/src/Alpha_complex/utilities/alpha_complex_3d_helper.h +++ b/src/Alpha_complex/utilities/alpha_complex_3d_helper.h @@ -52,13 +52,11 @@ Vertex_list from_facet(const Facet& fct) { template <class Vertex_list, class Edge_3> Vertex_list from_edge(const Edge_3& edg) { Vertex_list the_list; - for (auto i = 0; i < 4; i++) { - if ((edg.second == i) || (edg.third == i)) { + for (auto i : { edg.second, edg.third }) { #ifdef DEBUG_TRACES - std::cout << "from edge[" << i << "]=" << edg.first->vertex(i)->point() << std::endl; + std::cout << "from edge[" << i << "]=" << edg.first->vertex(i)->point() << std::endl; #endif // DEBUG_TRACES - the_list.push_back(edg.first->vertex(i)); - } + the_list.push_back(edg.first->vertex(i)); } return the_list; } diff --git a/src/Alpha_complex/utilities/alpha_complex_3d_persistence.cpp b/src/Alpha_complex/utilities/alpha_complex_3d_persistence.cpp index 0a021a0f..f4a14ae3 100644 --- a/src/Alpha_complex/utilities/alpha_complex_3d_persistence.cpp +++ b/src/Alpha_complex/utilities/alpha_complex_3d_persistence.cpp @@ -22,6 +22,7 @@ #include <boost/program_options.hpp> #include <boost/variant.hpp> +#include <boost/container/static_vector.hpp> #include <gudhi/Simplex_tree.h> #include <gudhi/Persistent_cohomology.h> @@ -38,7 +39,6 @@ #include <tuple> #include <map> #include <utility> -#include <list> #include <vector> #include <cstdlib> @@ -66,14 +66,13 @@ using Cell_handle = Alpha_shape_3::Cell_handle; using Facet = Alpha_shape_3::Facet; using Edge_3 = Alpha_shape_3::Edge; using Vertex_handle = Alpha_shape_3::Vertex_handle; -using Vertex_list = std::list<Alpha_shape_3::Vertex_handle>; +using Vertex_list = boost::container::static_vector<Alpha_shape_3::Vertex_handle, 4>; // gudhi type definition using ST = Gudhi::Simplex_tree<Gudhi::Simplex_tree_options_fast_persistence>; using Filtration_value = ST::Filtration_value; using Simplex_tree_vertex = ST::Vertex_handle; using Alpha_shape_simplex_tree_map = std::map<Alpha_shape_3::Vertex_handle, Simplex_tree_vertex>; -using Alpha_shape_simplex_tree_pair = std::pair<Alpha_shape_3::Vertex_handle, Simplex_tree_vertex>; using Simplex_tree_vector_vertex = std::vector<Simplex_tree_vertex>; using Persistent_cohomology = Gudhi::persistent_cohomology::Persistent_cohomology<ST, Gudhi::persistent_cohomology::Field_Zp>; @@ -97,7 +96,7 @@ int main(int argc, char **argv) { exit(-1); } - // Retrieve the triangulation + // Retrieve the points std::vector<Point_3> lp = off_reader.get_point_cloud(); // alpha shape construction from points. CGAL has a strange behavior in REGULARIZED mode. @@ -128,37 +127,23 @@ int main(int argc, char **argv) { ST 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(); - int dim_max = 0; - Filtration_value filtration_max = 0.0; 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<Vertex_list, Cell_handle>(*cell); count_cells++; - if (dim_max < 3) { - // Cell is of dim 3 - dim_max = 3; - } } else if (const Facet* facet = CGAL::object_cast<Facet>(&object_iterator)) { vertex_list = from_facet<Vertex_list, Facet>(*facet); count_facets++; - if (dim_max < 2) { - // Facet is of dim 2 - dim_max = 2; - } } else if (const Edge_3* edge = CGAL::object_cast<Edge_3>(&object_iterator)) { vertex_list = from_edge<Vertex_list, Edge_3>(*edge); count_edges++; - if (dim_max < 1) { - // Edge_3 is of dim 1 - dim_max = 1; - } } else if (const Vertex_handle* vertex = CGAL::object_cast<Vertex_handle>(&object_iterator)) { count_vertices++; vertex_list = from_vertex<Vertex_list, Vertex_handle>(*vertex); } // Construction of the vector of simplex_tree vertex from list of alpha_shapes vertex - Simplex_tree_vector_vertex the_simplex_tree; + Simplex_tree_vector_vertex the_simplex; 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()) { @@ -167,15 +152,15 @@ int main(int argc, char **argv) { #ifdef DEBUG_TRACES std::cout << "vertex [" << the_alpha_shape_vertex->point() << "] not found - insert " << 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)); + the_simplex.push_back(vertex); + map_cgal_simplex_tree.emplace(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); + the_simplex.push_back(vertex); } } // Construction of the simplex_tree @@ -183,14 +168,10 @@ int main(int argc, char **argv) { #ifdef DEBUG_TRACES std::cout << "filtration = " << filtr << std::endl; #endif // DEBUG_TRACES - if (filtr > filtration_max) { - filtration_max = filtr; - } - simplex_tree.insert_simplex(the_simplex_tree, filtr); - if (the_alpha_value_iterator != the_alpha_values.end()) - ++the_alpha_value_iterator; - else - std::cout << "This shall not happen" << std::endl; + simplex_tree.insert_simplex(the_simplex, filtr); + GUDHI_CHECK(the_alpha_value_iterator != the_alpha_values.end(), + "CGAL provided more simplices than values"); + ++the_alpha_value_iterator; } #ifdef DEBUG_TRACES diff --git a/src/Alpha_complex/utilities/exact_alpha_complex_3d_persistence.cpp b/src/Alpha_complex/utilities/exact_alpha_complex_3d_persistence.cpp index 9a266418..3b9a2ae0 100644 --- a/src/Alpha_complex/utilities/exact_alpha_complex_3d_persistence.cpp +++ b/src/Alpha_complex/utilities/exact_alpha_complex_3d_persistence.cpp @@ -38,7 +38,6 @@ #include <tuple> #include <map> #include <utility> -#include <list> #include <vector> #include <cstdlib> @@ -67,14 +66,13 @@ using Cell_handle = Alpha_shape_3::Cell_handle; using Facet = Alpha_shape_3::Facet; using Edge_3 = Alpha_shape_3::Edge; using Vertex_handle = Alpha_shape_3::Vertex_handle; -using Vertex_list = std::list<Vertex_handle>; +using Vertex_list = std::vector<Vertex_handle>; // gudhi type definition using ST = Gudhi::Simplex_tree<Gudhi::Simplex_tree_options_fast_persistence>; using Filtration_value = ST::Filtration_value; using Simplex_tree_vertex = ST::Vertex_handle; using Alpha_shape_simplex_tree_map = std::map<Alpha_shape_3::Vertex_handle, Simplex_tree_vertex>; -using Alpha_shape_simplex_tree_pair = std::pair<Alpha_shape_3::Vertex_handle, Simplex_tree_vertex>; using Simplex_tree_vector_vertex = std::vector<Simplex_tree_vertex>; using Persistent_cohomology = Gudhi::persistent_cohomology::Persistent_cohomology<ST, Gudhi::persistent_cohomology::Field_Zp>; @@ -98,7 +96,7 @@ int main(int argc, char **argv) { exit(-1); } - // Retrieve the triangulation + // Retrieve the points std::vector<Point_3> lp = off_reader.get_point_cloud(); // alpha shape construction from points. CGAL has a strange behavior in REGULARIZED mode. @@ -129,37 +127,23 @@ int main(int argc, char **argv) { ST 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(); - int dim_max = 0; - Filtration_value filtration_max = 0.0; 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<Vertex_list, Cell_handle>(*cell); count_cells++; - if (dim_max < 3) { - // Cell is of dim 3 - dim_max = 3; - } } else if (const Facet* facet = CGAL::object_cast<Facet>(&object_iterator)) { vertex_list = from_facet<Vertex_list, Facet>(*facet); count_facets++; - if (dim_max < 2) { - // Facet is of dim 2 - dim_max = 2; - } } else if (const Edge_3* edge = CGAL::object_cast<Edge_3>(&object_iterator)) { vertex_list = from_edge<Vertex_list, Edge_3>(*edge); count_edges++; - if (dim_max < 1) { - // Edge_3 is of dim 1 - dim_max = 1; - } } else if (const Vertex_handle* vertex = CGAL::object_cast<Vertex_handle>(&object_iterator)) { count_vertices++; vertex_list = from_vertex<Vertex_list, Vertex_handle>(*vertex); } // Construction of the vector of simplex_tree vertex from list of alpha_shapes vertex - Simplex_tree_vector_vertex the_simplex_tree; + Simplex_tree_vector_vertex the_simplex; 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()) { @@ -168,15 +152,15 @@ int main(int argc, char **argv) { #ifdef DEBUG_TRACES std::cout << "vertex [" << the_alpha_shape_vertex->point() << "] not found - insert " << 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)); + the_simplex.push_back(vertex); + map_cgal_simplex_tree.emplace(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); + the_simplex.push_back(vertex); } } // Construction of the simplex_tree @@ -185,10 +169,7 @@ int main(int argc, char **argv) { #ifdef DEBUG_TRACES std::cout << "filtration = " << filtr << std::endl; #endif // DEBUG_TRACES - if (filtr > filtration_max) { - filtration_max = filtr; - } - simplex_tree.insert_simplex(the_simplex_tree, filtr); + simplex_tree.insert_simplex(the_simplex, filtr); if (the_alpha_value_iterator != the_alpha_values.end()) ++the_alpha_value_iterator; else diff --git a/src/Alpha_complex/utilities/periodic_alpha_complex_3d_persistence.cpp b/src/Alpha_complex/utilities/periodic_alpha_complex_3d_persistence.cpp index 186a58f8..6993b0ad 100644 --- a/src/Alpha_complex/utilities/periodic_alpha_complex_3d_persistence.cpp +++ b/src/Alpha_complex/utilities/periodic_alpha_complex_3d_persistence.cpp @@ -39,7 +39,6 @@ #include <tuple> #include <map> #include <utility> -#include <list> #include <vector> #include <cstdlib> @@ -72,14 +71,13 @@ using Cell_handle = Alpha_shape_3::Cell_handle; using Facet = Alpha_shape_3::Facet; using Edge_3 = Alpha_shape_3::Edge; using Vertex_handle = Alpha_shape_3::Vertex_handle; -using Vertex_list = std::list<Alpha_shape_3::Vertex_handle>; +using Vertex_list = std::vector<Alpha_shape_3::Vertex_handle>; // gudhi type definition using ST = Gudhi::Simplex_tree<Gudhi::Simplex_tree_options_fast_persistence>; using Filtration_value = ST::Filtration_value; using Simplex_tree_vertex = ST::Vertex_handle; using Alpha_shape_simplex_tree_map = std::map<Alpha_shape_3::Vertex_handle, Simplex_tree_vertex>; -using Alpha_shape_simplex_tree_pair = std::pair<Alpha_shape_3::Vertex_handle, Simplex_tree_vertex>; using Simplex_tree_vector_vertex = std::vector<Simplex_tree_vertex>; using Persistent_cohomology = Gudhi::persistent_cohomology::Persistent_cohomology<ST, Gudhi::persistent_cohomology::Field_Zp>; @@ -115,7 +113,7 @@ int main(int argc, char **argv) { exit(-1); } - // Retrieve the triangulation + // Retrieve the points std::vector<Point_3> lp = off_reader.get_point_cloud(); // Define the periodic cube @@ -152,37 +150,23 @@ int main(int argc, char **argv) { ST 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(); - int dim_max = 0; - Filtration_value filtration_max = 0.0; 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<Vertex_list, Cell_handle>(*cell); count_cells++; - if (dim_max < 3) { - // Cell is of dim 3 - dim_max = 3; - } } else if (const Facet* facet = CGAL::object_cast<Facet>(&object_iterator)) { vertex_list = from_facet<Vertex_list, Facet>(*facet); count_facets++; - if (dim_max < 2) { - // Facet is of dim 2 - dim_max = 2; - } } else if (const Edge_3* edge = CGAL::object_cast<Edge_3>(&object_iterator)) { vertex_list = from_edge<Vertex_list, Edge_3>(*edge); count_edges++; - if (dim_max < 1) { - // Edge_3 is of dim 1 - dim_max = 1; - } } else if (const Vertex_handle* vertex = CGAL::object_cast<Vertex_handle>(&object_iterator)) { count_vertices++; vertex_list = from_vertex<Vertex_list, Vertex_handle>(*vertex); } // Construction of the vector of simplex_tree vertex from list of alpha_shapes vertex - Simplex_tree_vector_vertex the_simplex_tree; + Simplex_tree_vector_vertex the_simplex; 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()) { @@ -191,15 +175,15 @@ int main(int argc, char **argv) { #ifdef DEBUG_TRACES std::cout << "vertex [" << the_alpha_shape_vertex->point() << "] not found - insert " << 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)); + the_simplex.push_back(vertex); + map_cgal_simplex_tree.emplace(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); + the_simplex.push_back(vertex); } } // Construction of the simplex_tree @@ -207,10 +191,7 @@ int main(int argc, char **argv) { #ifdef DEBUG_TRACES std::cout << "filtration = " << filtr << std::endl; #endif // DEBUG_TRACES - if (filtr > filtration_max) { - filtration_max = filtr; - } - simplex_tree.insert_simplex(the_simplex_tree, filtr); + simplex_tree.insert_simplex(the_simplex, filtr); if (the_alpha_value_iterator != the_alpha_values.end()) ++the_alpha_value_iterator; else diff --git a/src/Alpha_complex/utilities/weighted_alpha_complex_3d_persistence.cpp b/src/Alpha_complex/utilities/weighted_alpha_complex_3d_persistence.cpp index 0e73a99b..f46f1a58 100644 --- a/src/Alpha_complex/utilities/weighted_alpha_complex_3d_persistence.cpp +++ b/src/Alpha_complex/utilities/weighted_alpha_complex_3d_persistence.cpp @@ -44,7 +44,6 @@ #include <tuple> #include <map> #include <utility> -#include <list> #include <vector> #include <cstdlib> @@ -92,14 +91,13 @@ using Cell_handle = Alpha_shape_3::Cell_handle; using Facet = Alpha_shape_3::Facet; using Edge_3 = Alpha_shape_3::Edge; using Vertex_handle = Alpha_shape_3::Vertex_handle; -using Vertex_list = std::list<Alpha_shape_3::Vertex_handle>; +using Vertex_list = std::vector<Alpha_shape_3::Vertex_handle>; // gudhi type definition using ST = Gudhi::Simplex_tree<Gudhi::Simplex_tree_options_fast_persistence>; using Filtration_value = ST::Filtration_value; using Simplex_tree_vertex = ST::Vertex_handle; using Alpha_shape_simplex_tree_map = std::map<Alpha_shape_3::Vertex_handle, Simplex_tree_vertex>; -using Alpha_shape_simplex_tree_pair = std::pair<Alpha_shape_3::Vertex_handle, Simplex_tree_vertex>; using Simplex_tree_vector_vertex = std::vector<Simplex_tree_vertex>; using Persistent_cohomology = Gudhi::persistent_cohomology::Persistent_cohomology<ST, Gudhi::persistent_cohomology::Field_Zp>; @@ -125,7 +123,7 @@ int main(int argc, char **argv) { exit(-1); } - // Retrieve the triangulation + // Retrieve the points std::vector<Point_3> lp = off_reader.get_point_cloud(); // Read weights information from file @@ -177,37 +175,23 @@ int main(int argc, char **argv) { ST 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(); - int dim_max = 0; - Filtration_value filtration_max = 0.0; 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<Vertex_list, Cell_handle>(*cell); count_cells++; - if (dim_max < 3) { - // Cell is of dim 3 - dim_max = 3; - } } else if (const Facet* facet = CGAL::object_cast<Facet>(&object_iterator)) { vertex_list = from_facet<Vertex_list, Facet>(*facet); count_facets++; - if (dim_max < 2) { - // Facet is of dim 2 - dim_max = 2; - } } else if (const Edge_3* edge = CGAL::object_cast<Edge_3>(&object_iterator)) { vertex_list = from_edge<Vertex_list, Edge_3>(*edge); count_edges++; - if (dim_max < 1) { - // Edge_3 is of dim 1 - dim_max = 1; - } } else if (const Vertex_handle* vertex = CGAL::object_cast<Vertex_handle>(&object_iterator)) { count_vertices++; vertex_list = from_vertex<Vertex_list, Vertex_handle>(*vertex); } // Construction of the vector of simplex_tree vertex from list of alpha_shapes vertex - Simplex_tree_vector_vertex the_simplex_tree; + Simplex_tree_vector_vertex the_simplex; 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()) { @@ -216,15 +200,15 @@ int main(int argc, char **argv) { #ifdef DEBUG_TRACES std::cout << "vertex [" << the_alpha_shape_vertex->point() << "] not found - insert " << 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)); + the_simplex.push_back(vertex); + map_cgal_simplex_tree.emplace(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); + the_simplex.push_back(vertex); } } // Construction of the simplex_tree @@ -232,10 +216,7 @@ int main(int argc, char **argv) { #ifdef DEBUG_TRACES std::cout << "filtration = " << filtr << std::endl; #endif // DEBUG_TRACES - if (filtr > filtration_max) { - filtration_max = filtr; - } - simplex_tree.insert_simplex(the_simplex_tree, filtr); + simplex_tree.insert_simplex(the_simplex, filtr); if (the_alpha_value_iterator != the_alpha_values.end()) ++the_alpha_value_iterator; else diff --git a/src/Alpha_complex/utilities/weighted_periodic_alpha_complex_3d_persistence.cpp b/src/Alpha_complex/utilities/weighted_periodic_alpha_complex_3d_persistence.cpp index 13634ff7..282b9180 100644 --- a/src/Alpha_complex/utilities/weighted_periodic_alpha_complex_3d_persistence.cpp +++ b/src/Alpha_complex/utilities/weighted_periodic_alpha_complex_3d_persistence.cpp @@ -38,7 +38,6 @@ #include <tuple> #include <map> #include <utility> -#include <list> #include <vector> #include <cstdlib> @@ -74,14 +73,13 @@ using Cell_handle = Alpha_shape_3::Cell_handle; using Facet = Alpha_shape_3::Facet; using Edge_3 = Alpha_shape_3::Edge; using Vertex_handle = Alpha_shape_3::Vertex_handle; -using Vertex_list = std::list<Alpha_shape_3::Vertex_handle>; +using Vertex_list = std::vector<Alpha_shape_3::Vertex_handle>; // gudhi type definition using ST = Gudhi::Simplex_tree<Gudhi::Simplex_tree_options_fast_persistence>; using Filtration_value = ST::Filtration_value; using Simplex_tree_vertex = ST::Vertex_handle; using Alpha_shape_simplex_tree_map = std::map<Alpha_shape_3::Vertex_handle, Simplex_tree_vertex>; -using Alpha_shape_simplex_tree_pair = std::pair<Alpha_shape_3::Vertex_handle, Simplex_tree_vertex>; using Simplex_tree_vector_vertex = std::vector<Simplex_tree_vertex>; using Persistent_cohomology = Gudhi::persistent_cohomology::Persistent_cohomology<ST, Gudhi::persistent_cohomology::Field_Zp>; @@ -112,7 +110,7 @@ int main(int argc, char* const argv[]) { usage(argv[0]); } - // Retrieve the triangulation + // Retrieve the points std::vector<Point_3> lp = off_reader.get_point_cloud(); // Read weights information from file @@ -180,37 +178,23 @@ int main(int argc, char* const argv[]) { ST 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(); - int dim_max = 0; - Filtration_value filtration_max = 0.0; 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<Vertex_list, Cell_handle>(*cell); count_cells++; - if (dim_max < 3) { - // Cell is of dim 3 - dim_max = 3; - } } else if (const Facet* facet = CGAL::object_cast<Facet>(&object_iterator)) { vertex_list = from_facet<Vertex_list, Facet>(*facet); count_facets++; - if (dim_max < 2) { - // Facet is of dim 2 - dim_max = 2; - } } else if (const Edge_3* edge = CGAL::object_cast<Edge_3>(&object_iterator)) { vertex_list = from_edge<Vertex_list, Edge_3>(*edge); count_edges++; - if (dim_max < 1) { - // Edge_3 is of dim 1 - dim_max = 1; - } } else if (const Vertex_handle* vertex = CGAL::object_cast<Vertex_handle>(&object_iterator)) { count_vertices++; vertex_list = from_vertex<Vertex_list, Vertex_handle>(*vertex); } // Construction of the vector of simplex_tree vertex from list of alpha_shapes vertex - Simplex_tree_vector_vertex the_simplex_tree; + Simplex_tree_vector_vertex the_simplex; 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()) { @@ -219,15 +203,15 @@ int main(int argc, char* const argv[]) { #ifdef DEBUG_TRACES std::cout << "vertex [" << the_alpha_shape_vertex->point() << "] not found - insert " << 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)); + the_simplex.push_back(vertex); + map_cgal_simplex_tree.emplace(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); + the_simplex.push_back(vertex); } } // Construction of the simplex_tree @@ -235,10 +219,7 @@ int main(int argc, char* const argv[]) { #ifdef DEBUG_TRACES std::cout << "filtration = " << filtr << std::endl; #endif // DEBUG_TRACES - if (filtr > filtration_max) { - filtration_max = filtr; - } - simplex_tree.insert_simplex(the_simplex_tree, filtr); + simplex_tree.insert_simplex(the_simplex, filtr); if (the_alpha_value_iterator != the_alpha_values.end()) ++the_alpha_value_iterator; else |