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