summaryrefslogtreecommitdiff
path: root/src/Alpha_complex/test/Alpha_complex_3d_unit_test.cpp
diff options
context:
space:
mode:
authorROUVREAU Vincent <vincent.rouvreau@inria.fr>2019-10-31 11:48:57 +0100
committerROUVREAU Vincent <vincent.rouvreau@inria.fr>2019-10-31 11:48:57 +0100
commitf6a78c1b7ea70b71fdb96f2fc17c44700e4b980a (patch)
tree5648693cc189220af1e966f61530281758e86feb /src/Alpha_complex/test/Alpha_complex_3d_unit_test.cpp
parent3bbdc086548740b6cc85c16b8afcd02b606c6bde (diff)
Add a get_point method for Alpha_complex_3d. Change Point_3 type to be either Weighted_point_3 or Bare_point_3 (new type). Add some get_point method tests.
Diffstat (limited to 'src/Alpha_complex/test/Alpha_complex_3d_unit_test.cpp')
-rw-r--r--src/Alpha_complex/test/Alpha_complex_3d_unit_test.cpp53
1 files changed, 50 insertions, 3 deletions
diff --git a/src/Alpha_complex/test/Alpha_complex_3d_unit_test.cpp b/src/Alpha_complex/test/Alpha_complex_3d_unit_test.cpp
index 1102838a..cd698a27 100644
--- a/src/Alpha_complex/test/Alpha_complex_3d_unit_test.cpp
+++ b/src/Alpha_complex/test/Alpha_complex_3d_unit_test.cpp
@@ -56,21 +56,52 @@ BOOST_AUTO_TEST_CASE(Alpha_complex_3d_from_points) {
// -----------------
std::cout << "Fast alpha complex 3d" << std::endl;
- Fast_alpha_complex_3d alpha_complex(get_points<Fast_alpha_complex_3d::Point_3>());
+ std::vector<Fast_alpha_complex_3d::Bare_point_3> points = get_points<Fast_alpha_complex_3d::Bare_point_3>();
+ Fast_alpha_complex_3d alpha_complex(points);
Gudhi::Simplex_tree<> stree;
alpha_complex.create_complex(stree);
+ for (std::size_t index = 0; index < points.size(); index++) {
+ bool found = false;
+ for (auto point : points) {
+ if (point == alpha_complex.get_point(index)) {
+ found = true;
+ break;
+ }
+ }
+ // Check all points from alpha complex are found in the input point cloud
+ BOOST_CHECK(found);
+ }
+ // Exception if we go out of range
+ BOOST_CHECK_THROW(alpha_complex.get_point(points.size()), std::out_of_range);
+
// -----------------
// Exact version
// -----------------
std::cout << "Exact alpha complex 3d" << std::endl;
- Exact_alpha_complex_3d exact_alpha_complex(get_points<Exact_alpha_complex_3d::Point_3>());
+ std::vector<Exact_alpha_complex_3d::Bare_point_3> exact_points = get_points<Exact_alpha_complex_3d::Bare_point_3>();
+ Exact_alpha_complex_3d exact_alpha_complex(exact_points);
Gudhi::Simplex_tree<> exact_stree;
exact_alpha_complex.create_complex(exact_stree);
+ for (std::size_t index = 0; index < exact_points.size(); index++) {
+ bool found = false;
+ Exact_alpha_complex_3d::Bare_point_3 ap = exact_alpha_complex.get_point(index);
+ for (auto point : points) {
+ if ((point.x() == ap.x()) && (point.y() == ap.y()) && (point.z() == ap.z())) {
+ found = true;
+ break;
+ }
+ }
+ // Check all points from alpha complex are found in the input point cloud
+ BOOST_CHECK(found);
+ }
+ // Exception if we go out of range
+ BOOST_CHECK_THROW(exact_alpha_complex.get_point(exact_points.size()), std::out_of_range);
+
// ---------------------
// Compare both versions
// ---------------------
@@ -110,11 +141,27 @@ BOOST_AUTO_TEST_CASE(Alpha_complex_3d_from_points) {
// -----------------
std::cout << "Safe alpha complex 3d" << std::endl;
- Safe_alpha_complex_3d safe_alpha_complex(get_points<Safe_alpha_complex_3d::Point_3>());
+ std::vector<Safe_alpha_complex_3d::Bare_point_3> safe_points = get_points<Safe_alpha_complex_3d::Bare_point_3>();
+ Safe_alpha_complex_3d safe_alpha_complex(safe_points);
Gudhi::Simplex_tree<> safe_stree;
safe_alpha_complex.create_complex(safe_stree);
+ for (std::size_t index = 0; index < safe_points.size(); index++) {
+ bool found = false;
+ Safe_alpha_complex_3d::Bare_point_3 ap = safe_alpha_complex.get_point(index);
+ for (auto point : points) {
+ if ((point.x() == ap.x()) && (point.y() == ap.y()) && (point.z() == ap.z())) {
+ found = true;
+ break;
+ }
+ }
+ // Check all points from alpha complex are found in the input point cloud
+ BOOST_CHECK(found);
+ }
+ // Exception if we go out of range
+ BOOST_CHECK_THROW(safe_alpha_complex.get_point(safe_points.size()), std::out_of_range);
+
// ---------------------
// Compare both versions
// ---------------------