author Dmitriy Morozov <morozov@cs.duke.edu>
Fri, 17 Aug 2007 15:08:27 -0400
changeset 57 07a8ed7c97a3
parent 56 f480ec018512
parent 23 cb700b407c0d
child 59 4eb311c4d0e7
permissions -rw-r--r--
Merged CGAL 3.3 changes with the work on ARVineyard

 * Author: Dmitriy Morozov
 * Department of Computer Science, Duke University, 2007

#ifndef __AR_VINEYARD_H__
#define __AR_VINEYARD_H__

#include "utilities/sys.h"
#include "utilities/debug.h"

#include "topology/conesimplex.h"
#include "topology/filtration.h"
#include "geometry/kinetic-sort.h"

#include <list>
#include "ar-simplex3d.h"

class ARConeSimplex: public ConeSimplex<ARSimplex3D>
		typedef						ConeSimplex<ARSimplex3D>									Parent;
		typedef						ARSimplex3D													ARSimplex3D;
		typedef						Filtration<ARConeSimplex>									Filtration;
		/// \name Polynomial Kernel types
		/// @{
		typedef						double														FieldType;
		typedef						UPolynomial<FieldType>										PolyKernel;
		typedef						PolyKernel::Polynomial										Polynomial;
		typedef						Simulator<PolyKernel>										Simulator;
		typedef						KineticSort<ARFiltration, SimplexTrajectoryExtractor, Simulator>
		typedef						SimplexSort::iterator										SimplexSortIterator;
		typedef						SimplexSortIterator											Key;
		/// @}

		/// \name Kinetic Sort types
		/// @{
		typedef 					std::list<Polynomial>										ThresholdList;

		struct 						ThresholdTrajectoryExtractor
		{	Polynomial				operator()(ThresholdList::iterator i) const				{ return *i; } }
		struct 						SimplexTrajectoryExtractor
		{	Polynomial				operator()(ARFiltration::iterator i) const					{ i->thresholds().front(); }

		typedef						KineticSort<ThresholdList, ThresholdTrajectoryExtractor, Simulator>	
		/// @}

									ARConeSimplex(const ARSimplex3D& s, bool coned = false): 
										Parent(s, coned), 
										thresholds_sort_(&thresholds_)							{}

		Key							kinetic_key() const											{ return key_; }
		void						set_kinetic_key(Key k)										{ key_ = k; }
		const ThresholdList&		thresholds() const											{ return thresholds_; }

		void						schedule_thresholds(Simulator* simulator);

		Key							key_;
		ThresholdList				thresholds_;
		ThresholdSort				thresholds_sort_;

		void						swap_thresholds(ThresholdList* tl, typename ThresholdList::iterator i);

class ARVineyard
		typedef						ARVineyard													Self;
		typedef						ARConeSimplex::Filtration									ARFiltration;	
		typedef						ARFiltration::Simplex										Simplex;
		typedef						ARFiltration::Index											Index;
		typedef						ARFiltration::Vineyard										Vineyard;
		typedef						Vineyard::Evaluator											Evaluator;
		typedef						ARConeSimplex::Simulator									Simulator;	
		typedef						ARConeSimplex::SimplexSort									SimplexSort;	

		typedef						std::list<Point>											PointList;

		class						StaticEvaluator;
		class						KineticEvaluator;

									ARVineyard(const PointList& points, const Point& z);

		void						compute_pairing();
		void						compute_vineyard(bool explicit_events = false);
		const ARFiltration*			filtration() const											{ return filtration_; }
		const Vineyard*				vineyard() const											{ return vineyard_; }

		// For Kinetic Sort
		static void 				swap(ARFiltration* filtration, Index i);
		void 						add_simplices();
		void						change_evaluator(Evaluator* eval);

		ARFiltration*				filtration_;
		Vineyard*					vineyard_;
		Evaluator*					evaluator_;

		Point						z_;
		Delaunay					dt_;
#if 0
		// Serialization
		friend class boost::serialization::access;
		ARVineyard() 																	{}

		template<class Archive> 
		void serialize(Archive& ar, version_type )
			// FIXME


class ARVineyard::StaticEvaluator: public Evaluator
									StaticEvaluator(RealType t): time_(t)						{}

		virtual RealType			time() const												{ return time_; }
		virtual RealType			value(const Simplex& s) const								{ return s.value(); }

		RealType					time_;

class ARVineyard::KineticEvaluator: public Evaluator
									KineticEvaluator(Simulator::Handle sp, 
													 ActivePointsTable::Handle apt, 
													 RealType time_offset): 
										sp_(sp), apt_(apt)										{}

		virtual RealType			time() const												{ return CGAL::to_double(get_time()); }
		virtual RealType			value(const Simplex& s)	const								{ return CGAL::to_double(apt_->at(s.kinetic_key()).x()(get_time())); }

		Simulator::Time				get_time() const											{ return sp_->current_time(); }
		Simulator::Handle			sp_;
		ActivePointsTable::Handle 	apt_;

#include "ar-vineyard.hpp"

#endif // __AR_VINEYARD_H__