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

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

/**
   gmafFacetIterator traverse all facets in the polyhedron
   (Not STL compatible)
*/
class gmafFacetIterator {
// ENUMS
public:

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

//@}

// METHODS
/**@name Class Methods */
//@{
public:
  /**
     Constructor of gmafFacetIterator
     p: the polyhdron it will traverse.
  */    
  gmafFacetIterator();
  gmafFacetIterator(gmafPolyhedron* p);
  /**
     Destructor of gmafFacetIterator
  */    
  virtual ~gmafFacetIterator();
  
  /**
     Retrun the number of the facets 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 facet.
   */
  inline virtual void next();
  /**
     Return the current facet
   */
  inline virtual Facet& current() const;
  
protected:
  
private:
};

//---------------------------------------------------------
inline gmafFacetIterator::gmafFacetIterator() {
}

inline gmafFacetIterator::gmafFacetIterator(gmafPolyhedron* p) {
  mpcgalPolyhedron = p->getPolyhedron();
  mcgalFacetItr = p->getPolyhedron()->facets_begin();
}

inline gmafFacetIterator::~gmafFacetIterator() {
}

inline int gmafFacetIterator::size() const {
  return mpcgalPolyhedron->size_of_facets();
}

inline void gmafFacetIterator::restart() {
  mcgalFacetItr = mpcgalPolyhedron->facets_begin();
}

inline bool gmafFacetIterator::valid() const {
  return (mcgalFacetItr != mpcgalPolyhedron->facets_end());
}

inline void gmafFacetIterator::next() {
  if (mcgalFacetItr != mpcgalPolyhedron->facets_end())
    mcgalFacetItr++;
}

inline Facet& gmafFacetIterator::current() const {
  return *mcgalFacetItr;
}



#endif gmafFacetIterator_H

