summaryrefslogtreecommitdiff
path: root/src/Alpha_complex/example
diff options
context:
space:
mode:
Diffstat (limited to 'src/Alpha_complex/example')
-rw-r--r--src/Alpha_complex/example/Alpha_complex_3d_from_points.cpp56
-rw-r--r--src/Alpha_complex/example/Alpha_complex_from_points.cpp20
-rw-r--r--src/Alpha_complex/example/CMakeLists.txt23
-rw-r--r--src/Alpha_complex/example/Weighted_alpha_complex_3d_from_points.cpp52
-rw-r--r--src/Alpha_complex/example/weightedalpha3dfrompoints_for_doc.txt31
5 files changed, 159 insertions, 23 deletions
diff --git a/src/Alpha_complex/example/Alpha_complex_3d_from_points.cpp b/src/Alpha_complex/example/Alpha_complex_3d_from_points.cpp
new file mode 100644
index 00000000..0e359a27
--- /dev/null
+++ b/src/Alpha_complex/example/Alpha_complex_3d_from_points.cpp
@@ -0,0 +1,56 @@
+#include <gudhi/Alpha_complex_3d.h>
+// to construct a simplex_tree from alpha complex
+#include <gudhi/Simplex_tree.h>
+
+#include <iostream>
+#include <string>
+#include <vector>
+#include <limits> // for numeric limits
+
+using Alpha_complex_3d = Gudhi::alpha_complex::Alpha_complex_3d<Gudhi::alpha_complex::complexity::SAFE, false, false>;
+using Point = Alpha_complex_3d::Point_3;
+using Vector_of_points = std::vector<Point>;
+
+int main(int argc, char **argv) {
+ if (argc != 1) {
+ std::cerr << "Error: Number of arguments (" << argc << ") is not correct\n";
+ std::cerr << "Usage: " << (argv[0] - 1) << " \n";
+ exit(-1); // ----- >>
+ }
+
+ // ----------------------------------------------------------------------------
+ // Init of a list of points from a small molecule
+ // ----------------------------------------------------------------------------
+ Vector_of_points points;
+ points.push_back(Point(1, -1, -1));
+ points.push_back(Point(-1, 1, -1));
+ points.push_back(Point(-1, -1, 1));
+ points.push_back(Point(1, 1, 1));
+ points.push_back(Point(2, 2, 2));
+
+ // ----------------------------------------------------------------------------
+ // Init of an alpha complex from the list of points
+ // ----------------------------------------------------------------------------
+ Alpha_complex_3d alpha_complex_from_points(points);
+
+ Gudhi::Simplex_tree<> simplex;
+ if (alpha_complex_from_points.create_complex(simplex)) {
+ // ----------------------------------------------------------------------------
+ // Display information about the alpha complex
+ // ----------------------------------------------------------------------------
+ std::cout << "Alpha complex is of dimension " << simplex.dimension() << " - " << simplex.num_simplices()
+ << " simplices - " << simplex.num_vertices() << " vertices." << std::endl;
+
+ std::cout << "Iterator on alpha complex simplices in the filtration order, with [filtration value]:" << std::endl;
+ for (auto f_simplex : simplex.filtration_simplex_range()) {
+ std::cout << " ( ";
+ for (auto vertex : simplex.simplex_vertex_range(f_simplex)) {
+ std::cout << vertex << " ";
+ }
+ std::cout << ") -> "
+ << "[" << simplex.filtration(f_simplex) << "] ";
+ std::cout << std::endl;
+ }
+ }
+ return 0;
+}
diff --git a/src/Alpha_complex/example/Alpha_complex_from_points.cpp b/src/Alpha_complex/example/Alpha_complex_from_points.cpp
index c19f7cc8..981aa470 100644
--- a/src/Alpha_complex/example/Alpha_complex_from_points.cpp
+++ b/src/Alpha_complex/example/Alpha_complex_from_points.cpp
@@ -5,29 +5,13 @@
#include <CGAL/Epick_d.h>
#include <iostream>
-#include <string>
#include <vector>
-#include <limits> // for numeric limits
using Kernel = CGAL::Epick_d< CGAL::Dimension_tag<2> >;
using Point = Kernel::Point_d;
using Vector_of_points = std::vector<Point>;
-void usage(int nbArgs, char * const progName) {
- std::cerr << "Error: Number of arguments (" << nbArgs << ") is not correct\n";
- std::cerr << "Usage: " << progName << " [alpha_square_max_value]\n";
- std::cerr << " i.e.: " << progName << " 60.0\n";
- exit(-1); // ----- >>
-}
-
-int main(int argc, char **argv) {
- if ((argc != 1) && (argc != 2)) usage(argc, (argv[0] - 1));
-
- // Delaunay complex if alpha_square_max_value is not given by the user.
- double alpha_square_max_value {std::numeric_limits<double>::infinity()};
- if (argc == 2)
- alpha_square_max_value = atof(argv[1]);
-
+int main() {
// ----------------------------------------------------------------------------
// Init of a list of points
// ----------------------------------------------------------------------------
@@ -46,7 +30,7 @@ int main(int argc, char **argv) {
Gudhi::alpha_complex::Alpha_complex<Kernel> alpha_complex_from_points(points);
Gudhi::Simplex_tree<> simplex;
- if (alpha_complex_from_points.create_complex(simplex, alpha_square_max_value)) {
+ if (alpha_complex_from_points.create_complex(simplex)) {
// ----------------------------------------------------------------------------
// Display information about the alpha complex
// ----------------------------------------------------------------------------
diff --git a/src/Alpha_complex/example/CMakeLists.txt b/src/Alpha_complex/example/CMakeLists.txt
index 2fc62452..c62a220c 100644
--- a/src/Alpha_complex/example/CMakeLists.txt
+++ b/src/Alpha_complex/example/CMakeLists.txt
@@ -1,7 +1,5 @@
project(Alpha_complex_examples)
-# need CGAL 4.7
-# cmake -DCGAL_DIR=~/workspace/CGAL-4.7 ..
if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.7.0)
add_executable ( Alpha_complex_example_from_points Alpha_complex_from_points.cpp )
target_link_libraries(Alpha_complex_example_from_points ${CGAL_LIBRARY})
@@ -28,8 +26,23 @@ if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.7.0)
add_test(Alpha_complex_example_from_off_32_diff_files ${DIFF_PATH}
${CMAKE_CURRENT_BINARY_DIR}/alphaoffreader_result_32.txt ${CMAKE_CURRENT_BINARY_DIR}/alphaoffreader_for_doc_32.txt)
endif()
+endif(NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.7.0)
- install(TARGETS Alpha_complex_example_from_points DESTINATION bin)
- install(TARGETS Alpha_complex_example_from_off DESTINATION bin)
+if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0)
+ add_executable ( Alpha_complex_example_weighted_3d_from_points Weighted_alpha_complex_3d_from_points.cpp )
+ target_link_libraries(Alpha_complex_example_weighted_3d_from_points ${CGAL_LIBRARY})
+ if (TBB_FOUND)
+ target_link_libraries(Alpha_complex_example_weighted_3d_from_points ${TBB_LIBRARIES})
+ endif()
+ add_test(NAME Alpha_complex_example_weighted_3d_from_points
+ COMMAND $<TARGET_FILE:Alpha_complex_example_weighted_3d_from_points>)
-endif(NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.7.0)
+ add_executable ( Alpha_complex_example_3d_from_points Alpha_complex_3d_from_points.cpp )
+ target_link_libraries(Alpha_complex_example_3d_from_points ${CGAL_LIBRARY})
+ if (TBB_FOUND)
+ target_link_libraries(Alpha_complex_example_3d_from_points ${TBB_LIBRARIES})
+ endif()
+ add_test(NAME Alpha_complex_example_3d_from_points
+ COMMAND $<TARGET_FILE:Alpha_complex_example_3d_from_points>)
+
+endif(NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0)
diff --git a/src/Alpha_complex/example/Weighted_alpha_complex_3d_from_points.cpp b/src/Alpha_complex/example/Weighted_alpha_complex_3d_from_points.cpp
new file mode 100644
index 00000000..ac11b68c
--- /dev/null
+++ b/src/Alpha_complex/example/Weighted_alpha_complex_3d_from_points.cpp
@@ -0,0 +1,52 @@
+#include <gudhi/Alpha_complex_3d.h>
+// to construct a simplex_tree from alpha complex
+#include <gudhi/Simplex_tree.h>
+
+#include <iostream>
+#include <string>
+#include <vector>
+#include <limits> // for numeric limits
+
+// Complexity = FAST, weighted = true, periodic = false
+using Weighted_alpha_complex_3d =
+ Gudhi::alpha_complex::Alpha_complex_3d<Gudhi::alpha_complex::complexity::SAFE, true, false>;
+using Point = Weighted_alpha_complex_3d::Point_3;
+using Weighted_point = Weighted_alpha_complex_3d::Weighted_point_3;
+
+int main(int argc, char **argv) {
+ // ----------------------------------------------------------------------------
+ // Init of a list of points and weights from a small molecule
+ // ----------------------------------------------------------------------------
+ std::vector<Weighted_point> weighted_points;
+ weighted_points.push_back(Weighted_point(Point(1, -1, -1), 4.));
+ weighted_points.push_back(Weighted_point(Point(-1, 1, -1), 4.));
+ weighted_points.push_back(Weighted_point(Point(-1, -1, 1), 4.));
+ weighted_points.push_back(Weighted_point(Point(1, 1, 1), 4.));
+ weighted_points.push_back(Weighted_point(Point(2, 2, 2), 1.));
+
+ // ----------------------------------------------------------------------------
+ // Init of an alpha complex from the list of points
+ // ----------------------------------------------------------------------------
+ Weighted_alpha_complex_3d alpha_complex_from_points(weighted_points);
+
+ Gudhi::Simplex_tree<> simplex;
+ if (alpha_complex_from_points.create_complex(simplex)) {
+ // ----------------------------------------------------------------------------
+ // Display information about the alpha complex
+ // ----------------------------------------------------------------------------
+ std::cout << "Alpha complex is of dimension " << simplex.dimension() << " - " << simplex.num_simplices()
+ << " simplices - " << simplex.num_vertices() << " vertices." << std::endl;
+
+ std::cout << "Iterator on alpha complex simplices in the filtration order, with [filtration value]:" << std::endl;
+ for (auto f_simplex : simplex.filtration_simplex_range()) {
+ std::cout << " ( ";
+ for (auto vertex : simplex.simplex_vertex_range(f_simplex)) {
+ std::cout << vertex << " ";
+ }
+ std::cout << ") -> "
+ << "[" << simplex.filtration(f_simplex) << "] ";
+ std::cout << std::endl;
+ }
+ }
+ return 0;
+}
diff --git a/src/Alpha_complex/example/weightedalpha3dfrompoints_for_doc.txt b/src/Alpha_complex/example/weightedalpha3dfrompoints_for_doc.txt
new file mode 100644
index 00000000..7a09998d
--- /dev/null
+++ b/src/Alpha_complex/example/weightedalpha3dfrompoints_for_doc.txt
@@ -0,0 +1,31 @@
+Alpha complex is of dimension 3 - 29 simplices - 5 vertices.
+Iterator on alpha complex simplices in the filtration order, with [filtration value]:
+ ( 0 ) -> [-4]
+ ( 1 ) -> [-4]
+ ( 2 ) -> [-4]
+ ( 3 ) -> [-4]
+ ( 1 0 ) -> [-2]
+ ( 2 0 ) -> [-2]
+ ( 2 1 ) -> [-2]
+ ( 3 0 ) -> [-2]
+ ( 3 1 ) -> [-2]
+ ( 3 2 ) -> [-2]
+ ( 2 1 0 ) -> [-1.33333]
+ ( 3 1 0 ) -> [-1.33333]
+ ( 3 2 0 ) -> [-1.33333]
+ ( 3 2 1 ) -> [-1.33333]
+ ( 3 2 1 0 ) -> [-1]
+ ( 4 ) -> [-1]
+ ( 4 2 ) -> [-1]
+ ( 4 0 ) -> [23]
+ ( 4 1 ) -> [23]
+ ( 4 2 0 ) -> [23]
+ ( 4 2 1 ) -> [23]
+ ( 4 3 ) -> [23]
+ ( 4 3 2 ) -> [23]
+ ( 4 1 0 ) -> [95]
+ ( 4 2 1 0 ) -> [95]
+ ( 4 3 0 ) -> [95]
+ ( 4 3 1 ) -> [95]
+ ( 4 3 2 0 ) -> [95]
+ ( 4 3 2 1 ) -> [95]