bindings/python/rips.cpp
author Dmitriy Morozov <dmitriy@mrzv.org>
Sat, 11 Apr 2009 10:29:53 -0700
branchdev
changeset 126 3c3e77ac43d2
child 127 406c6cc00b9c
permissions -rw-r--r--
Added Python bindings for the Rips complex + an example

#include <topology/rips.h>
#include <boost/python.hpp>
#include "python-rips.h"            // defines RipsWithDistances

#include <iostream>

namespace bp = boost::python;

/* Various wrappers for exposing Rips to Python */
// Constructor from distances
boost::shared_ptr<RipsWithDistances>        init_from_distances(bp::object distances)
{ 
    boost::shared_ptr<RipsWithDistances>    p(new RipsWithDistances(distances));
    return p;
}

void export_rips()
{
    bp::class_<RipsWithDistances>("Rips", bp::no_init)
        .def("__init__",            make_constructor(&init_from_distances))
        .def("generate",            &RipsWithDistances::generate)
        .def("generate",            &RipsWithDistances::generate_candidates)
        .def("vertex_cofaces",      &RipsWithDistances::vertex_cofaces)
        .def("vertex_cofaces",      &RipsWithDistances::vertex_cofaces_candidate)
        .def("edge_cofaces",        &RipsWithDistances::edge_cofaces)
        .def("edge_cofaces",        &RipsWithDistances::edge_cofaces_candidates)

        .def("cmp",                 &RipsWithDistances::cmp)
        .def("eval",                &RipsWithDistances::eval)
    ;
}