bindings/python/dionysus.cpp
author Aravindakshan Babu <akshan@stanford.edu>
Fri, 02 Jul 2010 04:19:29 -0700
branchdev
changeset 215 e94d521b72bb
parent 181 1ee6edc17cb6
child 232 edbbf84fde9e
permissions -rw-r--r--
Added code to expose the persistence_diagram class, the bottleneck_distance function and the point class to python. Most of the commonly used methods for each class have been exported. The constructor for point now requires that a data argument be provided along with x and y coord. This needs to be made optional. The constructor for persistence_diagram could possibly be rewritten as well.

#include <utilities/log.h>
#include <boost/python.hpp>
#include "utils.h"

namespace bp = boost::python;
namespace dp = dionysus::python;

void export_simplex();
void export_filtration();
void export_static_persistence();
void export_chain();
void export_birthid();
void export_zigzag_persistence();
void export_cohomology_persistence();
void export_point();
void export_persistence_diagram();

void export_rips();
void export_pairwise_distances();

#ifndef NO_CGAL
void export_alphashapes2d();
void export_alphashapes3d();
#endif

#ifdef LOGGING
void            enable_log(std::string s)
{
    stdoutLog.subscribeTo(RLOG_CHANNEL(s.c_str()));
}
#endif

BOOST_PYTHON_MODULE(_dionysus)
{
    bp::to_python_converter<std::pair<double, bool>, dp::PairToTupleConverter<double, bool> >();

    export_simplex();
    export_filtration();
    export_static_persistence();
    export_chain();
    export_point();
    export_persistence_diagram();

    export_birthid();
    export_zigzag_persistence();
    export_cohomology_persistence();

    export_rips();
    export_pairwise_distances();

#ifndef NO_CGAL
    export_alphashapes2d();
    export_alphashapes3d();
#endif

#ifdef LOGGING
    bp::def("enable_log",           &enable_log);
#endif
};