Commit to merge in changes from master. ar
authorDmitriy Morozov <morozov@cs.duke.edu>
Tue, 19 Feb 2008 06:51:23 -0500
branchar
changeset 59 4eb311c4d0e7
parent 58 b3b810b64a79
child 60 bb79215d1f93
Commit to merge in changes from master.
examples/ar-vineyard/ar-vineyard.h
examples/ar-vineyard/ar-vineyard.hpp
--- a/examples/ar-vineyard/ar-vineyard.h	Fri Aug 24 16:58:25 2007 -0400
+++ b/examples/ar-vineyard/ar-vineyard.h	Tue Feb 19 06:51:23 2008 -0500
@@ -23,6 +23,7 @@
 		typedef						ConeSimplex<ARSimplex3D>									Parent;
 		typedef						ARSimplex3D													ARSimplex3D;
 		typedef						Filtration<ARConeSimplex>									Filtration;
+		typedef						Filtration::Index											Index;
 		
 		/// \name Polynomial Kernel types
 		/// @{
@@ -31,7 +32,7 @@
 		typedef						PolyKernel::Polynomial										Polynomial;
 		typedef						Simulator<PolyKernel>										Simulator;
 		
-		typedef						KineticSort<ARFiltration, SimplexTrajectoryExtractor, Simulator>
+		typedef						KineticSort<Index, SimplexTrajectoryExtractor, Simulator>
 																								SimplexSort;
 		typedef						SimplexSort::iterator										SimplexSortIterator;
 		typedef						SimplexSortIterator											Key;
@@ -42,23 +43,22 @@
 		typedef 					std::list<Polynomial>										ThresholdList;
 
 		struct 						ThresholdTrajectoryExtractor
-		{	Polynomial				operator()(ThresholdList::iterator i) const				{ return *i; } }
+		{	Polynomial				operator()(ThresholdList::iterator i) const					{ return *i; } }
 		struct 						SimplexTrajectoryExtractor
-		{	Polynomial				operator()(ARFiltration::iterator i) const					{ i->thresholds().front(); }
+		{	Polynomial				operator()(Index i) const									{ i->thresholds().front(); }
 
-		typedef						KineticSort<ThresholdList, ThresholdTrajectoryExtractor, Simulator>	
+		typedef						KineticSort<ThresholdList::iterator, ThresholdTrajectoryExtractor, Simulator>	
 																								ThresholdSort;
 		/// @}
 
 									ARConeSimplex(const ARSimplex3D& s, bool coned = false): 
-										Parent(s, coned), 
-										thresholds_sort_(&thresholds_)							{}
+										Parent(s, coned)										{}
 
 		Key							kinetic_key() const											{ return key_; }
 		void						set_kinetic_key(Key k)										{ key_ = k; }
-		const ThresholdList&		thresholds() const											{ return thresholds_; }
+		ThresholdList&				thresholds()												{ return thresholds_; }
 
-		void						schedule_thresholds(Simulator* simulator);
+		void						schedule_thresholds(SimplexSort* sort, Simulator* simulator);
 
 								
 	private:
@@ -66,7 +66,7 @@
 		ThresholdList				thresholds_;
 		ThresholdSort				thresholds_sort_;
 
-		void						swap_thresholds(ThresholdList* tl, typename ThresholdList::iterator i);
+		void						swap_thresholds(SimplexSort* sort, ThresholdList::iterator i, Simulator* simulator);
 };
 
 
@@ -101,8 +101,7 @@
 		const Vineyard*				vineyard() const											{ return vineyard_; }
 
 	public:
-		// For Kinetic Sort
-		static void 				swap(ARFiltration* filtration, Index i);
+		void 						swap(Index i, Simulator* simulator);						///< For kinetic sort
 	
 	private:
 		void 						add_simplices();
--- a/examples/ar-vineyard/ar-vineyard.hpp	Fri Aug 24 16:58:25 2007 -0400
+++ b/examples/ar-vineyard/ar-vineyard.hpp	Tue Feb 19 06:51:23 2008 -0500
@@ -2,21 +2,20 @@
 	
 void
 ARConeSimplex::
-swap_thresholds(ThresholdList* tl, typename ThresholdList::iterator i)
+swap_thresholds(SimplexSort* sort, ThresholdList::iterator i, Simulator* simulator)
 {
-	AssertMsg(tl == &thresholds_, "Swap in the wrong list");		// might as well take advantage of the redundancy
-
 	typename ThresholdList::iterator n = boost::next(i);
 	tl->splice(i, *tl, n);
 	if (n == tl->begin())
-
+		sort->update_trajectory(kinetic_key(), simulator);
 }
 
 void
 ARConeSimplex::
-schedule_thresholds(Simulator* simulator)
+schedule_thresholds(SimplexSort* sort, Simulator* simulator)
 {
-	thresholds_sort_.insert(thresholds_sort_.end(), thresholds_.begin(), thresholds_.end(), simulator);
+	thresholds_sort_.initialize(thresholds_.begin(), thresholds_.end(), 
+								boost::bind(&ARConeSimplex::swap_thresholds, this, sort, _1, _2), simulator);
 }
 
 
@@ -67,36 +66,12 @@
 	AssertMsg(filtration_->is_paired(), "Simplices must be paired for a vineyard to be computed");
 	
 	Simulator simulator;
-	SimplexSort	simplex_sort(filtration_, swap);
-
-
-
-
-
-
-
-	simplex_sort.initialize(&simulator);
-
-
-
-	typedef Traits::Kinetic_kernel::Point_1 								Point_1;
-	typedef Simulator::Time													Time;
+	SimplexSort	simplex_sort;
 	
-	Traits tr(0,1);
-	Simulator::Handle sp = tr.simulator_handle();
-	ActivePointsTable::Handle apt = tr.active_points_1_table_handle();
-	Sort sort(tr, SortVisitor(this));
-	
-	// Setup the kinetic sort and membership changes
-	std::cout << "Setting up the kinetic sort and membership events" << std::endl;
-	CF cf; 
-	kinetic_map_.clear();
+	// Set thresholds
 	for (Index cur = filtration_->begin(); cur != filtration_->end(); ++cur)
 	{
-		F x = cf(F::NT(CGAL::to_double(cur->alpha())));
-		Point_1 p(x);
-		cur->set_kinetic_key(apt->insert(p));
-		kinetic_map_[cur->kinetic_key()] = cur;
+		cur->thresholds.push_back(ARConeSimplex::Polynomial(CGAL::to_double(cur->alpha())));
 			
 		if (!cur->coned()) continue;						// non-coned simplices stay put, so we are done
 
@@ -132,7 +107,16 @@
 		std::cout << "phi_lambda: " 		<< phi_lambda << std::endl;
 		std::cout << "s^2 + v^2: " 			<< sv << std::endl;
 		std::cout << std::endl;
+		
+		cur->set_kinetic_key();
 	}
+
+
+	// Once thresholds are set (and sorted), we can initialize the simplex_sort
+	simplex_sort.initialize(filtration_.begin(), filtration_.end(), 
+							boost::bind(&ARVineyard::swap, this, _1, _2), &simulator);
+
+
 	
 	// Process all the events (compute the vineyard in the process)
 	// FIXME: the time should not be 1, but something like twice the radius of