bindings/python/static-persistence.h
author Dmitriy Morozov <dmitriy@mrzv.org>
Fri, 06 May 2011 10:38:06 -0700
branchdev
changeset 243 c9b8c98187a8
parent 232 edbbf84fde9e
permissions -rw-r--r--
Minor fixes in tools/draw-diagram

#ifndef __PYTHON_STATIC_PERSISTENCE_H__
#define __PYTHON_STATIC_PERSISTENCE_H__

#include <topology/static-persistence.h>

#include "filtration.h"

namespace dionysus {
namespace python   {

typedef         StaticPersistence<>             SPersistence;
typedef         SPersistence::OrderElement      SPersistenceNode;
typedef         SPersistence::OrderIndex        SPersistenceIndex;
typedef         SPersistence::SimplexMap<PythonFiltration>        
                                                SPersistenceSimplexMap;


/* Persistence */
template<class Persistence>
boost::shared_ptr<Persistence>          init_from_filtration(bp::object f)
{
    PythonFiltration& sf = bp::extract<PythonFiltration&>(f);
    boost::shared_ptr<Persistence> p(new Persistence(sf));
    return p;
}

template<class Persistence, class PersistenceIndex>
unsigned                                distance(Persistence& p, 
                                                 const PersistenceIndex& i)             { return p.iterator_to(i) - p.begin(); }

/* SPNode */
template<class PNode>
const PNode&                            pair(const PNode& n)                            { return *n.pair; }


/* PersistenceSimplexMap */
template<class PersistenceSimplexMap, class PersistenceIndex>
const SimplexVD&                        psmap_getitem(const PersistenceSimplexMap& psmap, 
                                                      const PersistenceIndex& i)        { return psmap[i]; }


} } // namespace dionysus::python

#endif