summaryrefslogtreecommitdiff
path: root/src/cython
diff options
context:
space:
mode:
authorvrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2018-03-16 12:44:38 +0000
committervrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2018-03-16 12:44:38 +0000
commit0ac3c2e18ee942d59277816a341e94ff18ed370b (patch)
tree2d83b95441fb07312bc2f526fa384a4106d87dce /src/cython
parent6b1ea7e814cd08147d5eadbab50c90e23c3d9837 (diff)
Other interfaces
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/python_nerve_gic_vincent@3293 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 55298b30ca60b8e8956dbd11419acc128b1dee20
Diffstat (limited to 'src/cython')
-rw-r--r--src/cython/cython/nerve_gic.pyx54
-rw-r--r--src/cython/include/Nerve_gic_interface.h4
2 files changed, 58 insertions, 0 deletions
diff --git a/src/cython/cython/nerve_gic.pyx b/src/cython/cython/nerve_gic.pyx
index 989114da..e89fe1d0 100644
--- a/src/cython/cython/nerve_gic.pyx
+++ b/src/cython/cython/nerve_gic.pyx
@@ -46,6 +46,12 @@ cdef extern from "Nerve_gic_interface.h" namespace "Gudhi":
void set_color_from_file(string color_file_name)
void set_color_from_vector(vector[double] color)
void set_cover_from_file(string cover_file_name)
+ void set_cover_from_function()
+ void set_cover_from_Euclidean_Voronoi(int m)
+ void set_function_from_coordinate(int k)
+ void set_function_from_file(string func_file_name)
+ void set_function_from_range(vector[double] function)
+ void set_gain(double g)
# CoverComplex python interface
cdef class CoverComplex:
@@ -201,3 +207,51 @@ cdef class CoverComplex:
else:
print("file " + cover_file_name + " not found.")
+ def set_cover_from_function(self):
+ """Creates a cover C from the preimages of the function f.
+ """
+ self.thisptr.set_cover_from_function()
+
+ def set_cover_from_Voronoi(self, m=100):
+ """Creates the cover C from the Voronoï cells of a subsampling of the
+ point cloud.
+
+ :param m: Number of points in the subsample. Default value is 100.
+ :type m: int
+ """
+ self.thisptr.set_cover_from_Euclidean_Voronoi(m)
+
+ def set_function_from_coordinate(self, k):
+ """Creates the function f from the k-th coordinate of the point cloud.
+
+ :param k: coordinate to use (start at 0).
+ :type k: int
+ """
+ self.thisptr.set_function_from_coordinate(k)
+
+ def set_function_from_file(self, func_file_name):
+ """Creates the function f from a file containing the function values.
+
+ :param func_file_name: name of the input function file.
+ :type func_file_name: string
+ """
+ if os.path.isfile(func_file_name):
+ self.thisptr.set_function_from_file(str.encode(func_file_name))
+ else:
+ print("file " + func_file_name + " not found.")
+
+ def set_function_from_range(self, function):
+ """Creates the function f from a vector stored in memory.
+
+ :param function: Input vector of values.
+ :type function: vector[double]
+ """
+ self.thisptr.set_function_from_range(function)
+
+ def set_gain(self, g):
+ """Sets a gain from a value stored in memory.
+
+ :param g: gain (default value is 0.3).
+ :type g: double
+ """
+ self.thisptr.set_gain(g)
diff --git a/src/cython/include/Nerve_gic_interface.h b/src/cython/include/Nerve_gic_interface.h
index a0f760f0..5eb15e1d 100644
--- a/src/cython/include/Nerve_gic_interface.h
+++ b/src/cython/include/Nerve_gic_interface.h
@@ -24,6 +24,7 @@
#define INCLUDE_NERVE_GIC_INTERFACE_H_
#include <gudhi/Simplex_tree.h>
+#include <gudhi/distance_functions.h>
#include <gudhi/GIC.h>
#include "Simplex_tree_interface.h"
@@ -42,6 +43,9 @@ class Nerve_gic_interface : public Cover_complex<std::vector<double>> {
create_complex(*simplex_tree);
simplex_tree->initialize_filtration();
}
+ void set_cover_from_Euclidean_Voronoi(int m) {
+ set_cover_from_Voronoi(Gudhi::Euclidean_distance(), m);
+ }
};
} // namespace cover_complex