summaryrefslogtreecommitdiff
path: root/src/Persistent_cohomology/example/periodic_alpha_complex_3d_persistence.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Persistent_cohomology/example/periodic_alpha_complex_3d_persistence.cpp')
-rw-r--r--src/Persistent_cohomology/example/periodic_alpha_complex_3d_persistence.cpp60
1 files changed, 9 insertions, 51 deletions
diff --git a/src/Persistent_cohomology/example/periodic_alpha_complex_3d_persistence.cpp b/src/Persistent_cohomology/example/periodic_alpha_complex_3d_persistence.cpp
index dbc42706..8928cfc2 100644
--- a/src/Persistent_cohomology/example/periodic_alpha_complex_3d_persistence.cpp
+++ b/src/Persistent_cohomology/example/periodic_alpha_complex_3d_persistence.cpp
@@ -20,10 +20,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <boost/variant.hpp>
+
#include <gudhi/Simplex_tree.h>
#include <gudhi/Persistent_cohomology.h>
#include <gudhi/Points_3D_off_io.h>
-#include <boost/variant.hpp>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Periodic_3_Delaunay_triangulation_traits_3.h>
@@ -41,6 +42,8 @@
#include <vector>
#include <cstdlib>
+#include "alpha_complex_3d_helper.h"
+
// Traits
using K = CGAL::Exact_predicates_inexact_constructions_kernel;
using PK = CGAL::Periodic_3_Delaunay_triangulation_traits_3<K>;
@@ -67,6 +70,7 @@ using Dispatch = CGAL::Dispatch_output_iterator<
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>;
// gudhi type definition
@@ -79,52 +83,6 @@ using Simplex_tree_vector_vertex = std::vector< Simplex_tree_vertex >;
using Persistent_cohomology = Gudhi::persistent_cohomology::Persistent_cohomology<
ST, Gudhi::persistent_cohomology::Field_Zp >;
-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;
-}
-
-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;
-}
-
-Vertex_list from(const Edge_3& 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;
-}
-
-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;
-}
-
void usage(char * const progName) {
std::cerr << "Usage: " << progName <<
" path_to_file_graph path_to_iso_cuboid_3_file coeff_field_characteristic[integer > 0] min_persistence[float >= -1.0]\n";
@@ -203,21 +161,21 @@ int main(int argc, char * const argv[]) {
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 = 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 = 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 = from_edge<Vertex_list, Edge_3>(*edge);
count_edges++;
if (dim_max < 1) {
// Edge_3 is of dim 1
@@ -226,7 +184,7 @@ int main(int argc, char * const argv[]) {
} 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);
+ 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;