LowerStarFiltration provides a base class for VertexType
authorDmitriy Morozov <morozov@cs.duke.edu>
Sun, 17 Feb 2008 08:47:20 -0500
changeset 42 07510f86b517
parent 41 388fd8eade12
child 45 7c15f27bfa1b
LowerStarFiltration provides a base class for VertexType
examples/grid/grid2Dvineyard.h
include/topology/lowerstarfiltration.h
include/topology/lowerstarfiltration.hpp
--- a/examples/grid/grid2Dvineyard.h	Sun Feb 17 08:23:55 2008 -0500
+++ b/examples/grid/grid2Dvineyard.h	Sun Feb 17 08:47:20 2008 -0500
@@ -1,6 +1,6 @@
 /*
  * Author: Dmitriy Morozov
- * Department of Computer Science, Duke University, 2005 -- 2006
+ * Department of Computer Science, Duke University, 2005 -- 2008
  */
 
 #ifndef __GRID2DVINEYARD_H__
@@ -21,8 +21,11 @@
 	public:
 		typedef					Grid2DVineyard										Self;
 			
-		class					VertexType;
-		typedef					std::vector<VertexType>								VertexVector;
+		typedef					Grid2D::CoordinateIndex								CoordinateIndex;
+		typedef					Grid2D::ValueType									ValueType;
+
+		class					KineticVertexType;
+		typedef					std::vector<KineticVertexType>						VertexVector;
 		typedef					VertexVector::iterator								VertexIndex;
 		
 		typedef					LowerStarFiltration<VertexIndex>					LSFiltration; 
@@ -31,12 +34,11 @@
 		class					KineticEvaluator;
 		class 					VertexComparison;
 		
-		typedef					Grid2D::CoordinateIndex								CoordinateIndex;
-		typedef					Grid2D::ValueType									ValueType;
-
 		typedef					LSFiltration::Index									Index;
 		typedef					LSFiltration::Simplex								Simplex;
 		typedef					LSFiltration::VertexOrderIndex						VertexOrderIndex;
+		typedef					LSFiltration::VertexType<CoordinateIndex>			LSVertexType;
+
 		typedef					LSFiltration::Vineyard								Vineyard;
 		typedef					Vineyard::Evaluator									Evaluator;
 
@@ -103,22 +105,15 @@
 
 //BOOST_CLASS_EXPORT(Grid2DVineyard)
 	
-class Grid2DVineyard::VertexType
+class Grid2DVineyard::KineticVertexType: public LSVertexType
 {
 	public:
-		VertexType(CoordinateIndex ii = 0): i_(ii)											{}
-		
-		CoordinateIndex			index() const												{ return i_; }
-		void					set_index(CoordinateIndex i)								{ i_ = i; }
-		VertexOrderIndex		get_order() const											{ return order_; }
-		void					set_order(const VertexOrderIndex& o)						{ order_ = o; }
+		typedef					LSVertexType												Parent;
 		
 		Key						kinetic_key() const											{ return key_; }
 		void					set_kinetic_key(Key k)										{ key_ = k; }
 		
 	private:
-		CoordinateIndex			i_;
-		VertexOrderIndex		order_;
 		Key						key_;
 };
 
--- a/include/topology/lowerstarfiltration.h	Sun Feb 17 08:23:55 2008 -0500
+++ b/include/topology/lowerstarfiltration.h	Sun Feb 17 08:47:20 2008 -0500
@@ -1,6 +1,6 @@
 /*
  * Author: Dmitriy Morozov
- * Department of Computer Science, Duke University, 2005 -- 2006
+ * Department of Computer Science, Duke University, 2005 -- 2008
  */
 
 #ifndef __LOWERSTARFILTRATION_H__
@@ -41,6 +41,9 @@
 		typedef					typename Parent::Trail								Trail;
 		typedef					typename Simplex::Cycle 							SimplexBoundaryCycle;
 
+		template<class IndexType>		
+		class 					VertexType;
+
 		struct 					VertexDescriptor;
 		typedef					ConsistencyList<VertexDescriptor>					VertexOrder;
 		typedef					typename VertexOrder::iterator						VertexOrderIndex;
@@ -90,8 +93,34 @@
 		BOOST_SERIALIZATION_SPLIT_MEMBER()
 };
 
+/**
+ * Helper class that describes lower star vertex type. Defines essential
+ * methods that LowerStarFiltration expects from its vertex type. Actual 
+ * vertex types should inherit from it.
+ */
 template<class VI, class Smplx, class FltrSmplx, class Vnrd>
-struct LowerStarFiltration<VI,Smplx,FltrSmplx,Vnrd>::VertexDescriptor
+template<class IndexType_> 
+class LowerStarFiltration<VI,Smplx,FltrSmplx,Vnrd>::
+VertexType
+{
+	public:
+		typedef					IndexType_													IndexType;
+
+		VertexType(IndexType ii = 0): i_(ii)												{}
+		
+		IndexType				index() const												{ return i_; }
+		void					set_index(IndexType i)										{ i_ = i; }
+		VertexOrderIndex		get_order() const											{ return order_; }
+		void					set_order(const VertexOrderIndex& o)						{ order_ = o; }
+
+	private:
+		IndexType				i_;
+		VertexOrderIndex		order_;
+};
+
+template<class VI, class Smplx, class FltrSmplx, class Vnrd>
+struct LowerStarFiltration<VI,Smplx,FltrSmplx,Vnrd>::
+VertexDescriptor
 {
 	VertexDescriptor(VertexIndex vi, Index si): 
 		vertex_index(vi), simplex_index(si)		
@@ -102,7 +131,8 @@
 };
 
 template<class VI, class Smplx, class FltrSmplx, class Vnrd>
-struct LowerStarFiltration<VI,Smplx,FltrSmplx,Vnrd>::SimplexAttachmentComparison
+struct LowerStarFiltration<VI,Smplx,FltrSmplx,Vnrd>::
+SimplexAttachmentComparison
 {
 	bool operator()(const Simplex& first, const Simplex& second) const;
 	VertexOrderComparison	vertex_cmp;
--- a/include/topology/lowerstarfiltration.hpp	Sun Feb 17 08:23:55 2008 -0500
+++ b/include/topology/lowerstarfiltration.hpp	Sun Feb 17 08:47:20 2008 -0500
@@ -11,6 +11,11 @@
 static Counter*  cLowerStarChangedAttachment =		 	GetCounter("lowerstar/ChangedAttachment");
 #endif // COUNTERS
 
+
+/**
+ * Copies vertices [begin, end), orders them by cmp, and 
+ * records which vineyard to use in case of transpositions.
+ */
 template<class VI, class Smplx, class FltrSmplx, class Vnrd>
 template<class VertexCmp>
 LowerStarFiltration<VI,Smplx,FltrSmplx,Vnrd>::