summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoranmoreau <anmoreau@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2015-07-07 10:05:01 +0000
committeranmoreau <anmoreau@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2015-07-07 10:05:01 +0000
commit505a0c3159b1c1a74884b8e28d9eb18aafa57cca (patch)
tree950cfd30cb3833c49c623a446d3456a5648be7ea /src
parent51192ba9c5991a4d232417dd49ce15a14b400599 (diff)
Fix
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/coface@687 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 537ff69dd4c762a196c80d051995c3a4145f7c99
Diffstat (limited to 'src')
-rw-r--r--src/Simplex_tree/include/gudhi/Simplex_tree.h28
-rw-r--r--src/Simplex_tree/test/simplex_tree_unit_test.cpp10
2 files changed, 20 insertions, 18 deletions
diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h
index f2b726f9..f5add449 100644
--- a/src/Simplex_tree/include/gudhi/Simplex_tree.h
+++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h
@@ -613,58 +613,49 @@ private:
*\param vertices contains a list of vertices, which represent the vertices of the simplex not found yet.
*\param curr_nbVertices represents the number of vertices of the simplex found.
*\param cofaces contains a list of Simplex_handle, representing all the cofaces asked.
- *\param length number of vertices in the Simplex_handle of which we search the cofaces.
+ *\param star true if we need the star of the simplex
*\param nbVertices number of vertices of the cofaces we search
* Prefix actions : When the bottom vertex matches with the current vertex in the tree, we remove the bottom vertex from vertices.
* Infix actions : Then we call or not the recursion.
* Postfix actions : Finally, we add back the removed vertex into vertices, and remove this vertex from curr_nbVertices so that we didn't change the parameters.
* If the vertices list is empty, we need to check if curr_nbVertices matches with the dimension of the cofaces asked.
*/
- void rec_coface(std::vector<Vertex_handle> &vertices, Siblings *curr_sib, int curr_nbVertices, std::vector<Simplex_handle>& cofaces, int length, int nbVertices)
+ void rec_coface(std::vector<Vertex_handle> &vertices, Siblings *curr_sib, int curr_nbVertices, std::vector<Simplex_handle>& cofaces, bool star, int nbVertices)
{
- bool star = nbVertices == length;
if (!(star || curr_nbVertices <= nbVertices)) // dimension of actual simplex <= nbVertices
return;
- curr_nbVertices++;
for (Simplex_handle simplex = curr_sib->members().begin(); simplex != curr_sib->members().end(); ++simplex)
{
if (vertices.empty())
{
// If we reached the end of the vertices, and the simplex has more vertices than the given simplex, we found a coface
- bool addCoface = (star || curr_nbVertices == nbVertices); // dimension of actual simplex == nbVertices
+ bool addCoface = (star || curr_nbVertices == nbVertices); // Add a coface if we wan't the star or if the number of vertices of the current simplex matches with nbVertices
if (addCoface)
cofaces.push_back(simplex);
if ((!addCoface || star) && has_children(simplex)) // Rec call
- rec_coface(vertices, simplex->second.children(), curr_nbVertices, cofaces, length, nbVertices);
- curr_nbVertices--;
+ rec_coface(vertices, simplex->second.children(), curr_nbVertices + 1, cofaces, star, nbVertices);
}
else
{
if (simplex->first == vertices.back()) // If curr_sib matches with the top vertex
{
bool equalDim = (star || curr_nbVertices == nbVertices); // dimension of actual simplex == nbVertices
- bool addCoface = vertices.size() == 1 && curr_nbVertices > length && equalDim;
+ bool addCoface = vertices.size() == 1 && equalDim;
if (addCoface)
cofaces.push_back(simplex);
- if ((!addCoface || star) && has_children(simplex))
+ if ((!addCoface || star) && has_children(simplex)) // Rec call
{ // Rec call
Vertex_handle tmp = vertices.back();
vertices.pop_back();
- rec_coface(vertices, simplex->second.children(), curr_nbVertices, cofaces, length, nbVertices);
+ rec_coface(vertices, simplex->second.children(), curr_nbVertices + 1, cofaces, star, nbVertices);
vertices.push_back(tmp);
}
- curr_nbVertices--;
}
else if (simplex->first > vertices.back())
return;
else // (simplex->first < vertices.back()
- {
if (has_children(simplex))
- {
- rec_coface(vertices, simplex->second.children(), curr_nbVertices, cofaces, length, nbVertices);
- curr_nbVertices--;
- }
- }
+ rec_coface(vertices, simplex->second.children(), curr_nbVertices + 1, cofaces, star, nbVertices);
}
}
}
@@ -695,7 +686,8 @@ public:
if (codimension + (int)copy.size() > dimension_ + 1 || (codimension == 0 && (int)copy.size() > dimension_) ) // n+codimension greater than dimension_
return cofaces;
assert(std::is_sorted(copy.begin(), copy.end(), std::greater<Vertex_handle>())); // must be sorted in decreasing order
- rec_coface(copy, &root_, 0, cofaces, (int)copy.size(), codimension + (int)copy.size());
+ bool star = codimension == 0;
+ rec_coface(copy, &root_, 1, cofaces, star, codimension + (int)copy.size());
return cofaces;
}
diff --git a/src/Simplex_tree/test/simplex_tree_unit_test.cpp b/src/Simplex_tree/test/simplex_tree_unit_test.cpp
index a6328663..55a055a0 100644
--- a/src/Simplex_tree/test/simplex_tree_unit_test.cpp
+++ b/src/Simplex_tree/test/simplex_tree_unit_test.cpp
@@ -620,6 +620,11 @@ BOOST_AUTO_TEST_CASE( NSimplexAndSubfaces_tree_insertion )
v.push_back(3);
std::cout << "First test : " << std::endl;
std::cout << "Star of (3):" << std::endl;
+
+ simplex.push_back(3);
+ result.push_back(st.find(simplex));
+ simplex.clear();
+
simplex.push_back(3);
simplex.push_back(0);
result.push_back(st.find(simplex));
@@ -651,6 +656,11 @@ BOOST_AUTO_TEST_CASE( NSimplexAndSubfaces_tree_insertion )
std::cout << "Star of (1,7): " << std::endl;
simplex.push_back(7);
+ simplex.push_back(1);
+ result.push_back(st.find(simplex));
+ simplex.clear();
+
+ simplex.push_back(7);
simplex.push_back(6);
simplex.push_back(1);
simplex.push_back(0);