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
Shinya Kitaoka 120a6e
namespace tcg {
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
template <typename v=""></typename>
Toshihiro Shimizu 890ddd
struct vertex_traits {
Shinya Kitaoka 120a6e
  typedef typename V::point_type point_type;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  typedef typename V::edges_const_iterator edges_const_iterator;
Shinya Kitaoka 120a6e
  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>
Shinya Kitaoka 120a6e
class Vertex {
Toshihiro Shimizu 890ddd
protected:
Shinya Kitaoka 120a6e
  Point m_p;
Shinya Kitaoka 120a6e
  int m_index;
Shinya Kitaoka 120a6e
  tcg::list<int> m_edgeList;</int>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  typedef Point point_type;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  typedef tcg::list<int>::const_iterator edges_const_iterator;</int>
Shinya Kitaoka 120a6e
  typedef tcg::list<int>::iterator edges_iterator;</int>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  Vertex() : m_index(-1) {}
Shinya Kitaoka 120a6e
  Vertex(const point_type &p) : m_p(p), m_index(-1) {}
Shinya Kitaoka 120a6e
  ~Vertex() {}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void setIndex(int idx) { m_index = idx; }
Shinya Kitaoka 120a6e
  int getIndex() const { return m_index; }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  const tcg::list<int> &edges() const { return m_edgeList; }</int>
Shinya Kitaoka 120a6e
  tcg::list<int> &edges() { return m_edgeList; }</int>
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  int edgesCount() const { return int(m_edgeList.size()); }
Shinya Kitaoka 120a6e
  int edge(int e) const { return int(m_edgeList[e]); }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void addEdge(int e) { m_edgeList.push_back(e); }
Shinya Kitaoka 120a6e
  edges_iterator eraseEdge(edges_iterator it) { return m_edgeList.erase(it); }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  edges_const_iterator edgesBegin() const { return m_edgeList.begin(); }
Shinya Kitaoka 120a6e
  edges_const_iterator edgesEnd() const { return m_edgeList.end(); }
Shinya Kitaoka 120a6e
  edges_iterator edgesBegin() { return m_edgeList.begin(); }
Shinya Kitaoka 120a6e
  edges_iterator edgesEnd() { return m_edgeList.end(); }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void setP(const point_type &p) { m_p = p; }
Shinya Kitaoka 120a6e
  const point_type &P() const { return m_p; }
Shinya Kitaoka 120a6e
  point_type &P() { return m_p; }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  bool operator==(const Vertex &v) const { return (m_p == v.m_p); }
Shinya Kitaoka 120a6e
  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>
Shinya Kitaoka 120a6e
  typedef Vertex

point_type;

Shinya Kitaoka 120a6e
  typedef typename point_traits

::value_type value_type;

Shinya Kitaoka 120a6e
  typedef typename point_traits

::float_type float_type;

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