mirror of https://github.com/CGAL/cgal
113 lines
3.0 KiB
C++
113 lines
3.0 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/Partition_opt_cvx_vertex.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: Vertex used in optimal convex partitioning algorithm
|
|
// ============================================================================
|
|
|
|
#ifndef CGAL_PARTITION_OPT_CVX_VERTEX_H
|
|
#define CGAL_PARTITION_OPT_CVX_VERTEX_H
|
|
|
|
#include <list>
|
|
#include <CGAL/Partition_opt_cvx_diagonal_list.h>
|
|
|
|
namespace CGAL {
|
|
|
|
class Partition_opt_cvx_stack_record
|
|
{
|
|
public:
|
|
|
|
Partition_opt_cvx_stack_record() {}
|
|
|
|
Partition_opt_cvx_stack_record(unsigned int old, int value) :
|
|
_old(old), _value(value), _solution(Partition_opt_cvx_diagonal_list())
|
|
{}
|
|
|
|
Partition_opt_cvx_stack_record(unsigned int old, int value,
|
|
const Partition_opt_cvx_diagonal_list& solution) :
|
|
_old(old), _value(value), _solution(solution)
|
|
{}
|
|
|
|
unsigned int vertex_num() { return _old; }
|
|
|
|
int value() {return _value; }
|
|
|
|
Partition_opt_cvx_diagonal_list solution() { return _solution; }
|
|
|
|
private:
|
|
unsigned int _old;
|
|
int _value;
|
|
Partition_opt_cvx_diagonal_list _solution;
|
|
};
|
|
|
|
class Partition_opt_cvx_vertex
|
|
{
|
|
public:
|
|
|
|
Partition_opt_cvx_vertex() {}
|
|
|
|
Partition_opt_cvx_vertex(unsigned int v_num): _v_num(v_num),
|
|
_stack(std::list<Partition_opt_cvx_stack_record>()),
|
|
_best_so_far(Partition_opt_cvx_stack_record(0, 0))
|
|
{}
|
|
|
|
unsigned int vertex_num( ) { return _v_num; }
|
|
|
|
Partition_opt_cvx_stack_record best_so_far( )
|
|
{
|
|
return _best_so_far;
|
|
}
|
|
|
|
bool stack_empty() { return _stack.empty(); }
|
|
|
|
// Pre: stack is not empty
|
|
Partition_opt_cvx_stack_record stack_top()
|
|
{
|
|
return _stack.back();
|
|
}
|
|
|
|
void stack_push(unsigned int vertex, int value,
|
|
const Partition_opt_cvx_diagonal_list& diag_list)
|
|
{
|
|
_best_so_far = Partition_opt_cvx_stack_record(vertex, value, diag_list);
|
|
_stack.push_back(_best_so_far);
|
|
}
|
|
|
|
// Pre: stack is not empty
|
|
void stack_pop()
|
|
{
|
|
_best_so_far = _stack.back();
|
|
_stack.pop_back();
|
|
}
|
|
|
|
private:
|
|
unsigned int _v_num;
|
|
std::list<Partition_opt_cvx_stack_record> _stack;
|
|
Partition_opt_cvx_stack_record _best_so_far;
|
|
};
|
|
|
|
}
|
|
|
|
#endif // CGAL_PARTITION_OPT_CVX_VERTEX_H
|