summaryrefslogtreecommitdiff
path: root/src/Witness_complex/include
diff options
context:
space:
mode:
authorskachano <skachano@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2017-01-18 09:47:11 +0000
committerskachano <skachano@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2017-01-18 09:47:11 +0000
commitc0bd996842bd07fdc18a5df4c385936bd56118d5 (patch)
tree8a1c57d5006e20566b3ab5b4e56c0043272c4d49 /src/Witness_complex/include
parentf6992f0e5eb53d67a567ee0f12d2c16099bcaf1b (diff)
Added a file + fixed the bug
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/relaxed-witness@1944 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: dbc3cc5655ceb450c25be5b877f6bc4d2ce7a1fc
Diffstat (limited to 'src/Witness_complex/include')
-rw-r--r--src/Witness_complex/include/gudhi/Witness_complex.h31
-rw-r--r--src/Witness_complex/include/gudhi/Witness_complex/all_faces_in.h35
2 files changed, 38 insertions, 28 deletions
diff --git a/src/Witness_complex/include/gudhi/Witness_complex.h b/src/Witness_complex/include/gudhi/Witness_complex.h
index 22f0f590..73993900 100644
--- a/src/Witness_complex/include/gudhi/Witness_complex.h
+++ b/src/Witness_complex/include/gudhi/Witness_complex.h
@@ -25,6 +25,7 @@
#include <gudhi/Active_witness/Active_witness.h>
#include <gudhi/Kd_tree_search.h>
+#include <gudhi/Witness_complex/all_faces_in.h>
#include <utility>
#include <vector>
@@ -208,35 +209,9 @@ private:
}
return will_be_active;
}
-
- /* \brief Check if the facets of the k-dimensional simplex witnessed
- * by witness witness_id are already in the complex.
- * inserted_vertex is the handle of the (k+1)-th vertex witnessed by witness_id
- */
- template < typename SimplicialComplexForWitness >
- bool all_faces_in(typeVectorVertex& simplex,
- double* filtration_value,
- SimplicialComplexForWitness& sc)
- {
- typedef typename SimplicialComplexForWitness::Simplex_handle Simplex_handle;
-
- typeVectorVertex facet;
- for (typename typeVectorVertex::iterator not_it = simplex.begin(); not_it != simplex.end(); ++not_it)
- {
- facet.clear();
- for (typename typeVectorVertex::iterator it = simplex.begin(); it != simplex.end(); ++it)
- if (it != not_it)
- facet.push_back(*it);
- Simplex_handle facet_sh = sc.find(facet);
- if (facet_sh == sc.null_simplex())
- return false;
- else if (sc.filtration(facet_sh) > *filtration_value)
- *filtration_value = sc.filtration(facet_sh);
- }
- return true;
- }
-};
+};
+
} // namespace witness_complex
} // namespace Gudhi
diff --git a/src/Witness_complex/include/gudhi/Witness_complex/all_faces_in.h b/src/Witness_complex/include/gudhi/Witness_complex/all_faces_in.h
new file mode 100644
index 00000000..899022f8
--- /dev/null
+++ b/src/Witness_complex/include/gudhi/Witness_complex/all_faces_in.h
@@ -0,0 +1,35 @@
+#ifndef ALL_FACES_IN_H_
+#define ALL_FACES_IN_H_
+
+/* \brief Check if the facets of the k-dimensional simplex witnessed
+ * by witness witness_id are already in the complex.
+ * inserted_vertex is the handle of the (k+1)-th vertex witnessed by witness_id
+ */
+template < typename SimplicialComplexForWitness,
+ typename Simplex >
+ bool all_faces_in(Simplex& simplex,
+ double* filtration_value,
+ SimplicialComplexForWitness& sc)
+ {
+ typedef typename SimplicialComplexForWitness::Simplex_handle Simplex_handle;
+
+ if (simplex.size() == 1)
+ return true; /* Add vertices unconditionally */
+
+ Simplex facet;
+ for (typename Simplex::iterator not_it = simplex.begin(); not_it != simplex.end(); ++not_it)
+ {
+ facet.clear();
+ for (typename Simplex::iterator it = simplex.begin(); it != simplex.end(); ++it)
+ if (it != not_it)
+ facet.push_back(*it);
+ typename SimplicialComplexForWitness::Simplex_handle facet_sh = sc.find(facet);
+ if (facet_sh == sc.null_simplex())
+ return false;
+ else if (sc.filtration(facet_sh) > *filtration_value)
+ *filtration_value = sc.filtration(facet_sh);
+ }
+ return true;
+ }
+
+#endif