| 1 |
/* This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. |
| 2 |
* See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. |
| 3 |
* Author(s): David Salinas |
| 4 |
* |
| 5 |
* Copyright (C) 2014 Inria |
| 6 |
* |
| 7 |
* Modification(s): |
| 8 |
* - YYYY/MM Author: Description of the modification |
| 9 |
*/ |
| 10 |
|
| 11 |
#include <gudhi/Skeleton_blocker.h> |
| 12 |
|
| 13 |
#include <stdio.h> |
| 14 |
#include <stdlib.h> |
| 15 |
#include <string> |
| 16 |
#include <fstream> |
| 17 |
#include <sstream> |
| 18 |
#include <vector> |
| 19 |
|
| 20 |
typedef Gudhi::skeleton_blocker::Skeleton_blocker_simple_traits Traits; |
| 21 |
typedef Gudhi::skeleton_blocker::Skeleton_blocker_complex<Traits> Complex; |
| 22 |
typedef Complex::Vertex_handle Vertex_handle; |
| 23 |
typedef Complex::Simplex Simplex; |
| 24 |
|
| 25 |
int main(int argc, char *argv[]) { |
| 26 |
std::vector<Simplex> simplices; |
| 27 |
|
| 28 |
// add 4 triangles of a tetrahedron 0123 |
| 29 |
simplices.push_back(Simplex(Vertex_handle(0), Vertex_handle(1), Vertex_handle(2))); |
| 30 |
simplices.push_back(Simplex(Vertex_handle(1), Vertex_handle(2), Vertex_handle(3))); |
| 31 |
simplices.push_back(Simplex(Vertex_handle(3), Vertex_handle(0), Vertex_handle(2))); |
| 32 |
simplices.push_back(Simplex(Vertex_handle(3), Vertex_handle(0), Vertex_handle(1))); |
| 33 |
|
| 34 |
// get complex from top faces |
| 35 |
Complex complex(Gudhi::skeleton_blocker::make_complex_from_top_faces<Complex>(simplices.begin(), simplices.end())); |
| 36 |
|
| 37 |
|
| 38 |
std::clog << "Simplices:" << std::endl; |
| 39 |
for (const Simplex & s : complex.complex_simplex_range()) |
| 40 |
std::clog << s << " "; |
| 41 |
std::clog << std::endl; |
| 42 |
|
| 43 |
// One blocker as simplex 0123 is not in the complex but all its proper faces are. |
| 44 |
std::clog << "Blockers: " << complex.blockers_to_string() << std::endl; |
| 45 |
|
| 46 |
// now build a complex from its full list of simplices |
| 47 |
simplices.clear(); |
| 48 |
simplices.push_back(Simplex(Vertex_handle(0))); |
| 49 |
simplices.push_back(Simplex(Vertex_handle(1))); |
| 50 |
simplices.push_back(Simplex(Vertex_handle(2))); |
| 51 |
simplices.push_back(Simplex(Vertex_handle(0), Vertex_handle(1))); |
| 52 |
simplices.push_back(Simplex(Vertex_handle(1), Vertex_handle(2))); |
| 53 |
simplices.push_back(Simplex(Vertex_handle(2), Vertex_handle(0))); |
| 54 |
complex = Complex(simplices.begin(), simplices.end()); |
| 55 |
|
| 56 |
std::clog << "Simplices:" << std::endl; |
| 57 |
for (const Simplex & s : complex.complex_simplex_range()) |
| 58 |
std::clog << s << " "; |
| 59 |
std::clog << std::endl; |
| 60 |
|
| 61 |
// One blocker as simplex 012 is not in the complex but all its proper faces are. |
| 62 |
std::clog << "Blockers: " << complex.blockers_to_string() << std::endl; |
| 63 |
|
| 64 |
return EXIT_SUCCESS; |
| 65 |
} |