summaryrefslogtreecommitdiff
path: root/src/Simplex_tree/test/simplex_tree_unit_test.cpp
diff options
context:
space:
mode:
authoranmoreau <anmoreau@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2015-06-23 15:01:05 +0000
committeranmoreau <anmoreau@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2015-06-23 15:01:05 +0000
commit4eb1939d74050c9193daecba2f69471b915180b2 (patch)
treeb57a41f5b0d17251671a3f26134f05957e008ba3 /src/Simplex_tree/test/simplex_tree_unit_test.cpp
parent9d3c9ae3ccd861c00d113c17da7ec896eece7dac (diff)
multiple fix
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/coface@634 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 0bcb4f121da2714128c3ae8ab0da2000e815d339
Diffstat (limited to 'src/Simplex_tree/test/simplex_tree_unit_test.cpp')
-rw-r--r--src/Simplex_tree/test/simplex_tree_unit_test.cpp114
1 files changed, 73 insertions, 41 deletions
diff --git a/src/Simplex_tree/test/simplex_tree_unit_test.cpp b/src/Simplex_tree/test/simplex_tree_unit_test.cpp
index f8de1c24..344cb009 100644
--- a/src/Simplex_tree/test/simplex_tree_unit_test.cpp
+++ b/src/Simplex_tree/test/simplex_tree_unit_test.cpp
@@ -174,25 +174,20 @@ void set_and_test_simplex_tree_dim_fil(typeST& simplexTree, int vectorSize, cons
BOOST_CHECK(simplexTree.num_simplices() == nb_simplices);
}
-void test_cofaces(typeST& st, std::vector<Vertex_handle> v, int dim, std::vector<std::vector<Vertex_handle>> res)
-{
- std::vector<typeST::Simplex_handle> cofaces;
+void test_cofaces(typeST& st, std::vector<Vertex_handle> v, int dim, std::vector<typeST::Simplex_handle> res) {
+ typeST::Coface_simplex_range cofaces;
if (dim == 0)
cofaces = st.star_simplex_range(st.find(v));
else
- cofaces = st.cofaces_simplex_range(st.find(v), dim);
- std::vector<Vertex_handle> currentVertices;
- for (unsigned long i = 0; i < cofaces.size(); ++i)
+ cofaces = st.coface_simplex_range(st.find(v), dim);
+ for (auto simplex = cofaces.begin(); simplex != cofaces.end(); ++simplex)
{
- typeST::Simplex_vertex_range rg = st.simplex_vertex_range(cofaces[i]);
- currentVertices.clear();
- for (auto j = rg.begin(); j != rg.end(); ++j)
- {
- std::cout << "(" << *j << ")";
- currentVertices.push_back(*j);
+ typeST::Simplex_vertex_range rg = st.simplex_vertex_range(*simplex);
+ for (auto vertex = rg.begin(); vertex != rg.end(); ++vertex) {
+ std::cout << "(" << *vertex << ")" ;
}
- BOOST_CHECK(std::find(res.begin(), res.end(), currentVertices)!=res.end());
std::cout << std::endl;
+ BOOST_CHECK(std::find(res.begin(), res.end(), *simplex)!=res.end());
}
}
@@ -620,18 +615,32 @@ BOOST_AUTO_TEST_CASE( NSimplexAndSubfaces_tree_insertion )
st.set_dimension(3);
std::cout << "COFACE ALGORITHM" << std::endl;
std::vector<Vertex_handle> v;
- std::vector<std::vector<Vertex_handle>> result;
+ std::vector<Vertex_handle> simplex;
+ std::vector<typeST::Simplex_handle> result;
v.push_back(3);
std::cout << "First test : " << std::endl;
std::cout << "Star of (3):" << std::endl;
- int firstCoface[] = {3, 0};
- int secondCoface[] = {4, 3};
- int thirdCoface[] = {5, 4, 3};
- int fourthCoface[] = {5, 3};
- result.push_back(std::vector<Vertex_handle>(firstCoface, firstCoface + 2));
- result.push_back(std::vector<Vertex_handle>(secondCoface, secondCoface + 2));
- result.push_back(std::vector<Vertex_handle>(thirdCoface, thirdCoface + 3));
- result.push_back(std::vector<Vertex_handle>(fourthCoface, fourthCoface + 2));
+ simplex.push_back(3);
+ simplex.push_back(0);
+ result.push_back(st.find(simplex));
+ simplex.clear();
+
+ simplex.push_back(4);
+ simplex.push_back(3);
+ result.push_back(st.find(simplex));
+ simplex.clear();
+
+ simplex.push_back(5);
+ simplex.push_back(4);
+ simplex.push_back(3);
+ result.push_back(st.find(simplex));
+ simplex.clear();
+
+ simplex.push_back(5);
+ simplex.push_back(3);
+ result.push_back(st.find(simplex));
+ simplex.clear();
+
test_cofaces(st, v, 0, result);
v.clear();
result.clear();
@@ -640,34 +649,57 @@ BOOST_AUTO_TEST_CASE( NSimplexAndSubfaces_tree_insertion )
v.push_back(7);
std::cout << "Second test : " << std::endl;
std::cout << "Star of (1,7): " << std::endl;
- int firstCoface2[] = {7, 6, 1, 0};
- int secondCoface2[] = {7, 1, 0};
- int thirdCoface2[] = {7 ,6, 1};
- result.push_back(std::vector<Vertex_handle>(firstCoface2, firstCoface2 + 4));
- result.push_back(std::vector<Vertex_handle>(secondCoface2, secondCoface2 + 3));
- result.push_back(std::vector<Vertex_handle>(thirdCoface2, thirdCoface2 + 3));
+
+ simplex.push_back(7);
+ simplex.push_back(6);
+ simplex.push_back(1);
+ simplex.push_back(0);
+ result.push_back(st.find(simplex));
+ simplex.clear();
+
+ simplex.push_back(7);
+ simplex.push_back(1);
+ simplex.push_back(0);
+ result.push_back(st.find(simplex));
+ simplex.clear();
+
+ simplex.push_back(7);
+ simplex.push_back(6);
+ simplex.push_back(1);
+ result.push_back(st.find(simplex));
+ simplex.clear();
+
test_cofaces(st, v, 0, result);
result.clear();
std::cout << "Third test : " << std::endl;
std::cout << "2-dimension Cofaces of simplex(1,7) : " << std::endl;
- int secondCoface3[] = {7, 1, 0};
- int firstCoface3[] = {7, 6, 1};
- result.push_back(std::vector<Vertex_handle>(firstCoface3, firstCoface3 + 3));
- result.push_back(std::vector<Vertex_handle>(secondCoface3, secondCoface3 + 3));
+
+ simplex.push_back(7);
+ simplex.push_back(1);
+ simplex.push_back(0);
+ result.push_back(st.find(simplex));
+ simplex.clear();
+
+ simplex.push_back(7);
+ simplex.push_back(6);
+ simplex.push_back(1);
+ result.push_back(st.find(simplex));
+ simplex.clear();
+
test_cofaces(st, v, 1, result);
result.clear();
- std::cout << "Cofaces with a codimension too high (codimension + vetices > tree.dimension)" << std::endl;
+ std::cout << "Cofaces with a codimension too high (codimension + vetices > tree.dimension) :" << std::endl;
test_cofaces(st, v, 5, result);
- std::cout << "Cofaces with an empty codimension" << std::endl;
- test_cofaces(st, v, -1, result);
- std::cout << "Cofaces in an empty simplex tree" << std::endl;
- typeST empty_tree;
- test_cofaces(empty_tree, v, 1, result);
- std::cout << "Cofaces of an empty simplex" << std::endl;
- v.clear();
- test_cofaces(st, v, 1, result);
+// std::cout << "Cofaces with an empty codimension" << std::endl;
+// test_cofaces(st, v, -1, result);
+// std::cout << "Cofaces in an empty simplex tree" << std::endl;
+// typeST empty_tree;
+// test_cofaces(empty_tree, v, 1, result);
+// std::cout << "Cofaces of an empty simplex" << std::endl;
+// v.clear();
+// test_cofaces(st, v, 1, result);
/*
// TEST Off read