--- a/Doxyfile Thu Dec 21 13:37:23 2006 -0500
+++ b/Doxyfile Fri Dec 22 10:25:26 2006 -0500
@@ -444,7 +444,7 @@
# excluded from the INPUT source files. This way you can easily exclude a
# subdirectory from a directory tree whose root is specified with the INPUT tag.
-EXCLUDE = examples/include/tnt aux
+EXCLUDE = aux
# The EXCLUDE_SYMLINKS tag can be used select whether or not files or directories
# that are symbolic links (a Unix filesystem feature) are excluded from the input.
--- a/README Thu Dec 21 13:37:23 2006 -0500
+++ b/README Fri Dec 22 10:25:26 2006 -0500
@@ -13,7 +13,8 @@
Building
To build examples run "scons" at the top level, or "scons -u" in the specific
examples/ subdirectory.
- "scons debug=1" turns on debugging. "scons counters=1" turns on counters.
+ "scons debug=1" turns on debugging. "scons counters=1" turns on counters.
+ "scons optimize=3" turns on -O3 optimizations.
Author
Dmitriy Morozov <morozov@cs.duke.edu>
--- a/examples/grid/SConscript Thu Dec 21 13:37:23 2006 -0500
+++ b/examples/grid/SConscript Fri Dec 22 10:25:26 2006 -0500
@@ -4,7 +4,7 @@
libraries = ['dsrpdb']
# Sources
-sources = ['test-grid2D.cpp', 'pdbdistance-vineyard.cpp']
+sources = ['test-grid2D.cpp', 'pdbdistance-vineyard.cpp', 'combustion-vineyard.cpp']
local_env = env.Copy()
local_env.Append (LIBS = libraries)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/grid/combustion-vineyard.cpp Fri Dec 22 10:25:26 2006 -0500
@@ -0,0 +1,79 @@
+/*
+ * Author: Dmitriy Morozov
+ * Department of Computer Science, Duke University, 2005
+ */
+
+#include <iostream>
+#include <fstream>
+#include <algorithm>
+
+#include "grid2D.h"
+#include "grid2Dvineyard.h"
+
+const int xsize = 600;
+const int ysize = 600;
+const int var = 0; // which variable to use out of nc of them in each record in the file
+
+template<typename T>
+void read(std::ifstream& ifs, T& var)
+{
+ ifs.read(reinterpret_cast<char*>(&var), sizeof(T));
+}
+
+int main(int argc, char** argv)
+{
+ if (argc < 3)
+ {
+ std::cout << "Usage: combustion-vineyard FRAME1 FRAME2" << std::endl;
+ exit(0);
+ }
+
+ int size0, nc0;
+ int size1, nc1;
+
+ std::cout << "Reading: " << argv[1] << std::endl;
+ std::ifstream ifs0(argv[1], std::ios::binary);
+ std::cout << "Reading: " << argv[2] << std::endl;
+ std::ifstream ifs1(argv[2], std::ios::binary);
+
+ if (!ifs0 || !ifs1)
+ {
+ std::cout << "Could not open the frames" << std::endl;
+ exit(0);
+ }
+
+ read(ifs0, size0); read(ifs0, nc0);
+ read(ifs1, size1); read(ifs1, nc1);
+
+ assert(size0 == size1); assert(nc0 == nc1);
+ assert(size0 == xsize*ysize);
+
+ Grid2D g0(xsize, ysize), g1(xsize, ysize);
+
+ for (int y = 0; y < ysize; ++y)
+ for (int x = 0; x < xsize; ++x)
+ for (int d = 0; d < nc0; ++d)
+ {
+ float val0, val1;
+ read(ifs0, val0);
+ read(ifs1, val1);
+ if (d == var)
+ {
+ g0(x,y) = val0;
+ g1(x,y) = val1;
+ }
+ }
+ std::cout << "Grids read" << std::endl;
+
+ // Generate filtration and compute pairing
+ Grid2DVineyard v(&g0);
+ std::cout << "Filtration generated, size: " << v.filtration()->size() << std::endl;
+ v.compute_pairing();
+ std::cout << "Pairing computed" << std::endl;
+
+ // Compute vineyard
+ v.compute_vineyard(&g1, true);
+ std::cout << "Vineyard computed" << std::endl;
+
+ v.vineyard()->save_edges("combustion");
+}
--- a/examples/grid/grid2Dvineyard.h Thu Dec 21 13:37:23 2006 -0500
+++ b/examples/grid/grid2Dvineyard.h Fri Dec 22 10:25:26 2006 -0500
@@ -58,7 +58,7 @@
~Grid2DVineyard();
void compute_pairing();
- void compute_vineyard(Grid2D* grid);
+ void compute_vineyard(Grid2D* grid, bool explicit_events = false);
Grid2D* grid() const { return grid_stack_.back(); }
Grid2D* grid(int i) const { return grid_stack_[i]; }
--- a/examples/grid/grid2Dvineyard.hpp Thu Dec 21 13:37:23 2006 -0500
+++ b/examples/grid/grid2Dvineyard.hpp Fri Dec 22 10:25:26 2006 -0500
@@ -1,5 +1,5 @@
/* Implementation */
-
+
Grid2DVineyard::
Grid2DVineyard(Grid2D* g): vertices_(g->size())
{
@@ -33,7 +33,7 @@
void
Grid2DVineyard::
-compute_vineyard(Grid2D* g)
+compute_vineyard(Grid2D* g, bool explicit_events)
{
AssertMsg(filtration_->is_paired(), "Simplices must be paired for a vineyard to be computed");
@@ -48,6 +48,7 @@
Sort sort(tr, SortVisitor(this));
// Setup the (linear) trajectories
+ std::cout << "Setting up trajectories" << std::endl;
CF cf;
kinetic_map_.clear();
for (VertexIndex cur = vertices_.begin(); cur != vertices_.end(); ++cur)
@@ -58,24 +59,28 @@
Point p(x);
cur->set_kinetic_key(apt->insert(p));
kinetic_map_[cur->kinetic_key()] = cur->get_order();
+ if (cur->index() % 10000 == 0)
+ std::cout << "Added trajectory: " << cur->index() << " " << val0 << " " << val1 << std::endl;
}
// Process all the events (compute the vineyard in the process)
change_evaluator(new KineticEvaluator(sp, apt, num_grids() - 1));
- /*
- while (sp->next_event_time() < 1)
+ if (explicit_events)
{
- std::cout << "Next event time: " << sp->next_event_time() << std::endl;
- sp->set_current_event_number(sp->current_event_number() + 1);
- std::cout << "Processed event" << std::endl;
- }
- */
- sp->set_current_time(1.0);
+ while (sp->next_event_time() < 1)
+ {
+ std::cout << "Next event time: " << sp->next_event_time() << std::endl;
+ sp->set_current_event_number(sp->current_event_number() + 1);
+ std::cout << "Processed event" << std::endl;
+ }
+ } else
+ sp->set_current_time(1.0);
std::cout << "Processed " << sp->current_event_number() << " events" << std::endl;
// Add the grid to the stack
grid_stack_.push_back(g);
change_evaluator(new StaticEvaluator(grid(), num_grids() - 1));
+ vineyard_->record_diagram(filtration_->begin(), filtration_->end());
}
void
--- a/include/vineyard.hpp Thu Dec 21 13:37:23 2006 -0500
+++ b/include/vineyard.hpp Fri Dec 22 10:25:26 2006 -0500
@@ -90,6 +90,7 @@
for (typename VineList::const_iterator vi = vines[i].begin(); vi != vines[i].end(); ++vi)
for (typename Vine::const_iterator ki = vi->begin(), kiprev = ki++; ki != vi->end(); kiprev = ki++)
{
+ if (kiprev->is_infinite() || ki->is_infinite()) continue;
out << kiprev->birth << ' ' << kiprev->death << ' ' << kiprev->time << std::endl;
out << ki->birth << ' ' << ki->death << ' ' << ki->time << std::endl;
}