tools/extract-diagram.cpp
author Christos Mantoulidis <cmad@stanford.edu>
Tue, 28 Jul 2009 10:58:53 -0700
branchdev
changeset 153 7731c42892de
parent 124 af54138b98fd
permissions -rw-r--r--
Modified WeightedRips::generate() to incorporate the simplex-appearance-value computation (before it would have to be done explicitly by the user by a for-loop after the call to generate())

#include <topology/persistence-diagram.h>

#include <string>
#include <map>
#include <iostream>

#include <fstream>
#include <boost/archive/binary_iarchive.hpp>
#include <boost/serialization/map.hpp>

typedef PersistenceDiagram<>                    PDgm;

int main(int argc, char** argv)
{
    if (argc < 2)
    {
        std::cout << "Usage: " << argv[0] << " FILENAME" << std::endl;
        return 0;
    }
    std::string infilename = argv[1];
    
    std::ifstream ifs(infilename.c_str());
    boost::archive::binary_iarchive ia(ifs);
    
    std::map<Dimension, PDgm> dgms;
    ia >> dgms;
    for (std::map<Dimension, PDgm>::const_iterator cur = dgms.begin(); cur != dgms.end(); ++cur)
        for (PDgm::const_iterator pcur = cur->second.begin(); pcur != cur->second.end(); ++pcur)
            std::cout << cur->first << " " << pcur->x() << " " << pcur->y() << std::endl;
}