mirror of https://github.com/CGAL/cgal
146 lines
3.5 KiB
C++
146 lines
3.5 KiB
C++
// ============================================================================
|
|
//
|
|
// Copyright (c) 2000 The CGAL Consortium
|
|
//
|
|
// This software and related documentation is part of an INTERNAL release
|
|
// of the Computational Geometry Algorithms Library (CGAL). It is not
|
|
// intended for general use.
|
|
//
|
|
// ----------------------------------------------------------------------------
|
|
//
|
|
// release : $CGAL_Revision $
|
|
// release_date : $CGAL_Date $
|
|
//
|
|
// file : include/CGAL/Circulator_pair.h
|
|
// package : $CGAL_Package: Partition_2 $
|
|
// maintainer : Susan Hert <hert@mpi-sb.mpg.de>
|
|
// chapter : Planar Polygon Partitioning
|
|
//
|
|
// revision : $Revision$
|
|
// revision_date : $Date$
|
|
//
|
|
// author(s) : Susan Hert <hert@mpi-sb.mpg.de>
|
|
//
|
|
// coordinator : MPI (Susan Hert <hert@mpi-sb.mpg.de>)
|
|
//
|
|
// implementation: pair of circulators that represents a chain of vertices
|
|
// ============================================================================
|
|
#ifndef CGAL_CIRC_PAIR_H
|
|
#define CGAL_CIRC_PAIR_H
|
|
|
|
namespace CGAL {
|
|
|
|
//
|
|
// "before" always means a point between front and back in the indicated
|
|
// direction
|
|
//
|
|
// "after" always means a point just beyond the range of [front,back]
|
|
//
|
|
template <class BidirectionalCirculator>
|
|
class Circ_pair
|
|
{
|
|
|
|
public:
|
|
Circ_pair(BidirectionalCirculator back, BidirectionalCirculator front) :
|
|
_front(front), _back(back), _direction(COUNTERCLOCKWISE) {}
|
|
|
|
Circ_pair(BidirectionalCirculator back, BidirectionalCirculator front,
|
|
Orientation dir) : _front(front), _back(back), _direction(dir) {}
|
|
|
|
Circ_pair(BidirectionalCirculator front_and_back, Orientation dir) :
|
|
_front(front_and_back), _back(front_and_back), _direction(dir) {}
|
|
|
|
void initialize(BidirectionalCirculator new_back_and_front)
|
|
{
|
|
_back = _front = new_back_and_front;
|
|
}
|
|
|
|
void push_back(BidirectionalCirculator new_back)
|
|
{
|
|
_back = new_back;
|
|
}
|
|
|
|
void pop_back()
|
|
{
|
|
_back = before_back();
|
|
}
|
|
|
|
void push_front(BidirectionalCirculator new_front)
|
|
{
|
|
_front = new_front;
|
|
}
|
|
|
|
void pop_front()
|
|
{
|
|
_front = before_front();
|
|
}
|
|
|
|
BidirectionalCirculator front() const
|
|
{
|
|
return _front;
|
|
}
|
|
|
|
BidirectionalCirculator back() const
|
|
{
|
|
return _back;
|
|
}
|
|
|
|
Orientation direction() const
|
|
{
|
|
return _direction;
|
|
}
|
|
|
|
void set_direction(Orientation direction)
|
|
{
|
|
_direction = direction;
|
|
}
|
|
|
|
void change_dir()
|
|
{
|
|
if (_direction == CLOCKWISE)
|
|
_direction = COUNTERCLOCKWISE;
|
|
else
|
|
_direction = CLOCKWISE;
|
|
}
|
|
|
|
BidirectionalCirculator before_back()
|
|
{
|
|
BidirectionalCirculator temp = _back;
|
|
if (_direction == COUNTERCLOCKWISE)
|
|
return ++temp;
|
|
else
|
|
return --temp;
|
|
}
|
|
BidirectionalCirculator after_back()
|
|
{
|
|
BidirectionalCirculator temp = _back;
|
|
if (_direction == COUNTERCLOCKWISE)
|
|
return --temp;
|
|
else
|
|
return ++temp;
|
|
}
|
|
BidirectionalCirculator before_front()
|
|
{
|
|
BidirectionalCirculator temp = _front;
|
|
if (_direction == COUNTERCLOCKWISE)
|
|
return --temp;
|
|
else
|
|
return ++temp;
|
|
}
|
|
BidirectionalCirculator after_front()
|
|
{
|
|
BidirectionalCirculator temp = _front;
|
|
if (_direction == COUNTERCLOCKWISE)
|
|
return ++temp;
|
|
else
|
|
return --temp;
|
|
}
|
|
private:
|
|
BidirectionalCirculator _front, _back;
|
|
Orientation _direction;
|
|
};
|
|
|
|
}
|
|
|
|
#endif // CGAL_CIRC_PAIR_H
|