Added tools/extract-diagram + minor fixes dev
authorDmitriy Morozov <dmitriy@mrzv.org>
Fri, 01 May 2009 15:36:25 -0700
branchdev
changeset 124 af54138b98fd
parent 123 c50e7020a1e4
child 125 0a2c2283e4a8
Added tools/extract-diagram + minor fixes
examples/rips/rips-pairwise.cpp
include/topology/simplex.h
tools/CMakeLists.txt
tools/extract-diagram.cpp
--- a/examples/rips/rips-pairwise.cpp	Fri Apr 10 14:35:43 2009 -0700
+++ b/examples/rips/rips-pairwise.cpp	Fri May 01 15:36:25 2009 -0700
@@ -112,7 +112,6 @@
 
     po::positional_options_description pos;
     pos.add("input-file", 1);
-    pos.add("output-file", 2);
     
     po::options_description all; all.add(visible).add(hidden);
 
--- a/include/topology/simplex.h	Fri Apr 10 14:35:43 2009 -0700
+++ b/include/topology/simplex.h	Fri May 01 15:36:25 2009 -0700
@@ -114,16 +114,16 @@
          * DataComparison -             compare simplices based on their <data()>
          * DataDimensionComparison -    compare simplices based on their <data()> within each <dimension()>
          */
-        
-        /* Classes: Functors
-         * DataEvaluator -              return data given a simplex
-         * DimensionExtractor -         return dimesnion given a simplex
-         */
         struct VertexComparison;
         struct VertexDimensionComparison;
         struct DataComparison;
         struct DataDimensionComparison;
 
+        /* Classes: Functors
+         *
+         * DataEvaluator -              return data given a simplex
+         * DimensionExtractor -         return dimesnion given a simplex
+         */
         struct DataEvaluator;
         struct DimensionExtractor;
     
--- a/tools/CMakeLists.txt	Fri Apr 10 14:35:43 2009 -0700
+++ b/tools/CMakeLists.txt	Fri May 01 15:36:25 2009 -0700
@@ -8,5 +8,8 @@
 #find_path                   (QGLViewer_INCLUDE_DIR      QGLViewer/qglviewer.h)
 #include_directories         (${QGLViewer_INCLUDE_DIR})
 
+add_executable              (extract-diagram                extract-diagram.cpp)
+target_link_libraries       (extract-diagram                ${libraries} ${Boost_SERIALIZATION_LIBRARY})
+
 add_subdirectory            (diagram-viewer)
 add_subdirectory            (matching)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/extract-diagram.cpp	Fri May 01 15:36:25 2009 -0700
@@ -0,0 +1,30 @@
+#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;
+}