From 4eb1939d74050c9193daecba2f69471b915180b2 Mon Sep 17 00:00:00 2001 From: anmoreau Date: Tue, 23 Jun 2015 15:01:05 +0000 Subject: 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 --- src/Simplex_tree/test/simplex_tree_unit_test.cpp | 114 +++++++++++++++-------- 1 file changed, 73 insertions(+), 41 deletions(-) (limited to 'src/Simplex_tree/test/simplex_tree_unit_test.cpp') 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 v, int dim, std::vector> res) -{ - std::vector cofaces; +void test_cofaces(typeST& st, std::vector v, int dim, std::vector 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 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 v; - std::vector> result; + std::vector simplex; + std::vector 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(firstCoface, firstCoface + 2)); - result.push_back(std::vector(secondCoface, secondCoface + 2)); - result.push_back(std::vector(thirdCoface, thirdCoface + 3)); - result.push_back(std::vector(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(firstCoface2, firstCoface2 + 4)); - result.push_back(std::vector(secondCoface2, secondCoface2 + 3)); - result.push_back(std::vector(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(firstCoface3, firstCoface3 + 3)); - result.push_back(std::vector(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 -- cgit v1.2.3