tools/extract-diagram.cpp
author Christos Mantoulidis <cmad@stanford.edu>
Tue, 04 Aug 2009 13:23:16 -0700
branchdev
changeset 156 f75fb57d2831
parent 124 af54138b98fd
permissions -rw-r--r--
Changed implementation of WeightedRips to store simplex values (max distance between simplices' vertices) as an invisible layer on top of each simplex object, so that the data() field of WeightedRips has been freed for use by the users again.

#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;
}