--- a/CMakeLists.txt Fri Oct 26 11:45:58 2012 -0700
+++ b/CMakeLists.txt Thu Feb 28 11:12:02 2013 +0800
@@ -73,7 +73,7 @@
# Doxygen (FIXME)
if (DOXYGEN_FOUND)
-# add_custom_target (docs ALL
+# add_custom_target (docs ALL
# ${DOXYGEN_EXECUTABLE} Doxyfile
# DEPENDS Doxyfile)
endif (DOXYGEN_FOUND)
--- a/examples/alphashapes/alphashapes2d.hpp Fri Oct 26 11:45:58 2012 -0700
+++ b/examples/alphashapes/alphashapes2d.hpp Thu Feb 28 11:12:02 2013 +0800
@@ -1,121 +1,121 @@
#include <utilities/log.h>
#include <boost/foreach.hpp>
-AlphaSimplex2D::
+AlphaSimplex2D::
AlphaSimplex2D(const Delaunay2D::Vertex& v): alpha_(0), attached_(false)
{
- for (int i = 0; i < 3; ++i)
- if (v.face()->vertex(i) != Vertex_handle() && v.face()->vertex(i)->point() == v.point())
- Parent::add(v.face()->vertex(i));
+ for (int i = 0; i < 3; ++i)
+ if (v.face()->vertex(i) != Vertex_handle() && v.face()->vertex(i)->point() == v.point())
+ Parent::add(v.face()->vertex(i));
}
-AlphaSimplex2D::
+AlphaSimplex2D::
AlphaSimplex2D(const Delaunay2D::Edge& e): attached_(false)
{
Face_handle f = e.first;
- for (int i = 0; i < 3; ++i)
- if (i != e.second)
- Parent::add(f->vertex(i));
+ for (int i = 0; i < 3; ++i)
+ if (i != e.second)
+ Parent::add(f->vertex(i));
}
-AlphaSimplex2D::
+AlphaSimplex2D::
AlphaSimplex2D(const Delaunay2D::Edge& e, const SimplexSet& simplices, const Delaunay2D& Dt): attached_(false)
{
Face_handle f = e.first;
- for (int i = 0; i < 3; ++i)
- if (i != e.second)
- Parent::add(f->vertex(i));
+ for (int i = 0; i < 3; ++i)
+ if (i != e.second)
+ Parent::add(f->vertex(i));
- VertexSet::const_iterator v = static_cast<const Parent*>(this)->vertices().begin();
- const Point& p1 = (*v++)->point();
- const Point& p2 = (*v)->point();
-
- Face_handle o = f->neighbor(e.second);
+ VertexSet::const_iterator v = static_cast<const Parent*>(this)->vertices().begin();
+ const Point& p1 = (*v++)->point();
+ const Point& p2 = (*v)->point();
+
+ Face_handle o = f->neighbor(e.second);
if (o == Face_handle())
{
- alpha_ = squared_radius(p1, p2);
+ alpha_ = CGAL::squared_radius(p1, p2);
return;
}
- int oi = o->index(f);
+ int oi = o->index(f);
- attached_ = false;
- if (!Dt.is_infinite(f->vertex(e.second)) &&
- CGAL::side_of_bounded_circle(p1, p2,
- f->vertex(e.second)->point()) == CGAL::ON_BOUNDED_SIDE)
- attached_ = true;
- else if (!Dt.is_infinite(o->vertex(oi)) &&
+ attached_ = false;
+ if (!Dt.is_infinite(f->vertex(e.second)) &&
+ CGAL::side_of_bounded_circle(p1, p2,
+ f->vertex(e.second)->point()) == CGAL::ON_BOUNDED_SIDE)
+ attached_ = true;
+ else if (!Dt.is_infinite(o->vertex(oi)) &&
CGAL::side_of_bounded_circle(p1, p2,
- o->vertex(oi)->point()) == CGAL::ON_BOUNDED_SIDE)
- attached_ = true;
- else
- alpha_ = squared_radius(p1, p2);
+ o->vertex(oi)->point()) == CGAL::ON_BOUNDED_SIDE)
+ attached_ = true;
+ else
+ alpha_ = CGAL::squared_radius(p1, p2);
- if (attached_)
- {
- if (Dt.is_infinite(f))
- alpha_ = simplices.find(AlphaSimplex2D(*o))->alpha();
- else if (Dt.is_infinite(o))
- alpha_ = simplices.find(AlphaSimplex2D(*f))->alpha();
- else
- alpha_ = std::min(simplices.find(AlphaSimplex2D(*f))->alpha(),
+ if (attached_)
+ {
+ if (Dt.is_infinite(f))
+ alpha_ = simplices.find(AlphaSimplex2D(*o))->alpha();
+ else if (Dt.is_infinite(o))
+ alpha_ = simplices.find(AlphaSimplex2D(*f))->alpha();
+ else
+ alpha_ = std::min(simplices.find(AlphaSimplex2D(*f))->alpha(),
simplices.find(AlphaSimplex2D(*o))->alpha());
- }
+ }
}
-AlphaSimplex2D::
+AlphaSimplex2D::
AlphaSimplex2D(const Delaunay2D::Face& f): attached_(false)
{
- for (int i = 0; i < 3; ++i)
- Parent::add(f.vertex(i));
- VertexSet::const_iterator v = static_cast<const Parent*>(this)->vertices().begin();
- Point p1 = (*v++)->point();
- Point p2 = (*v++)->point();
- Point p3 = (*v)->point();
- alpha_ = CGAL::squared_radius(p1, p2, p3);
+ for (int i = 0; i < 3; ++i)
+ Parent::add(f.vertex(i));
+ VertexSet::const_iterator v = static_cast<const Parent*>(this)->vertices().begin();
+ Point p1 = (*v++)->point();
+ Point p2 = (*v++)->point();
+ Point p3 = (*v)->point();
+ alpha_ = CGAL::squared_radius(p1, p2, p3);
}
-bool
+bool
AlphaSimplex2D::AlphaOrder::
operator()(const AlphaSimplex2D& first, const AlphaSimplex2D& second) const
{
- if (first.alpha() == second.alpha())
- return (first.dimension() < second.dimension());
- else
- return (first.alpha() < second.alpha());
+ if (first.alpha() == second.alpha())
+ return (first.dimension() < second.dimension());
+ else
+ return (first.alpha() < second.alpha());
}
-std::ostream&
+std::ostream&
AlphaSimplex2D::
operator<<(std::ostream& out) const
{
- for (VertexSet::const_iterator cur = Parent::vertices().begin();
- cur != Parent::vertices().end(); ++cur)
- out << **cur << ", ";
- out << "value = " << value();
+ for (VertexSet::const_iterator cur = Parent::vertices().begin();
+ cur != Parent::vertices().end(); ++cur)
+ out << **cur << ", ";
+ out << "value = " << value();
- return out;
+ return out;
}
void fill_simplex_set(const Delaunay2D& Dt, AlphaSimplex2D::SimplexSet& simplices)
{
- for(Face_iterator cur = Dt.finite_faces_begin(); cur != Dt.finite_faces_end(); ++cur)
- simplices.insert(AlphaSimplex2D(*cur));
- rInfo("Faces inserted");
- for(Edge_iterator cur = Dt.finite_edges_begin(); cur != Dt.finite_edges_end(); ++cur)
- simplices.insert(AlphaSimplex2D(*cur, simplices, Dt));
- rInfo("Edges inserted");
- for(Vertex_iterator cur = Dt.finite_vertices_begin(); cur != Dt.finite_vertices_end(); ++cur)
- simplices.insert(AlphaSimplex2D(*cur));
- rInfo("Vertices inserted");
+ for(Face_iterator cur = Dt.finite_faces_begin(); cur != Dt.finite_faces_end(); ++cur)
+ simplices.insert(AlphaSimplex2D(*cur));
+ rInfo("Faces inserted");
+ for(Edge_iterator cur = Dt.finite_edges_begin(); cur != Dt.finite_edges_end(); ++cur)
+ simplices.insert(AlphaSimplex2D(*cur, simplices, Dt));
+ rInfo("Edges inserted");
+ for(Vertex_iterator cur = Dt.finite_vertices_begin(); cur != Dt.finite_vertices_end(); ++cur)
+ simplices.insert(AlphaSimplex2D(*cur));
+ rInfo("Vertices inserted");
}
template<class Filtration>
void fill_complex(const Delaunay2D& Dt, Filtration& filtration)
{
- // Compute all simplices with their alpha values and attachment information
+ // Compute all simplices with their alpha values and attachment information
// TODO: this can be optimized; the new Filtration can act as a SimplexSet
- AlphaSimplex2D::SimplexSet simplices;
+ AlphaSimplex2D::SimplexSet simplices;
fill_simplex_set(Dt, simplices);
BOOST_FOREACH(const AlphaSimplex2D& s, simplices)
filtration.push_back(s);
--- a/examples/alphashapes/alphashapes3d.hpp Fri Oct 26 11:45:58 2012 -0700
+++ b/examples/alphashapes/alphashapes3d.hpp Thu Feb 28 11:12:02 2013 +0800
@@ -1,169 +1,169 @@
#include <utilities/log.h>
#include <boost/foreach.hpp>
-AlphaSimplex3D::
+AlphaSimplex3D::
AlphaSimplex3D(const Delaunay3D::Vertex& v): alpha_(0), attached_(false)
{
- for (int i = 0; i < 4; ++i)
- if (v.cell()->vertex(i)->point() == v.point())
- Parent::add(v.cell()->vertex(i));
+ for (int i = 0; i < 4; ++i)
+ if (v.cell()->vertex(i)->point() == v.point())
+ Parent::add(v.cell()->vertex(i));
}
-AlphaSimplex3D::
+AlphaSimplex3D::
AlphaSimplex3D(const Delaunay3D::Edge& e)
{
Cell_handle c = e.first;
- Parent::add(c->vertex(e.second));
- Parent::add(c->vertex(e.third));
+ Parent::add(c->vertex(e.second));
+ Parent::add(c->vertex(e.third));
}
-AlphaSimplex3D::
+AlphaSimplex3D::
AlphaSimplex3D(const Delaunay3D::Edge& e, const SimplexSet& simplices, const Delaunay3D& Dt, Facet_circulator facet_bg)
{
Cell_handle c = e.first;
- Parent::add(c->vertex(e.second));
- Parent::add(c->vertex(e.third));
+ Parent::add(c->vertex(e.second));
+ Parent::add(c->vertex(e.third));
- Facet_circulator cur = facet_bg;
- while (Dt.is_infinite(*cur)) ++cur;
- SimplexSet::const_iterator cur_iter = simplices.find(AlphaSimplex3D(*cur));
- RealValue min = cur_iter->alpha();
-
+ Facet_circulator cur = facet_bg;
+ while (Dt.is_infinite(*cur)) ++cur;
+ SimplexSet::const_iterator cur_iter = simplices.find(AlphaSimplex3D(*cur));
+ RealValue min = cur_iter->alpha();
+
const VertexSet& vertices = static_cast<const Parent*>(this)->vertices();
- VertexSet::const_iterator v = vertices.begin();
- const Point& p1 = (*v++)->point();
- const Point& p2 = (*v)->point();
- attached_ = false;
+ VertexSet::const_iterator v = vertices.begin();
+ const Point& p1 = (*v++)->point();
+ const Point& p2 = (*v)->point();
+ attached_ = false;
- if (facet_bg != 0) do
- {
- VertexSet::const_iterator v = vertices.begin();
- int i0 = (*cur).first->index(*v++);
- int i1 = (*cur).first->index(*v);
- int i = 6 - i0 - i1 - (*cur).second;
+ if (facet_bg != 0) do
+ {
+ VertexSet::const_iterator v = vertices.begin();
+ int i0 = (*cur).first->index(*v++);
+ int i1 = (*cur).first->index(*v);
+ int i = 6 - i0 - i1 - (*cur).second;
if (Dt.is_infinite(cur->first->vertex(i))) { ++cur; continue; }
- Point p3 = (*cur).first->vertex(i)->point();
+ Point p3 = (*cur).first->vertex(i)->point();
- cur_iter = simplices.find(AlphaSimplex3D(*cur));
- if (CGAL::side_of_bounded_sphere(p1, p2, p3) == CGAL::ON_BOUNDED_SIDE)
- attached_ = true;
- RealValue val = cur_iter->alpha();
- if (val < min)
- min = val;
- ++cur;
- } while (cur != facet_bg);
+ cur_iter = simplices.find(AlphaSimplex3D(*cur));
+ if (CGAL::side_of_bounded_sphere(p1, p2, p3) == CGAL::ON_BOUNDED_SIDE)
+ attached_ = true;
+ RealValue val = cur_iter->alpha();
+ if (val < min)
+ min = val;
+ ++cur;
+ } while (cur != facet_bg);
- if (attached_)
- alpha_ = min;
- else
- alpha_ = CGAL::squared_radius(p1, p2);
+ if (attached_)
+ alpha_ = min;
+ else
+ alpha_ = CGAL::squared_radius(p1, p2);
}
-AlphaSimplex3D::
+AlphaSimplex3D::
AlphaSimplex3D(const Delaunay3D::Facet& f)
{
Cell_handle c = f.first;
- for (int i = 0; i < 4; ++i)
- if (i != f.second)
- Parent::add(c->vertex(i));
+ for (int i = 0; i < 4; ++i)
+ if (i != f.second)
+ Parent::add(c->vertex(i));
}
-AlphaSimplex3D::
+AlphaSimplex3D::
AlphaSimplex3D(const Delaunay3D::Facet& f, const SimplexSet& simplices, const Delaunay3D& Dt)
{
Cell_handle c = f.first;
- for (int i = 0; i < 4; ++i)
- if (i != f.second)
- Parent::add(c->vertex(i));
+ for (int i = 0; i < 4; ++i)
+ if (i != f.second)
+ Parent::add(c->vertex(i));
- Cell_handle o = c->neighbor(f.second);
- int oi = o->index(c);
+ Cell_handle o = c->neighbor(f.second);
+ int oi = o->index(c);
- VertexSet::const_iterator v = static_cast<const Parent*>(this)->vertices().begin();
- const Point& p1 = (*v++)->point();
- const Point& p2 = (*v++)->point();
- const Point& p3 = (*v)->point();
-
- attached_ = false;
- if (!Dt.is_infinite(c->vertex(f.second)) &&
+ VertexSet::const_iterator v = static_cast<const Parent*>(this)->vertices().begin();
+ const Point& p1 = (*v++)->point();
+ const Point& p2 = (*v++)->point();
+ const Point& p3 = (*v)->point();
+
+ attached_ = false;
+ if (!Dt.is_infinite(c->vertex(f.second)) &&
CGAL::side_of_bounded_sphere(p1, p2, p3,
- c->vertex(f.second)->point()) == CGAL::ON_BOUNDED_SIDE)
- attached_ = true;
- else if (!Dt.is_infinite(o->vertex(oi)) &&
+ c->vertex(f.second)->point()) == CGAL::ON_BOUNDED_SIDE)
+ attached_ = true;
+ else if (!Dt.is_infinite(o->vertex(oi)) &&
CGAL::side_of_bounded_sphere(p1, p2, p3,
- o->vertex(oi)->point()) == CGAL::ON_BOUNDED_SIDE)
- attached_ = true;
- else
- alpha_ = squared_radius(p1, p2, p3);
-
- if (attached_)
- {
- if (Dt.is_infinite(c))
- alpha_ = simplices.find(AlphaSimplex3D(*o))->alpha();
- else if (Dt.is_infinite(o))
- alpha_ = simplices.find(AlphaSimplex3D(*c))->alpha();
- else
- alpha_ = std::min(simplices.find(AlphaSimplex3D(*c))->alpha(),
+ o->vertex(oi)->point()) == CGAL::ON_BOUNDED_SIDE)
+ attached_ = true;
+ else
+ alpha_ = CGAL::squared_radius(p1, p2, p3);
+
+ if (attached_)
+ {
+ if (Dt.is_infinite(c))
+ alpha_ = simplices.find(AlphaSimplex3D(*o))->alpha();
+ else if (Dt.is_infinite(o))
+ alpha_ = simplices.find(AlphaSimplex3D(*c))->alpha();
+ else
+ alpha_ = std::min(simplices.find(AlphaSimplex3D(*c))->alpha(),
simplices.find(AlphaSimplex3D(*o))->alpha());
- }
+ }
}
-AlphaSimplex3D::
+AlphaSimplex3D::
AlphaSimplex3D(const Delaunay3D::Cell& c): attached_(false)
{
- for (int i = 0; i < 4; ++i)
- Parent::add(c.vertex(i));
- VertexSet::const_iterator v = static_cast<const Parent*>(this)->vertices().begin();
- Point p1 = (*v++)->point();
- Point p2 = (*v++)->point();
- Point p3 = (*v++)->point();
- Point p4 = (*v)->point();
- alpha_ = CGAL::squared_radius(p1, p2, p3, p4);
+ for (int i = 0; i < 4; ++i)
+ Parent::add(c.vertex(i));
+ VertexSet::const_iterator v = static_cast<const Parent*>(this)->vertices().begin();
+ Point p1 = (*v++)->point();
+ Point p2 = (*v++)->point();
+ Point p3 = (*v++)->point();
+ Point p4 = (*v)->point();
+ alpha_ = CGAL::squared_radius(p1, p2, p3, p4);
}
-bool
+bool
AlphaSimplex3D::AlphaOrder::
operator()(const AlphaSimplex3D& first, const AlphaSimplex3D& second) const
{
- if (first.alpha() == second.alpha())
- return (first.dimension() < second.dimension());
- else
- return (first.alpha() < second.alpha());
+ if (first.alpha() == second.alpha())
+ return (first.dimension() < second.dimension());
+ else
+ return (first.alpha() < second.alpha());
}
-std::ostream&
+std::ostream&
AlphaSimplex3D::
operator<<(std::ostream& out) const
{
- for (VertexSet::const_iterator cur = Parent::vertices().begin(); cur != Parent::vertices().end(); ++cur)
- out << **cur << ", ";
- out << "value = " << value();
+ for (VertexSet::const_iterator cur = Parent::vertices().begin(); cur != Parent::vertices().end(); ++cur)
+ out << **cur << ", ";
+ out << "value = " << value();
- return out;
+ return out;
}
void fill_simplex_set(const Delaunay3D& Dt, AlphaSimplex3D::SimplexSet& simplices)
{
- // Compute all simplices with their alpha values and attachment information
- for(Cell_iterator cur = Dt.finite_cells_begin(); cur != Dt.finite_cells_end(); ++cur)
- simplices.insert(AlphaSimplex3D(*cur));
- rInfo("Cells inserted");
- for(Facet_iterator cur = Dt.finite_facets_begin(); cur != Dt.finite_facets_end(); ++cur)
- simplices.insert(AlphaSimplex3D(*cur, simplices, Dt));
- rInfo("Facets inserted");
- for(Edge_iterator cur = Dt.finite_edges_begin(); cur != Dt.finite_edges_end(); ++cur)
- simplices.insert(AlphaSimplex3D(*cur, simplices, Dt, Dt.incident_facets(*cur)));
- rInfo("Edges inserted");
- for(Vertex_iterator cur = Dt.finite_vertices_begin(); cur != Dt.finite_vertices_end(); ++cur)
- simplices.insert(AlphaSimplex3D(*cur));
- rInfo("Vertices inserted");
+ // Compute all simplices with their alpha values and attachment information
+ for(Cell_iterator cur = Dt.finite_cells_begin(); cur != Dt.finite_cells_end(); ++cur)
+ simplices.insert(AlphaSimplex3D(*cur));
+ rInfo("Cells inserted");
+ for(Facet_iterator cur = Dt.finite_facets_begin(); cur != Dt.finite_facets_end(); ++cur)
+ simplices.insert(AlphaSimplex3D(*cur, simplices, Dt));
+ rInfo("Facets inserted");
+ for(Edge_iterator cur = Dt.finite_edges_begin(); cur != Dt.finite_edges_end(); ++cur)
+ simplices.insert(AlphaSimplex3D(*cur, simplices, Dt, Dt.incident_facets(*cur)));
+ rInfo("Edges inserted");
+ for(Vertex_iterator cur = Dt.finite_vertices_begin(); cur != Dt.finite_vertices_end(); ++cur)
+ simplices.insert(AlphaSimplex3D(*cur));
+ rInfo("Vertices inserted");
}
template<class Filtration>
void fill_complex(const Delaunay3D& Dt, Filtration& filtration)
{
- AlphaSimplex3D::SimplexSet simplices;
+ AlphaSimplex3D::SimplexSet simplices;
fill_simplex_set(Dt, simplices);
BOOST_FOREACH(const AlphaSimplex3D& s, simplices)
filtration.push_back(s);
--- a/include/geometry/kinetic-sort.h Fri Oct 26 11:45:58 2012 -0700
+++ b/include/geometry/kinetic-sort.h Thu Feb 28 11:12:02 2013 +0800
@@ -7,19 +7,19 @@
#include <iostream>
/**
- * Maintains elements of the given data structure in the sorted order assuming the elements follow
+ * Maintains elements of the given data structure in the sorted order assuming the elements follow
* trajectories given by TrajectoryExtractor_.
*
* \arg ElementIterator_ iterator over the underlying data structure that's kept in sorted order
- * \arg TrajectoryExtractor_ applied to the iterator into SortDS_ should return a function
+ * \arg TrajectoryExtractor_ applied to the iterator into SortDS_ should return a function
* (of type Simulator_::FunctionKernel::Function) describing the trajectory of the element
- * \arg Simulator_ the Simulator type, e.g. Simulator. Note that KineticSort does not store
+ * \arg Simulator_ the Simulator type, e.g. Simulator. Note that KineticSort does not store
* a pointer to the Simulator (so a pointer is passed in each relevant operation)
* \arg Swap_ is called with an ElementIterator_ when a swap needs to be performed
*
* \ingroup kinetic
*/
-template<class ElementIterator_, class TrajectoryExtractor_,
+template<class ElementIterator_, class TrajectoryExtractor_,
class Simulator_, class Swap_ = boost::function<void(ElementIterator_ pos, Simulator_* simulator)> >
class KineticSort
{
@@ -29,18 +29,18 @@
typedef ElementIterator_ ElementIterator;
typedef Swap_ Swap;
typedef TrajectoryExtractor_ TrajectoryExtractor;
-
+
typedef typename Simulator::Key SimulatorKey;
-
+
private:
/* Implementation */
struct Node
{
ElementIterator element;
- SimulatorKey swap_event_key;
+ SimulatorKey swap_event_key;
- Node(ElementIterator e, SimulatorKey k):
+ Node(ElementIterator e, SimulatorKey k):
element(e), swap_event_key(k) {}
};
@@ -53,7 +53,7 @@
/// \name Core Functionality
/// @{
KineticSort();
- KineticSort(ElementIterator b, ElementIterator e, Swap swap, Simulator* simulator, const TrajectoryExtractor& te);
+ KineticSort(ElementIterator b, ElementIterator e, Swap swap, Simulator* simulator, const TrajectoryExtractor& te = TrajectoryExtractor());
void initialize(ElementIterator b, ElementIterator e, Swap swap, Simulator* simulator);
void insert(iterator pos, ElementIterator f, ElementIterator l, Simulator* simulator);
@@ -77,7 +77,7 @@
private:
NodeList list_;
- Swap swap_;
+ Swap swap_;
TrajectoryExtractor te_;
};
--- a/include/geometry/kinetic-sort.hpp Fri Oct 26 11:45:58 2012 -0700
+++ b/include/geometry/kinetic-sort.hpp Thu Feb 28 11:12:02 2013 +0800
@@ -21,7 +21,7 @@
template<class ElementIterator_, class TrajectoryExtractor_, class Simulator_, class Swap_>
KineticSort<ElementIterator_, TrajectoryExtractor_, Simulator_, Swap_>::
-KineticSort(ElementIterator b, ElementIterator e, Swap swap, Simulator* simulator, const TrajectoryExtractor& te = TrajectoryExtractor()):
+KineticSort(ElementIterator b, ElementIterator e, Swap swap, Simulator* simulator, const TrajectoryExtractor& te):
te_(te)
{
initialize(b, e, swap, simulator);
--- a/include/geometry/simulator.h Fri Oct 26 11:45:58 2012 -0700
+++ b/include/geometry/simulator.h Thu Feb 28 11:12:02 2013 +0800
@@ -7,10 +7,10 @@
#include <limits>
/**
- * Simulator class. Keeps a queue of events. Infinity is reached if the Event
- * at the front of the queue has an empty root stack. Keeps track of current time,
- * Event addition, and processes events one by one. Degeneracies are handled by
- * assuming that the FunctionKernel::Function responsible for the event must be
+ * Simulator class. Keeps a queue of events. Infinity is reached if the Event
+ * at the front of the queue has an empty root stack. Keeps track of current time,
+ * Event addition, and processes events one by one. Degeneracies are handled by
+ * assuming that the FunctionKernel::Function responsible for the event must be
* positive before the Event occurs.
*
* \ingroup kinetic
@@ -39,21 +39,21 @@
~Simulator() { for (Key cur = queue_.top(); cur != queue_.end(); ++cur) delete *cur; }
- template<class Event_>
+ template<class Event_>
Key add(const Event_& e);
- template<class Event_>
+ template<class Event_>
Key add(const Function& f, const Event_& e);
void process();
- void update(Key k, const Function& f);
-
+ //void update(Key k, const Function& f);
+
void remove(Key k) { Event* e = *k; queue_.remove(k); delete e; }
Key null_key() { return queue_.end(); }
Time current_time() const { return current_; }
Time audit_time() const;
bool reached_infinity() const { return queue_.empty() || (*queue_.top())->root_stack().empty(); }
- Time next_event_time() const { return queue_.empty() ? std::numeric_limits<Time>::infinity():(*queue_.top())->root_stack().top(); }
-
+ Time next_event_time() const { return queue_.empty() ? std::numeric_limits<Time>::infinity():(*queue_.top())->root_stack().top(); }
+
Event* top() const { return *(queue_.top()); }
unsigned size() const { return queue_.size(); }
unsigned event_count() const { return count_; }
@@ -68,8 +68,8 @@
/**
- * Base class for events. Stores a root stack, subclasses need to define process().
- * Event with an empty root stack compares greater than any other Event,
+ * Base class for events. Stores a root stack, subclasses need to define process().
+ * Event with an empty root stack compares greater than any other Event,
* pushing those events to the end of the queue.
*/
template<class FuncKernel_, template<class Event> class EventComparison_>
@@ -79,17 +79,18 @@
typedef FuncKernel_ FunctionKernel;
typedef typename FunctionKernel::RootStack RootStack;
- /// process() is called when the event is at the top of the queue
+ virtual ~Event() {}
+
+ /// process() is called when the event is at the top of the queue
/// in the simulator.
- /// Returns true if the event needs to remain in the Simulator
+ /// Returns true if the event needs to remain in the Simulator
/// (top of the root_stack() will be used for new time).
virtual bool process(Simulator* s) const =0;
-
RootStack& root_stack() { return root_stack_; }
const RootStack& root_stack() const { return root_stack_; }
- bool operator<(const Event& e) const
- {
+ bool operator<(const Event& e) const
+ {
if (root_stack().empty())
return false;
else if (e.root_stack().empty())
@@ -98,9 +99,9 @@
return root_stack().top() < e.root_stack().top();
}
- virtual std::ostream& operator<<(std::ostream& out) const
- {
- out << "Event with " << root_stack_.size() << " roots";
+ virtual std::ostream& operator<<(std::ostream& out) const
+ {
+ out << "Event with " << root_stack_.size() << " roots";
if (!root_stack_.empty()) out << "; top root: " << root_stack_.top();
out << ", ";
return out;
@@ -111,13 +112,13 @@
};
/**
- * Compares elements pointed at by its arguments using the provided Comparison_
+ * Compares elements pointed at by its arguments using the provided Comparison_
* (which must not take any arguments during construction).
*/
template<class FuncKernel_, template<class Event> class EventComparison_>
-class Simulator<FuncKernel_, EventComparison_>::IndirectEventComparison:
- public std::binary_function<const typename EventComparison::first_argument_type*,
- const typename EventComparison::second_argument_type*,
+class Simulator<FuncKernel_, EventComparison_>::IndirectEventComparison:
+ public std::binary_function<const typename EventComparison::first_argument_type*,
+ const typename EventComparison::second_argument_type*,
bool>
{
public:
--- a/include/geometry/simulator.hpp Fri Oct 26 11:45:58 2012 -0700
+++ b/include/geometry/simulator.hpp Thu Feb 28 11:12:02 2013 +0800
@@ -17,8 +17,8 @@
Simulator<FuncKernel_, EventComparison_>::
add(const Event_& e)
{
- Event* ee = new Event_(e);
- return queue_.push(ee);
+ Event* ee = new Event_(e);
+ return queue_.push(ee);
}
template<class FuncKernel_, template<class Event> class EventComparison_>
@@ -27,58 +27,58 @@
Simulator<FuncKernel_, EventComparison_>::
add(const Function& f, const Event_& e)
{
- Event* ee = new Event_(e);
- rLog(rlSimulator, "Solving: %s", tostring(f).c_str());
- int sign = FunctionKernel::sign_at_negative_infinity(f); // going to be sign after current time
+ Event* ee = new Event_(e);
+ rLog(rlSimulator, "Solving: %s", tostring(f).c_str());
+ int sign = FunctionKernel::sign_at_negative_infinity(f); // going to be sign after current time
rLog(rlSimulator, "Sign at -infinity: %i", sign);
if (sign != 0)
{
- FunctionKernel::solve(f, ee->root_stack());
+ FunctionKernel::solve(f, ee->root_stack());
rLog(rlSimulator, "Got solution with root stack size: %i", ee->root_stack().size());
}
- while (!ee->root_stack().empty() && ee->root_stack().top() < current_time())
- {
+ while (!ee->root_stack().empty() && ee->root_stack().top() < current_time())
+ {
// rLog(rlSimulator, "Popping expired root: %f", ee->root_stack().top());
- ee->root_stack().pop();
- sign *= -1;
- }
+ ee->root_stack().pop();
+ sign *= -1;
+ }
if (sign == -1)
{
rLog(rlSimulator, "Popping the root because of negative sign (degeneracy)");
// rLog(rlSimulator, "Popping the root because of negative sign (degeneracy): %f", ee->root_stack().top());
// rLog(rlSimulator, " Current time: %f", current_time());
- // AssertMsg(ee->root_stack().top() == current_time(),
+ // AssertMsg(ee->root_stack().top() == current_time(),
// "If sign is negative, we must be in the degenerate case");
ee->root_stack().pop();
}
- if (ee->root_stack().empty())
+ if (ee->root_stack().empty())
rLog(rlSimulator, "Pushing event with empty root stack");
else
{
rLog(rlSimulator, "Root stack size: %i", ee->root_stack().size());
rLog(rlSimulator, "Pushing: %s", tostring(ee->root_stack().top()).c_str());
}
- Key k = queue_.push(ee);
+ Key k = queue_.push(ee);
return k;
}
-
-template<class FuncKernel_, template<class Event> class EventComparison_>
-void
-Simulator<FuncKernel_, EventComparison_>::
-update(Key k, const Function& f)
-{
- Event* ee = *k;
- Event* e = new Event;
- e->root_stack() = RootStack(); // no clear() in std::stack
- FunctionKernel::solve(f, e->root_stack());
- while (!e->root_stack().empty() && e->root_stack().top() < current_time())
- e->root_stack().pop();
- queue_.replace(k, e);
- delete ee;
-}
+
+//template<class FuncKernel_, template<class Event> class EventComparison_>
+//void
+//Simulator<FuncKernel_, EventComparison_>::
+//update(Key k, const Function& f)
+//{
+// Event* ee = *k;
+// Event* e = new Event;
+// e->root_stack() = RootStack(); // no clear() in std::stack
+// FunctionKernel::solve(f, e->root_stack());
+// while (!e->root_stack().empty() && e->root_stack().top() < current_time())
+// e->root_stack().pop();
+// queue_.replace(k, e);
+// delete ee;
+//}
template<class FuncKernel_, template<class Event> class EventComparison_>
void
@@ -87,30 +87,30 @@
{
Count(cSimulatorProcess);
if (reached_infinity()) return;
- rLog(rlSimulator, "Queue size: %i", queue_.size());
- Key top = queue_.top();
- Event* e = *top;
+ rLog(rlSimulator, "Queue size: %i", queue_.size());
+ Key top = queue_.top();
+ Event* e = *top;
rLog(rlSimulator, "Processing event: %s", intostring(*e).c_str());
-
- current_ = e->root_stack().top(); e->root_stack().pop();
+
+ current_ = e->root_stack().top(); e->root_stack().pop();
queue_.demoted(top);
// Get the top element out of the queue, put it back depending on what process() says
- if (!(e->process(this))) { queue_.remove(top); delete e; }
+ if (!(e->process(this))) { queue_.remove(top); delete e; }
++count_;
}
-
+
template<class FuncKernel_, template<class Event> class EventComparison_>
typename Simulator<FuncKernel_, EventComparison_>::Time
Simulator<FuncKernel_, EventComparison_>::
audit_time() const
{
- const_Key top = queue_.top();
- Event* e = *top;
+ const_Key top = queue_.top();
+ Event* e = *top;
- if (e->root_stack().empty()) return current_ + 1;
- else return FunctionKernel::between(e->root_stack().top(), current_);
+ if (e->root_stack().empty()) return current_ + 1;
+ else return FunctionKernel::between(e->root_stack().top(), current_);
}
template<class FuncKernel_, template<class Event> class EventComparison_>
@@ -118,8 +118,8 @@
Simulator<FuncKernel_, EventComparison_>::
operator<<(std::ostream& out) const
{
- out << "Simulator: " << std::endl;
- return queue_.print(out, " ");
+ out << "Simulator: " << std::endl;
+ return queue_.print(out, " ");
}
template<class FuncKernel_, template<class Event> class EventComparison_>
--- a/include/topology/dynamic-persistence.h Fri Oct 26 11:45:58 2012 -0700
+++ b/include/topology/dynamic-persistence.h Thu Feb 28 11:12:02 2013 +0800
@@ -25,7 +25,7 @@
typedef typename Parent::Cycle Cycle;
typedef typename Parent::Chain Chain;
typedef Chain Trail;
-
+
// Modifiers
template<class Cmp>
void trail_append(Index i, const Cmp& cmp) { trail.append(i, cmp); }
@@ -41,20 +41,20 @@
/**
* Class: DynamicPersistenceTrails
- * Derives from StaticPersistence and allows one to update persistence
- * after a transposition of two contiguous simplices in a filtration.
+ * Derives from StaticPersistence and allows one to update persistence
+ * after a transposition of two contiguous simplices in a filtration.
* In addition to reduced cycles, it stores each OrderElement's trails,
* i.e. in addition to matrix R, it stores matrix U in vineyard notation.
*
* Template parameters:
* Data_ - auxilliary contents to store with each OrderElement
- * OrderDescriptor_ - class describing how the order is stored; it defaults to <VectorOrderDescriptor>
+ * OrderDescriptor_ - class describing how the order is stored; it defaults to <VectorOrderDescriptor>
* which serves as a prototypical class
*/
-// TODO: perhaps Consistency should be wrapped into a ConsistencyDescriptor that somehow knows how to initialize it.
-// That way one could provide a simple consistency descriptor that just stored some integers describing the original
+// TODO: perhaps Consistency should be wrapped into a ConsistencyDescriptor that somehow knows how to initialize it.
+// That way one could provide a simple consistency descriptor that just stored some integers describing the original
// position, or one could provide consistency that is references into the complex
-template<class Data_ = Empty<>,
+template<class Data_ = Empty<>,
class ChainTraits_ = VectorChains<>,
class ContainerTraits_ = OrderConsistencyContainer<>,
class Element_ = TrailData<Data_, ChainTraits_>,
@@ -63,7 +63,7 @@
class ConsistencyComparison_ = ElementComparison<typename ContainerTraits_::template rebind<Element_>::other::ConsistentContainer,
std::greater<typename ContainerTraits_::template rebind<Element_>::other::ConsistentContainer::iterator> >
>
-class DynamicPersistenceTrails:
+class DynamicPersistenceTrails:
public StaticPersistence<Data_, ChainTraits_, ContainerTraits_, Element_, Comparison_>
{
public:
@@ -71,7 +71,7 @@
typedef Element_ Element;
typedef StaticPersistence<Data_, ChainTraits_,
ContainerTraits_, Element_, Comparison_> Parent;
-
+
typedef typename Parent::ContainerTraits Traits;
typedef typename Parent::Order Order;
typedef typename Traits::ConsistentContainer Consistency;
@@ -94,18 +94,18 @@
* Filtration - filtration of the complex whose persistence we are computing
*/
template<class Filtration> DynamicPersistenceTrails(const Filtration& f);
-
+
template<class Filtration>
void initialize(const Filtration& f) { Parent::initialize(f); }
void pair_simplices();
// Function: transpose(i)
- // Tranpose i and the next element.
+ // Tranpose i and the next element.
// Returns: true iff the pairing switched.
template<class DimensionFunctor, class Visitor>
bool transpose(iterator i, const DimensionFunctor& dimension, Visitor visitor = Visitor());
-
+
template<class DimensionFunctor>
bool transpose(iterator i, const DimensionFunctor& dimension) { return transpose(i,dimension,TranspositionVisitor()); }
@@ -125,14 +125,14 @@
struct TranspositionVisitor
{
// Function: transpose(i)
- // This function is called before transposition is processed
- // (at the very beginning of <transpose(i, visitor)>). It is meant to update any structures
+ // This function is called before transposition is processed
+ // (at the very beginning of <transpose(i, visitor)>). It is meant to update any structures
// that may need to be updated, but perhaps it has other uses as well.
void transpose(iterator i) const {}
// Function: switched(i, type)
// This function is called after the transposition if the switch in pairing has occured.
- // `i` is the index of the preceding simplex after the transposition.
+ // `i` is the index of the preceding simplex after the transposition.
// `type` indicates the <SwitchType>.
void switched(iterator i, SwitchType type) const {}
};
@@ -142,8 +142,8 @@
using Parent::set_pair;
using Parent::swap_cycle;
- Consistency& consistent_order() { return order().get<consistency>(); }
- const Consistency& consistent_order() const { return order().get<consistency>(); }
+ Consistency& consistent_order() { return order().template get<consistency>(); }
+ const Consistency& consistent_order() const { return order().template get<consistency>(); }
bool trail_remove_if_contains
(iterator i, OrderIndex j) { TrailRemover rm(j); order().modify(i, rm); return rm.result; }
@@ -154,16 +154,16 @@
void swap(iterator i, iterator j);
void pairing_switch(iterator i, iterator j);
- struct PairingTrailsVisitor: public Parent::PairVisitor
+ struct PairingTrailsVisitor: public Parent::PairVisitor
{
- PairingTrailsVisitor(Order& order, ConsistencyComparison ccmp, unsigned size):
+ PairingTrailsVisitor(Order& order, ConsistencyComparison ccmp, unsigned size):
Parent::PairVisitor(size), order_(order), ccmp_(ccmp) {}
void init(iterator i) const { order_.modify(i, boost::bind(&Element::template trail_append<ConsistencyComparison>, bl::_1, &*i, ccmp_)); Count(cTrailLength); } // i->trail_append(&*i, ccmp)
void update(iterator j, iterator i) const { order_.modify(order_.iterator_to(*(i->pair)), boost::bind(&Element::template trail_append<ConsistencyComparison>, bl::_1, &*j, ccmp_)); Count(cTrailLength); } // i->pair->trail_append(&*j, ccmp)
void finished(iterator i) const { Parent::PairVisitor::finished(i); }
- Order& order_;
+ Order& order_;
ConsistencyComparison ccmp_;
};
@@ -185,7 +185,7 @@
typedef typename Parent::Cycle Cycle;
typedef typename Parent::Chain Chain;
typedef Chain Trail;
-
+
// Modifiers
template<class Cmp>
void chain_append(Index i, const Cmp& cmp) { chain.append(i, cmp); }
@@ -203,17 +203,17 @@
* Class: DynamicPersistenceChains
*
* TODO: below comment is incorrect; nothing dynamic about this yet.
- * Derives from StaticPersistence and allows one to update persistence
- * after a transposition of two contiguous simplices in a filtration.
+ * Derives from StaticPersistence and allows one to update persistence
+ * after a transposition of two contiguous simplices in a filtration.
* In addition to reduced cycles, it stores each OrderElement's chains,
* i.e. in addition to matrix R, it stores matrix V in vineyard notation.
*
* Template parameters:
* Data_ - auxilliary contents to store with each OrderElement
- * OrderDescriptor_ - class describing how the order is stored; it defaults to <VectorOrderDescriptor>
+ * OrderDescriptor_ - class describing how the order is stored; it defaults to <VectorOrderDescriptor>
* which serves as a prototypical class
*/
-template<class Data_ = Empty<>,
+template<class Data_ = Empty<>,
class ChainTraits_ = VectorChains<>,
class ContainerTraits_ = OrderConsistencyContainer<>,
class Element_ = ChainData<Data_, ChainTraits_>,
@@ -222,7 +222,7 @@
class ConsistencyComparison_ = ElementComparison<typename ContainerTraits_::template rebind<Element_>::other::ConsistentContainer,
std::greater<typename ContainerTraits_::template rebind<Element_>::other::ConsistentContainer::iterator> >
>
-class DynamicPersistenceChains:
+class DynamicPersistenceChains:
public StaticPersistence<Data_, ChainTraits_, ContainerTraits_, Element_, Comparison_>
{
public:
@@ -230,7 +230,7 @@
typedef Element_ Element;
typedef StaticPersistence<Data_, ChainTraits_,
ContainerTraits_, Element_, Comparison_> Parent;
-
+
typedef typename Parent::ContainerTraits Traits;
typedef typename Parent::Order Order;
@@ -253,21 +253,21 @@
* Filtration - filtration of the complex whose persistence we are computing
*/
template<class Filtration> DynamicPersistenceChains(const Filtration& f);
-
+
template<class Filtration>
void initialize(const Filtration& f) { Parent::initialize(f); }
void pair_simplices();
// Function: transpose(i)
- // Tranpose i and the next element.
+ // Tranpose i and the next element.
// Returns: true iff the pairing switched.
// TODO
//bool transpose(OrderIndex i) { return transpose(i, TranspositionVisitor()); }
-
+
// TODO: the main missing piece to be dynamic
//template<class Visitor>
//bool transpose(OrderIndex i, Visitor& visitor = Visitor());
-
+
using Parent::begin;
using Parent::end;
using Parent::iterator_to;
@@ -280,14 +280,14 @@
struct TranspositionVisitor
{
// Function: transpose(i)
- // This function is called before transposition is processed
- // (at the very beginning of <transpose(i, visitor)>). It is meant to update any structures
+ // This function is called before transposition is processed
+ // (at the very beginning of <transpose(i, visitor)>). It is meant to update any structures
// that may need to be updated, but perhaps it has other uses as well.
void transpose(iterator i) const {}
// Function: switched(i, type)
// This function is called after the transposition if the switch in pairing has occured.
- // `i` is the index of the preceding simplex after the transposition.
+ // `i` is the index of the preceding simplex after the transposition.
// `type` indicates the <SwitchType>.
void switched(iterator i, SwitchType type) const {}
};
@@ -304,16 +304,16 @@
void swap(OrderIndex i, OrderIndex j);
void pairing_switch(OrderIndex i, OrderIndex j);
- struct PairingChainsVisitor: public Parent::PairVisitor
+ struct PairingChainsVisitor: public Parent::PairVisitor
{
- PairingChainsVisitor(Order& order, ConsistencyComparison ccmp, unsigned size):
+ PairingChainsVisitor(Order& order, ConsistencyComparison ccmp, unsigned size):
Parent::PairVisitor(size), order_(order), ccmp_(ccmp) {}
void init(iterator i) const { order_.modify(i, boost::bind(&Element::template chain_append<ConsistencyComparison>, bl::_1, &*i, ccmp_)); } // i->chain_append(&*i, ccmp)
void update(iterator j, iterator i) const { order_.modify(j, boost::bind(&Element::template chain_add<ConsistencyComparison>, bl::_1, i->pair->chain, ccmp_)); } // j->chain.add(i->pair->chain, ccmp_)
void finished(iterator i) const { Parent::PairVisitor::finished(i); CountBy(cChainLength, i->chain.size()); }
- Order& order_;
+ Order& order_;
ConsistencyComparison ccmp_;
};
--- a/include/topology/dynamic-persistence.hpp Fri Oct 26 11:45:58 2012 -0700
+++ b/include/topology/dynamic-persistence.hpp Thu Feb 28 11:12:02 2013 +0800
@@ -298,14 +298,14 @@
template<class D, class CT, class OT, class E, class Cmp, class CCmp>
DynamicPersistenceChains<D,CT,OT,E,Cmp,CCmp>::
DynamicPersistenceChains():
- ccmp_(order().get<consistency>())
+ ccmp_(order().template get<consistency>())
{}
template<class D, class CT, class OT, class E, class Cmp, class CCmp>
template<class Filtration>
DynamicPersistenceChains<D,CT,OT,E,Cmp,CCmp>::
DynamicPersistenceChains(const Filtration& f):
- Parent(f), ccmp_(order().get<consistency>())
+ Parent(f), ccmp_(order().template get<consistency>())
{}
template<class D, class CT, class OT, class E, class Cmp, class CCmp>
--- a/include/topology/filtration.h Fri Oct 26 11:45:58 2012 -0700
+++ b/include/topology/filtration.h Thu Feb 28 11:12:02 2013 +0800
@@ -26,11 +26,11 @@
// Class: Filtration
//
-// Filtration keeps track of the ordering of the simplices in a complex.
+// Filtration keeps track of the ordering of the simplices in a complex.
// The most significant function it provides is <boundary()> which converts
// the boundary of a simplex at a given index into a list of indices.
template<class Simplex_,
- class SimplexOrderIndex_ = bmi::ordered_unique<bmi::identity<Simplex_>,
+ class SimplexOrderIndex_ = bmi::ordered_unique<bmi::identity<Simplex_>,
typename Simplex_::VertexComparison> >
class Filtration
{
@@ -42,9 +42,9 @@
typedef Simplex_ Simplex;
typedef SimplexOrderIndex_ SimplexOrderIndex;
- typedef b::multi_index_container<Simplex,
+ typedef b::multi_index_container<Simplex,
bmi::indexed_by<SimplexOrderIndex,
- bmi::random_access<bmi::tag<order> >
+ bmi::random_access<bmi::tag<order> >
>
> Container;
typedef typename Container::value_type value_type;
@@ -69,18 +69,18 @@
// Lookup
const Simplex& simplex(Index i) const { return *i; }
Index find(const Simplex& s) const { return bmi::project<order>(container_, container_.find(s)); }
-
+
// Modifiers
template<class Comparison>
- void sort(const Comparison& cmp = Comparison()) { container_.get<order>().sort(cmp); }
- void push_back(const Simplex& s) { container_.get<order>().push_back(s); }
- void transpose(Index i) { container_.get<order>().relocate(i, i+1); }
- void clear() { container_.get<order>().clear(); }
+ void sort(const Comparison& cmp = Comparison()) { container_.template get<order>().sort(cmp); }
+ void push_back(const Simplex& s) { container_.template get<order>().push_back(s); }
+ void transpose(Index i) { container_.template get<order>().relocate(i, i+1); }
+ void clear() { container_.template get<order>().clear(); }
template<class Iter>
- void rearrange(Iter i) { container_.get<order>().rearrange(i); }
+ void rearrange(Iter i) { container_.template get<order>().rearrange(i); }
- Index begin() const { return container_.get<order>().begin(); }
- Index end() const { return container_.get<order>().end(); }
+ Index begin() const { return container_.template get<order>().begin(); }
+ Index end() const { return container_.template get<order>().end(); }
size_t size() const { return container_.size(); }
std::ostream& operator<<(std::ostream& out) const { std::copy(begin(), end(), std::ostream_iterator<Simplex>(out, "\n")); return out; }
@@ -91,7 +91,7 @@
private:
// Serialization
friend class boost::serialization::access;
- template<class Archive>
+ template<class Archive>
void serialize(Archive& ar, const unsigned int)
{ ar & boost::serialization::make_nvp("order", container_); }
};
@@ -140,7 +140,7 @@
template<class key_type>
Dimension operator()(key_type i) const { return filtration_.simplex(map_[i]).dimension(); }
- private:
+ private:
const Map& map_;
const Filtration& filtration_;
};
--- a/include/topology/lsvineyard.h Fri Oct 26 11:45:58 2012 -0700
+++ b/include/topology/lsvineyard.h Thu Feb 28 11:12:02 2013 +0800
@@ -32,7 +32,7 @@
typedef Vertex_ Vertex;
typedef VertexEvaluator_ VertexEvaluator;
typedef typename VertexEvaluator::result_type VertexValue;
-
+
typedef Simplex_ Simplex;
typedef Filtration_ LSFiltration;
typedef typename LSFiltration::Index LSFIndex;
@@ -42,20 +42,20 @@
class KineticVertexType;
class KineticVertexComparison;
class TrajectoryExtractor;
- typedef typename OrderContainer<KineticVertexType>::Container
+ typedef typename OrderContainer<KineticVertexType>::Container
VertexContainer;
typedef typename VertexContainer::iterator VertexIndex;
- struct AttachmentData: public VineData
- {
+ struct AttachmentData: public VineData
+ {
void set_attachment(VertexIndex v) { attachment = v; }
- VertexIndex attachment;
+ VertexIndex attachment;
};
typedef DynamicPersistenceTrails<AttachmentData> Persistence;
typedef typename Persistence::OrderIndex Index;
typedef typename Persistence::iterator iterator;
- typedef typename Persistence::template SimplexMap<LSFiltration>
+ typedef typename Persistence::template SimplexMap<LSFiltration>
PFMap;
class Evaluator;
@@ -70,19 +70,19 @@
class TranspositionVisitor;
friend class TranspositionVisitor;
-
+
typedef Vineyard<Index, iterator, Evaluator> Vnrd;
public:
template<class VertexIterator>
- LSVineyard(VertexIterator begin, VertexIterator end,
+ LSVineyard(VertexIterator begin, VertexIterator end,
LSFiltration& filtration,
const VertexEvaluator& veval = VertexEvaluator());
~LSVineyard();
void compute_vineyard(const VertexEvaluator& veval);
bool transpose_vertices(VertexIndex vi);
-
+
const LSFiltration& filtration() const { return filtration_; }
const Vnrd& vineyard() const { return vineyard_; }
const Persistence& persistence() const { return persistence_; }
@@ -91,7 +91,7 @@
const SimplexComparison& simplex_comparison() const { return scmp_; }
VertexValue vertex_value(const Vertex& v) const { return veval_(v); }
- VertexValue simplex_value(const Simplex& s) const { return vertex_value(*std::max_element(s.vertices().begin(), s.vertices().end(), vcmp_)); }
+ VertexValue simplex_value(const Simplex& s) const { return vertex_value(*std::max_element(s.vertices().begin(), s.vertices().end(), vcmp_)); }
const Simplex& pfmap(iterator i) const { return pfmap_[i]; }
const Simplex& pfmap(Index i) const { return pfmap_[i]; }
VertexIndex filtration_attachment(LSFIndex i) const { return (persistence().begin() + (i - filtration().begin()))->attachment; }
@@ -101,7 +101,7 @@
public:
// For Kinetic Sort
void swap(VertexIndex a, KineticSimulator* simulator);
-
+
private:
void change_evaluator(Evaluator* eval);
void set_attachment(iterator i, VertexIndex vi) { persistence_.modifier()(i, boost::bind(&AttachmentData::set_attachment, bl::_1, vi)); }
@@ -109,14 +109,14 @@
bool verify_pairing() const;
- typedef b::tuple< b::reference_wrapper<const Simplex>,
+ typedef b::tuple< b::reference_wrapper<const Simplex>,
b::reference_wrapper<const typename Persistence::Element> >
SimplexPersistenceElementTuple;
struct AttachmentCmp;
private:
VertexContainer vertices_;
-
+
VertexEvaluator veval_;
VertexComparison vcmp_;
SimplexComparison scmp_;
@@ -124,24 +124,24 @@
LSFiltration& filtration_;
Persistence persistence_;
PFMap pfmap_;
-
+
Vnrd vineyard_;
Evaluator* evaluator_;
unsigned time_count_;
-
+
#if 0
private:
// Serialization
friend class boost::serialization::access;
-
+
LSVineyard() {}
- template<class Archive>
+ template<class Archive>
void serialize(Archive& ar, version_type )
- {
- ar & BOOST_SERIALIZATION_NVP(grid_stack_);
- ar & BOOST_SERIALIZATION_NVP(vertices_);
- ar & BOOST_SERIALIZATION_NVP(filtration_);
+ {
+ ar & BOOST_SERIALIZATION_NVP(grid_stack_);
+ ar & BOOST_SERIALIZATION_NVP(vertices_);
+ ar & BOOST_SERIALIZATION_NVP(filtration_);
};
#endif
};
@@ -149,13 +149,13 @@
//BOOST_CLASS_EXPORT(LSVineyard)
template<class V, class VE, class S, class C>
-std::ostream&
-operator<<(std::ostream& out, const typename LSVineyard<V,VE,S,C>::VertexIndex& vi)
+std::ostream&
+operator<<(std::ostream& out, const typename LSVineyard<V,VE,S,C>::VertexIndex& vi)
{ return out << vi->vertex(); }
template<class V, class VE, class S, class C>
-std::ostream&
-operator<<(std::ostream& out, const typename LSVineyard<V,VE,S,C>::KineticVertexType& v)
+std::ostream&
+operator<<(std::ostream& out, const typename LSVineyard<V,VE,S,C>::KineticVertexType& v)
{ return out << v.vertex(); }
template<class V, class VE, class S, class C>
@@ -170,7 +170,7 @@
LSFIndex simplex_index() const { return simplex_index_; }
void set_simplex_index(LSFIndex i) { simplex_index_ = i; }
-
+
private:
Vertex vertex_;
LSFIndex simplex_index_;
@@ -182,13 +182,13 @@
public:
typedef typename KineticSimulator::Function Function;
- TrajectoryExtractor(const VertexEvaluator& veval0,
+ TrajectoryExtractor(const VertexEvaluator& veval0,
const VertexEvaluator& veval1):
veval0_(veval0), veval1_(veval1) {}
-
+
Function operator()(VertexIndex i) const { VertexValue v0 = veval0_(i->vertex()), v1 = veval1_(i->vertex()); return Function(v0, v1 - v0); }
-
+
private:
const VertexEvaluator& veval0_, veval1_;
};
@@ -230,6 +230,7 @@
class LSVineyard<V,VE,S,C>::Evaluator: public std::unary_function<Index, RealType>
{
public:
+ virtual ~Evaluator() {}
virtual RealType time() const =0;
virtual RealType operator()(Index i) const =0;
virtual Dimension dimension(Index i) const =0;
@@ -243,7 +244,7 @@
public:
DimensionFromIterator(const PFMap& pfmap): pfmap_(pfmap) {}
- Dimension operator()(iterator i) const { return pfmap_[i].dimension(); }
+ Dimension operator()(iterator i) const { return pfmap_[i].dimension(); }
private:
const PFMap& pfmap_;
--- a/include/utilities/consistencylist.h Fri Oct 26 11:45:58 2012 -0700
+++ b/include/utilities/consistencylist.h Thu Feb 28 11:12:02 2013 +0800
@@ -1,5 +1,5 @@
/*
- * Author: Dmitriy Morozov
+ * Author: Dmitriy Morozov
* Department of Computer Science, Duke University, 2006
*/
@@ -31,7 +31,7 @@
class ConsistencyList: public OrderList<ConsistencyListNode<T> >
{
public:
- class OrderComparison;
+ class OrderComparison;
class LessThanComparison;
class GreaterThanComparison;
class ConsistencyComparison;
@@ -43,20 +43,20 @@
typedef GreaterThanComparison GreaterThanComparison;
typedef ConsistencyComparison ConsistencyComparison;
/// @}
-
+
typedef ConsistencyListNode<T> NodeType;
typedef ConsistencyList<T> Self;
typedef OrderList<NodeType > Parent;
-
+
typedef T value_type;
typedef T& reference;
typedef const T& const_reference;
typedef ConsistencyListIterator<T> iterator;
typedef const_ConsistencyListIterator<T> const_iterator;
-
+
ConsistencyList(): sz(0) {}
~ConsistencyList() { clear(); }
-
+
/// \name Order operations
void swap(iterator i, iterator j); ///< Exchanges the order of simplices pointed to by i and j
template<class BinaryPredicate>
@@ -69,7 +69,7 @@
iterator insert(iterator predecessor, const_reference x); ///< Inserts x immediately after predecessor (has to be a valid iterator)
void erase(iterator x) { Parent::erase(x.get_base()); --sz; }
- void clear() { return Parent::clear(); }
+ void clear() { return Parent::clear(); }
bool empty() const { return Parent::empty(); }
SizeType size() const { return sz; }
iterator begin() { return iterator(Parent::begin()); }
@@ -79,11 +79,11 @@
reference back() { return Parent::back(); }
const_reference back() const { return Parent::back(); }
void pop_back() { return Parent::pop_back(); }
-
+
iterator last() { return iterator(boost::prior(end())); }
const_iterator last() const { return const_iterator(boost::prior(end())); }
/// @}
-
+
private:
unsigned int sz;
};
@@ -93,31 +93,31 @@
class ConsistencyList<T>::OrderComparison
{
public:
- typedef typename ConsistencyList<T>::const_iterator ComparableType;
+ typedef typename ConsistencyList<T>::const_iterator ComparableType;
- int compare(ComparableType a, ComparableType b) const; /// (-1,0,1) = a (precedes, ==, succeeds) b
+ int compare(ComparableType a, ComparableType b) const; /// (-1,0,1) = a (precedes, ==, succeeds) b
};
/// Determines if the first element is less than the second one
template<class T>
-class ConsistencyList<T>::LessThanComparison: public OrderComparison
+class ConsistencyList<T>::LessThanComparison: public OrderComparison
{
public:
typedef OrderComparison Parent;
- typedef typename Parent::ComparableType ComparableType;
-
- int compare(ComparableType a, ComparableType b) const;
+ typedef typename Parent::ComparableType ComparableType;
+
+ int compare(ComparableType a, ComparableType b) const;
bool operator()(ComparableType a, ComparableType b) const;
};
/// Determines if the first element is greater than the second one
template<class T>
-class ConsistencyList<T>::GreaterThanComparison: public OrderComparison
+class ConsistencyList<T>::GreaterThanComparison: public OrderComparison
{
public:
typedef OrderComparison Parent;
- typedef typename Parent::ComparableType ComparableType;
-
+ typedef typename Parent::ComparableType ComparableType;
+
int compare(ComparableType a, ComparableType b) const;
bool operator()(ComparableType a, ComparableType b) const;
};
@@ -127,10 +127,10 @@
class ConsistencyList<T>::ConsistencyComparison
{
public:
- typedef typename ConsistencyList<T>::const_iterator ComparableType;
-
- int compare(ComparableType a, ComparableType b) const; ///< (-1,0,1) = a (precedes, ==, succeeds) b
- bool operator()(ComparableType a, ComparableType b) const;
+ typedef typename ConsistencyList<T>::const_iterator ComparableType;
+
+ int compare(ComparableType a, ComparableType b) const; ///< (-1,0,1) = a (precedes, ==, succeeds) b
+ bool operator()(ComparableType a, ComparableType b) const;
};
/// Structure storing auxilliary information requred for each node of ConsistencyList
@@ -140,7 +140,7 @@
ConsistencyListNode(const T& d, unsigned int c):
data(d), consistency(c)
{}
-
+
T data;
OrderType consistency;
@@ -157,7 +157,7 @@
{
private:
struct enabler {};
-
+
public:
typedef typename ConsistencyList<T>::Parent ConsistencyListParent;
typedef boost::iterator_adaptor<ConsistencyListIterator<T>,
@@ -168,10 +168,10 @@
ConsistencyListIterator() {}
ConsistencyListIterator(const typename ConsistencyListParent::iterator& iter):
- ConsistencyListIterator::iterator_adaptor_(iter)
+ ConsistencyListIterator::iterator_adaptor_(iter)
{}
ConsistencyListIterator(const ConsistencyListIterator<T>& other):
- ConsistencyListIterator::iterator_adaptor_(other.base())
+ ConsistencyListIterator::iterator_adaptor_(other.base())
{}
private:
@@ -189,7 +189,7 @@
{
private:
struct enabler {};
-
+
public:
typedef typename ConsistencyList<T>::Parent ConsistencyListParent;
typedef boost::iterator_adaptor<const_ConsistencyListIterator<T>,
@@ -200,13 +200,13 @@
const_ConsistencyListIterator() {}
const_ConsistencyListIterator(const typename ConsistencyListParent::const_iterator& iter):
- const_ConsistencyListIterator::iterator_adaptor_(iter)
+ const_ConsistencyListIterator::iterator_adaptor_(iter)
{}
const_ConsistencyListIterator(const const_ConsistencyListIterator<T>& other):
- const_ConsistencyListIterator::iterator_adaptor_(other.base())
+ const_ConsistencyListIterator::iterator_adaptor_(other.base())
{}
const_ConsistencyListIterator(const ConsistencyListIterator<T>& other):
- const_ConsistencyListIterator::iterator_adaptor_(other.base())
+ const_ConsistencyListIterator::iterator_adaptor_(other.base())
{}
private:
@@ -216,7 +216,6 @@
get_base() { return Parent::base_reference(); }
friend class ConsistencyList<T>::OrderComparison;
- friend class ConsistencyList<T>::ConsistencyComparison;
};
--- a/include/utilities/eventqueue.h Fri Oct 26 11:45:58 2012 -0700
+++ b/include/utilities/eventqueue.h Thu Feb 28 11:12:02 2013 +0800
@@ -24,10 +24,9 @@
template<class Event_, class EventComparison_>
class EventQueue
{
-
- public:
- typedef Event_ Event;
- typedef EventComparison_ EventComparison;
+ public:
+ typedef Event_ Event;
+ typedef EventComparison_ EventComparison;
struct HeapNode;
struct CompareNodes;
@@ -39,29 +38,29 @@
typedef std::list<HeapNode> QueueRepresentation;
typedef std::vector<iterator> EventListHeap;
- EventQueue() {}
-
- const_iterator top() const { AssertMsg(!empty(), "Queue must not be empty"); return heap_.front(); }
- iterator top() { AssertMsg(!empty(), "Queue must not be empty"); return heap_.front(); }
- iterator push(Event e);
- void pop() { AssertMsg(!empty(), "Queue must not be empty"); std::pop_heap(heap_.begin(), heap_.end(), CompareNodes(), UpdateNode()); queue_.erase(heap_.back().base()); heap_.pop_back(); }
- void remove(iterator i);
+ EventQueue() {}
+
+ const_iterator top() const { AssertMsg(!empty(), "Queue must not be empty"); return heap_.front(); }
+ iterator top() { AssertMsg(!empty(), "Queue must not be empty"); return heap_.front(); }
+ iterator push(Event e);
+ void pop();
+ void remove(iterator i);
void replace(iterator i, Event e);
- void promoted(iterator i) { std::update_heap_pos(heap_.begin(), heap_.end(), heap_.begin() + i.base()->heap_position_, CompareNodes(), UpdateNode()); }
+ void promoted(iterator i);
void demoted(iterator i);
iterator begin() { return queue_.begin(); }
const_iterator begin() const { return queue_.begin(); }
- iterator end() { return queue_.end(); }
- const_iterator end() const { return queue_.end(); }
- bool empty() const { return queue_.empty(); }
- size_t size() const { return heap_.size(); }
+ iterator end() { return queue_.end(); }
+ const_iterator end() const { return queue_.end(); }
+ bool empty() const { return queue_.empty(); }
+ size_t size() const { return heap_.size(); }
- std::ostream& print(std::ostream& out, const std::string& prefix) const;
+ std::ostream& print(std::ostream& out, const std::string& prefix) const;
- private:
- QueueRepresentation queue_;
- EventListHeap heap_;
+ private:
+ QueueRepresentation queue_;
+ EventListHeap heap_;
};
template<class Event_, class EventComparison_>
@@ -74,13 +73,13 @@
};
template<class Event_, class EventComparison_>
-class EventQueue<Event_, EventComparison_>::iterator:
- public boost::iterator_adaptor<iterator,
+class EventQueue<Event_, EventComparison_>::iterator:
+ public boost::iterator_adaptor<iterator,
typename QueueRepresentation::iterator,
Event>
{
public:
- iterator():
+ iterator():
iterator::iterator_adaptor_(0) {}
iterator(typename QueueRepresentation::iterator i):
@@ -93,8 +92,8 @@
};
template<class Event_, class EventComparison_>
-class EventQueue<Event_, EventComparison_>::const_iterator:
- public boost::iterator_adaptor<const_iterator,
+class EventQueue<Event_, EventComparison_>::const_iterator:
+ public boost::iterator_adaptor<const_iterator,
typename QueueRepresentation::const_iterator,
Event,
b::use_default,
@@ -121,7 +120,7 @@
{
void operator()(iterator i, size_t pos) const { i.base()->heap_position_ = pos; }
};
-
+
template<class Event_, class EventComparison_>
struct EventQueue<Event_, EventComparison_>::CompareNodes
{
@@ -132,55 +131,65 @@
struct EventQueue<Event_, EventComparison_>::MarkedCompareNodes
{
MarkedCompareNodes(iterator i): i_(i) {}
- bool operator()(iterator i, iterator j) const
- {
+ bool operator()(iterator i, iterator j) const
+ {
// i_ is less than everything else
if (i == i_)
return false;
if (j == i_)
return true;
- return EventComparison()(*j, *i);
+ return EventComparison()(*j, *i);
}
iterator i_;
};
-
+
template<class Event_, class EventComparison_>
typename EventQueue<Event_, EventComparison_>::iterator
EventQueue<Event_, EventComparison_>::
push(Event e)
-{
- queue_.push_back(e);
- iterator i = b::prior(queue_.end());
- heap_.push_back(i);
- std::push_heap(heap_.begin(), heap_.end(), CompareNodes(), UpdateNode());
+{
+ queue_.push_back(e);
+ iterator i = b::prior(queue_.end());
+ heap_.push_back(i);
+ std::push_heap(heap_.begin(), heap_.end(), CompareNodes(), UpdateNode());
return i;
}
-
+
+template<class Event_, class EventComparison_>
+void
+EventQueue<Event_, EventComparison_>::
+pop()
+{
+ AssertMsg(!empty(), "Queue must not be empty");
+ std::pop_heap(heap_.begin(), heap_.end(), CompareNodes(), UpdateNode());
+ queue_.erase(heap_.back().base()); heap_.pop_back();
+}
+
template<class Event_, class EventComparison_>
void
EventQueue<Event_, EventComparison_>::
remove(iterator i)
-{
+{
MarkedCompareNodes mcmp(i);
std::update_heap_pos(heap_.begin(), heap_.end(), heap_.begin() + i.base()->heap_position_, mcmp, UpdateNode());
- std::pop_heap(heap_.begin(), heap_.end(), mcmp, UpdateNode());
+ std::pop_heap(heap_.begin(), heap_.end(), mcmp, UpdateNode());
AssertMsg(heap_.back() == i, "i should be in the back");
- queue_.erase(heap_.back().base());
+ queue_.erase(heap_.back().base());
heap_.pop_back();
}
-
+
template<class Event_, class EventComparison_>
void
EventQueue<Event_, EventComparison_>::
replace(iterator i, Event e)
-{
-
+{
+
if (EventComparison()(*i, e))
{
- *i = e;
- promoted(i);
+ *i = e;
+ promoted(i);
} else
{
*i = e;
@@ -191,17 +200,25 @@
template<class Event_, class EventComparison_>
void
EventQueue<Event_, EventComparison_>::
+promoted(iterator i)
+{
+ std::update_heap_pos(heap_.begin(), heap_.end(), heap_.begin() + i.base()->heap_position_, CompareNodes(), UpdateNode());
+}
+
+template<class Event_, class EventComparison_>
+void
+EventQueue<Event_, EventComparison_>::
demoted(iterator i)
-{
+{
// Bring to front
MarkedCompareNodes mcmp(i);
std::update_heap_pos(heap_.begin(), heap_.end(), heap_.begin() + i.base()->heap_position_, mcmp, UpdateNode());
// Bring to back
- std::pop_heap(heap_.begin(), heap_.end(), mcmp, UpdateNode());
+ std::pop_heap(heap_.begin(), heap_.end(), mcmp, UpdateNode());
// Find new place
- std::update_heap_pos(heap_.begin(), heap_.end(), heap_.begin() + i.base()->heap_position_, CompareNodes(), UpdateNode());
+ std::update_heap_pos(heap_.begin(), heap_.end(), heap_.begin() + i.base()->heap_position_, CompareNodes(), UpdateNode());
}
template<class Event_, class EventComparison_>
@@ -209,9 +226,9 @@
EventQueue<Event_, EventComparison_>::
print(std::ostream& out, const std::string& prefix) const
{
- for (typename EventListHeap::const_iterator cur = heap_.begin(); cur != heap_.end(); ++cur)
- out << prefix << **cur << std::endl;
- return out;
+ for (typename EventListHeap::const_iterator cur = heap_.begin(); cur != heap_.end(); ++cur)
+ out << prefix << **cur << std::endl;
+ return out;
}
#endif // __EVENTQUEUE_H__
--- a/include/utilities/orderlist.h Fri Oct 26 11:45:58 2012 -0700
+++ b/include/utilities/orderlist.h Thu Feb 28 11:12:02 2013 +0800
@@ -1,5 +1,5 @@
/*
- * Author: Dmitriy Morozov
+ * Author: Dmitriy Morozov
* Department of Computer Science, Duke University, 2006
*
* Implements the simplified order list data strcutre given in ``Two Simplified
@@ -42,21 +42,21 @@
class OrderList: public std::list<OrderListNode<T> >
{
public:
- class OrderComparison;
+ class OrderComparison;
/// OrderComparison type
typedef OrderComparison OrderComparison;
-
+
typedef OrderListNode<T> NodeType;
typedef OrderList<T> Self;
typedef std::list<NodeType > Parent;
-
+
typedef T value_type;
typedef T& reference;
typedef const T& const_reference;
typedef OrderListIterator<T> iterator;
typedef const_OrderListIterator<T> const_iterator;
-
+
OrderList() {}
~OrderList() { clear(); }
@@ -71,8 +71,8 @@
iterator push_back(const_reference x);
iterator insert(iterator predecessor, const_reference x); ///< Inserts x immediately after predecessor (has to be a valid iterator)
void erase(iterator x) { Parent::erase(x.get_base()); }
-
- void clear() { return Parent::clear(); }
+
+ void clear() { return Parent::clear(); }
bool empty() const { return Parent::empty(); }
SizeType size() const { return Parent::size(); }
iterator begin() { return iterator(Parent::begin()); }
@@ -82,11 +82,11 @@
reference back() { return Parent::back(); }
const_reference back() const { return Parent::back(); }
void pop_back() { return Parent::pop_back(); }
-
+
iterator last() { return iterator(boost::prior(end())); }
const_iterator last() const { return const_iterator(boost::prior(end())); }
/// @}
-
+
/// \name Debugging operations
/// @{
void show_elements() const;
@@ -101,8 +101,8 @@
class OrderList<T>::OrderComparison
{
public:
- typedef typename OrderList<T>::const_iterator ComparableType;
- int compare(ComparableType a, ComparableType b) const; /// (-1,0,1) = a (precedes, ==, succeeds) b
+ typedef typename OrderList<T>::const_iterator ComparableType;
+ int compare(ComparableType a, ComparableType b) const; /// (-1,0,1) = a (precedes, ==, succeeds) b
bool operator()(ComparableType a, ComparableType b) const;
};
@@ -113,10 +113,10 @@
OrderListNode(const T& d, unsigned int t):
data(d), tag(t)
{}
-
+
T data;
OrderType tag;
-
+
std::ostream& operator<<(std::ostream& out) const { return out << data << ": " << tag; }
};
@@ -142,7 +142,7 @@
{
private:
struct enabler {};
-
+
public:
typedef typename OrderList<T>::Parent OrderListParent;
typedef boost::iterator_adaptor<OrderListIterator<T>,
@@ -153,12 +153,12 @@
OrderListIterator() {}
OrderListIterator(const typename OrderListParent::iterator& iter):
- OrderListIterator::iterator_adaptor_(iter)
+ OrderListIterator::iterator_adaptor_(iter)
{}
OrderListIterator(const OrderListIterator<T>& other):
- OrderListIterator::iterator_adaptor_(other.base())
+ OrderListIterator::iterator_adaptor_(other.base())
{}
-
+
private:
friend class boost::iterator_core_access;
reference dereference() const { return Parent::base_reference()->data; }
@@ -174,7 +174,7 @@
{
private:
struct enabler {};
-
+
public:
typedef typename OrderList<T>::Parent OrderListParent;
typedef boost::iterator_adaptor<const_OrderListIterator<T>,
@@ -185,13 +185,13 @@
const_OrderListIterator() {}
const_OrderListIterator(const typename OrderListParent::const_iterator& iter):
- const_OrderListIterator::iterator_adaptor_(iter)
+ const_OrderListIterator::iterator_adaptor_(iter)
{}
const_OrderListIterator(const const_OrderListIterator<T>& other):
- const_OrderListIterator::iterator_adaptor_(other.base())
+ const_OrderListIterator::iterator_adaptor_(other.base())
{}
const_OrderListIterator(const OrderListIterator<T>& other):
- const_OrderListIterator::iterator_adaptor_(other.base())
+ const_OrderListIterator::iterator_adaptor_(other.base())
{}
private:
@@ -201,7 +201,6 @@
get_base() { return Parent::base_reference(); }
friend class OrderList<T>;
- friend class OrderList<T>::OrderComparison;
};