summaryrefslogtreecommitdiff
path: root/src/GudhUI/utils/Rips_builder.h
diff options
context:
space:
mode:
authorsalinasd <salinasd@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2015-01-27 10:20:13 +0000
committersalinasd <salinasd@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2015-01-27 10:20:13 +0000
commitf527cde6342c5b8109a20f0a6b483327c6569844 (patch)
tree1c0464b56b21ef7767f814b9a35a6e5c68aa7613 /src/GudhUI/utils/Rips_builder.h
parentdf6c26bdcb28805e8949d08dad5acd012e91ecb8 (diff)
Merge GudhUI, a UI for gudhi based on Qt
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@427 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 17fedd974f14a8225b27d94361e835964eeb5cba
Diffstat (limited to 'src/GudhUI/utils/Rips_builder.h')
-rw-r--r--src/GudhUI/utils/Rips_builder.h56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/GudhUI/utils/Rips_builder.h b/src/GudhUI/utils/Rips_builder.h
new file mode 100644
index 00000000..9484f9ab
--- /dev/null
+++ b/src/GudhUI/utils/Rips_builder.h
@@ -0,0 +1,56 @@
+/*
+ * Rips_builder.h
+ *
+ * Created on: Sep 10, 2014
+ * Author: dsalinas
+ */
+
+#ifndef RIPS_BUILDER_H_
+#define RIPS_BUILDER_H_
+
+#include <boost/iterator/iterator_facade.hpp>
+
+#include "utils/UI_utils.h"
+#include "model/Complex_typedefs.h"
+#include <CGAL/Euclidean_distance.h>
+
+#include <CGAL/Orthogonal_k_neighbor_search.h>
+#include <CGAL/Search_traits_d.h>
+
+template<typename SkBlComplex> class Rips_builder{
+private:
+ SkBlComplex& complex_;
+public:
+
+ /**
+ * @brief Modify complex to be the Rips complex
+ * of its points with offset alpha.
+ */
+ Rips_builder(SkBlComplex& complex,double alpha):complex_(complex){
+ complex.keep_only_vertices();
+ if (alpha<=0) return;
+ compute_edges(alpha);
+ }
+
+private:
+
+
+ double squared_eucl_distance(const Point& p1,const Point& p2) const{
+ return Geometry_trait::Squared_distance_d()(p1,p2);
+ }
+
+ void compute_edges(double alpha){
+ auto vertices = complex_.vertex_range();
+ for(auto p = vertices.begin(); p!= vertices.end(); ++p){
+ std::cout << *p << " "; std::cout.flush();
+ for (auto q = p; ++q != vertices.end(); /**/)
+ if (squared_eucl_distance(complex_.point(*p),complex_.point(*q)) < 4*alpha*alpha)
+ complex_.add_edge(*p,*q);
+ }
+ std::cout << std::endl;
+ }
+
+};
+
+
+#endif /* RIPS_BUILDER_H_ */