/****************************************************************************
** GMAF - The Geometry Modeling Algorithms Framework
**
** Created : 04012000
**
** Copyright (C) 2000 by Le-Jeng Shiue.  All rights reserved.
**
****************************************************************************/
#ifndef gmafVertexIterator_H
#define gmafVertexIterator_H

#include "CgalExtension/cgalConfig.h"
#include "gmafPolyhedron.h"

/**
   gmafVertexIterator will traverse all vertices in the polyhedron.
   (Not STL compatible)
*/
class gmafVertexIterator {
// ENUMS
public:

// VARIABLES
/**@name Class Variables */
//@{
protected:
  /**
     The polyhdron it will traverse.
   */
  Polyhedron* mpcgalPolyhedron;
  Vertex_iterator mcgalVertexItr;
private:

//@}

// METHODS
/**@name Class Methods */
//@{
public:
  /**
     Constructor of gmafVertexIterator
     p: the polyhdron it will traverse.
  */    
  gmafVertexIterator(gmafPolyhedron* p);
  /**
     Destructor of gmafVertexIterator
  */    
  virtual ~gmafVertexIterator();
  
  /**
     Retrun the number of the vertices in the polyhedron
   */
  inline virtual int size() const;
  /**
     Move the iterator back to the start position.
   */
  inline virtual void restart();
  /**
     Check if the iterator is still advanceble.
   */
  inline virtual bool valid() const;
  /**
     Go to next vertex.
   */
  inline virtual void next();
  /**
     Return the current vertex.
   */
  inline virtual Vertex& current() const;
  
protected:
  
private:
};

//---------------------------------------------------------
inline gmafVertexIterator::gmafVertexIterator(gmafPolyhedron* p) {
  mpcgalPolyhedron = p->getPolyhedron();
  mcgalVertexItr = mpcgalPolyhedron->vertices_begin();
}

inline gmafVertexIterator::~gmafVertexIterator() {
}

inline int gmafVertexIterator::size() const {
  return mpcgalPolyhedron->size_of_vertices();
}

inline void gmafVertexIterator::restart() {
  mcgalVertexItr = mpcgalPolyhedron->vertices_begin();
}

inline bool gmafVertexIterator::valid() const {
  return (mcgalVertexItr != mpcgalPolyhedron->vertices_end());
}

inline void gmafVertexIterator::next() {
  if (mcgalVertexItr != mpcgalPolyhedron->vertices_end())
    mcgalVertexItr++;
}

inline Vertex& gmafVertexIterator::current() const {
  return *mcgalVertexItr;
}



#endif gmafVertexIterator_H

