// Equator.H  (lost original version of this?)
// JR 9/27/95
//	10/20/95  Added non-null constructors.
//		  Tested.
//	10/25/95  Added evacuateEdge.
//	4/4/96    Added evacuateEdgeThruTerminus.
//		  Fixed error in evacuateEdge.

#ifndef EQUATOR_H
#define EQUATOR_H

#include "DELList.H"
#include "DE.H"
#include "Graph.H"
//#include <iostream.h>
#include <iostream>
using namespace std;

class Equator: public DELList
{
	public:
		Equator()
		: DELList()
		{}
		Equator(const DE& e1)
		: DELList(e1)
		{}
		Equator(const DE& e1,const DE& e2)
		: DELList(e1,e2)
		{}
		Equator(const DE& e1,const DE& e2,const DE& e3)
		: DELList(e1,e2,e3)
		{}
		Equator(const LinList<DE>& L)
		: DELList(L)
		{}
	        ~Equator()
		{}

		void evacuateEdge(DE e,const Graph& g);
		void evacuateEdgeThruTerminus(DE e,const Graph& g);

//2002_12_27	friend ostream& operator << ( ostream& out, const LinList<DE>& eq);
//2002_12_27	friend istream& operator >> ( istream&  in,       LinList<DE>& eq);
};

void Equator::evacuateEdge(DE e,const Graph& g)
{
	// Any crossings of edge e should be pushed out
	// through one end or the other of e.
	// We choose the end with fewer edges.

// cout << "Entered evacuateEdge " << e << endl;

	const Vertex& ve(g.originOf(e));
	const Vertex& vebar(g.originOf(e.bar()));

	if(ve.length()<vebar.length())	
	{	
		DELList tmp(e,ve);		
		tmp.popFirst();
		substitute(e.bar(),tmp);
	}
	else
	{
		DELList tmp(e.bar(),vebar);		
		tmp.popFirst();
		substitute(e,tmp);
	}
// cout << "Leaving evacuateEdge, new Equator" << endl << (*this) << endl;
}

void Equator::evacuateEdgeThruTerminus(DE e,const Graph& g)
{
	// Any crossings of edge e should be pushed out
	// through the terminus of e.

	const Vertex& vebar(g.originOf(e.bar()));

	DELList tmp(e.bar(),vebar);	// (e.bar() specifies the split of the CircList)	
	tmp.popFirst();
	substitute(e,tmp);
}



#endif

