summaryrefslogtreecommitdiff
path: root/src/Alpha_complex/utilities/exact_alpha_complex_3d_persistence.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Alpha_complex/utilities/exact_alpha_complex_3d_persistence.cpp')
-rw-r--r--src/Alpha_complex/utilities/exact_alpha_complex_3d_persistence.cpp31
1 files changed, 19 insertions, 12 deletions
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 c69482ab..9a266418 100644
--- a/src/Alpha_complex/utilities/exact_alpha_complex_3d_persistence.cpp
+++ b/src/Alpha_complex/utilities/exact_alpha_complex_3d_persistence.cpp
@@ -4,7 +4,7 @@
*
* Author(s): Vincent Rouvreau
*
- * Copyright (C) 2014 INRIA Saclay (France)
+ * Copyright (C) 2014 INRIA
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -30,8 +30,6 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Delaunay_triangulation_3.h>
#include <CGAL/Alpha_shape_3.h>
-#include <CGAL/Alpha_shape_vertex_base_3.h>
-#include <CGAL/Alpha_shape_cell_base_3.h>
#include <CGAL/iterator.h>
#include <fstream>
@@ -42,6 +40,7 @@
#include <utility>
#include <list>
#include <vector>
+#include <cstdlib>
#include "alpha_complex_3d_helper.h"
@@ -77,7 +76,8 @@ 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 PCOH = Gudhi::persistent_cohomology::Persistent_cohomology<ST, Gudhi::persistent_cohomology::Field_Zp>;
+using Persistent_cohomology =
+ Gudhi::persistent_cohomology::Persistent_cohomology<ST, Gudhi::persistent_cohomology::Field_Zp>;
void program_options(int argc, char *argv[], std::string &off_file_points, std::string &output_file_diag,
int &coeff_field_characteristic, Filtration_value &min_persistence);
@@ -133,28 +133,28 @@ int main(int argc, char **argv) {
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)) {
+ 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)) {
+ } 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)) {
+ } 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)) {
+ } else if (const Vertex_handle* vertex = CGAL::object_cast<Vertex_handle>(&object_iterator)) {
count_vertices++;
vertex_list = from_vertex<Vertex_list, Vertex_handle>(*vertex);
}
@@ -181,7 +181,7 @@ int main(int argc, char **argv) {
}
// Construction of the simplex_tree
// you can also use the_alpha_value_iterator->exact()
- Filtration_value filtr = /*std::sqrt*/ CGAL::to_double(the_alpha_value_iterator->exact());
+ Filtration_value filtr = /*std::sqrt*/CGAL::to_double(the_alpha_value_iterator->exact());
#ifdef DEBUG_TRACES
std::cout << "filtration = " << filtr << std::endl;
#endif // DEBUG_TRACES
@@ -194,7 +194,6 @@ int main(int argc, char **argv) {
else
std::cout << "This shall not happen" << std::endl;
}
- simplex_tree.set_dimension(dim_max);
#ifdef DEBUG_TRACES
std::cout << "vertices \t\t" << count_vertices << std::endl;
@@ -220,13 +219,21 @@ int main(int argc, char **argv) {
std::cout << "Simplex_tree dim: " << simplex_tree.dimension() << std::endl;
// Compute the persistence diagram of the complex
- PCOH pcoh(simplex_tree);
+ Persistent_cohomology pcoh(simplex_tree, true);
// initializes the coefficient field for homology
pcoh.init_coefficients(coeff_field_characteristic);
pcoh.compute_persistent_cohomology(min_persistence);
- pcoh.output_diagram();
+ // Output the diagram in filediag
+ if (output_file_diag.empty()) {
+ pcoh.output_diagram();
+ } else {
+ std::cout << "Result in file: " << output_file_diag << std::endl;
+ std::ofstream out(output_file_diag);
+ pcoh.output_diagram(out);
+ out.close();
+ }
return 0;
}