00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef PPL_algorithms_hh
00025 #define PPL_algorithms_hh 1
00026
00027 #include "NNC_Polyhedron.defs.hh"
00028 #include "Pointset_Powerset.defs.hh"
00029 #include <utility>
00030 #include "assert.hh"
00031
00032 namespace Parma_Polyhedra_Library {
00033
00034 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00035
00042 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
00043 template <typename PH>
00044 bool
00045 poly_hull_assign_if_exact(PH& p, const PH& q);
00046
00047 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00048
00049 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
00050 template <typename PH>
00051 bool
00052 poly_hull_assign_if_exact(PH& p, const PH& q) {
00053 PH phull = p;
00054 NNC_Polyhedron nnc_p(p);
00055 phull.poly_hull_assign(q);
00056 std::pair<PH, Pointset_Powerset<NNC_Polyhedron> >
00057 partition = linear_partition(q, phull);
00058 const Pointset_Powerset<NNC_Polyhedron>& s = partition.second;
00059 typedef Pointset_Powerset<NNC_Polyhedron>::const_iterator iter;
00060 for (iter i = s.begin(), s_end = s.end(); i != s_end; ++i)
00061
00062
00063
00064 if (!nnc_p.contains(i->pointset()))
00065 return false;
00066 p = phull;
00067 return true;
00068 }
00069
00070 }
00071
00072 #endif // !defined(PPL_algorithms_hh)