Shinya Kitaoka 810553
#pragma once
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifndef TCG_VERTEX_H
Toshihiro Shimizu 890ddd
#define TCG_VERTEX_H
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// tcg includes
Toshihiro Shimizu 890ddd
#include "list.h"
Toshihiro Shimizu 890ddd
#include "point.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
namespace tcg
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
template <typename v=""></typename>
Toshihiro Shimizu 890ddd
struct vertex_traits {
Toshihiro Shimizu 890ddd
	typedef typename V::point_type point_type;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	typedef typename V::edges_const_iterator edges_const_iterator;
Toshihiro Shimizu 890ddd
	typedef typename V::edges_iterator edges_iterator;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//----------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
template <typename point=""></typename>
Toshihiro Shimizu 890ddd
class Vertex
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
protected:
Toshihiro Shimizu 890ddd
	Point m_p;
Toshihiro Shimizu 890ddd
	int m_index;
Toshihiro Shimizu 890ddd
	tcg::list<int> m_edgeList;</int>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	typedef Point point_type;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	typedef tcg::list<int>::const_iterator edges_const_iterator;</int>
Toshihiro Shimizu 890ddd
	typedef tcg::list<int>::iterator edges_iterator;</int>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	Vertex() : m_index(-1) {}
Toshihiro Shimizu 890ddd
	Vertex(const point_type &p) : m_p(p), m_index(-1) {}
Toshihiro Shimizu 890ddd
	~Vertex() {}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void setIndex(int idx) { m_index = idx; }
Toshihiro Shimizu 890ddd
	int getIndex() const { return m_index; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	const tcg::list<int> &edges() const { return m_edgeList; }</int>
Toshihiro Shimizu 890ddd
	tcg::list<int> &edges() { return m_edgeList; }</int>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	int edgesCount() const { return int(m_edgeList.size()); }
Toshihiro Shimizu 890ddd
	int edge(int e) const { return int(m_edgeList[e]); }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void addEdge(int e) { m_edgeList.push_back(e); }
Toshihiro Shimizu 890ddd
	edges_iterator eraseEdge(edges_iterator it) { return m_edgeList.erase(it); }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	edges_const_iterator edgesBegin() const { return m_edgeList.begin(); }
Toshihiro Shimizu 890ddd
	edges_const_iterator edgesEnd() const { return m_edgeList.end(); }
Toshihiro Shimizu 890ddd
	edges_iterator edgesBegin() { return m_edgeList.begin(); }
Toshihiro Shimizu 890ddd
	edges_iterator edgesEnd() { return m_edgeList.end(); }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void setP(const point_type &p) { m_p = p; }
Toshihiro Shimizu 890ddd
	const point_type &P() const { return m_p; }
Toshihiro Shimizu 890ddd
	point_type &P() { return m_p; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	bool operator==(const Vertex &v) const { return (m_p == v.m_p); }
Toshihiro Shimizu 890ddd
	bool operator!=(const Vertex &v) const { return (m_p != v.m_p); }
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//----------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
template <typename p=""></typename>
Toshihiro Shimizu 890ddd
struct point_traits<vertex<p>> {</vertex<p>
Toshihiro Shimizu 890ddd
	typedef Vertex

point_type;

Toshihiro Shimizu 890ddd
	typedef typename point_traits

::value_type value_type;

Toshihiro Shimizu 890ddd
	typedef typename point_traits

::float_type float_type;

Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	static inline value_type x(const point_type &p) { return p.P().x; }
Toshihiro Shimizu 890ddd
	static inline value_type y(const point_type &p) { return p.P().y; }
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
} // namespace tcg
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#endif // TCG_VERTEX_H