mirror of https://github.com/CGAL/cgal
factorize the call to the convex hull of the dual
This commit is contained in:
parent
6554279e9a
commit
50c8db347b
|
|
@ -243,7 +243,7 @@ namespace CGAL
|
|||
template <class PlaneIterator, class Polyhedron>
|
||||
void halfspace_intersection_3 (PlaneIterator begin, PlaneIterator end,
|
||||
Polyhedron &P,
|
||||
boost::optional<typename Polyhedron::Vertex::Point_3> const& origin = boost::none) {
|
||||
boost::optional<typename Polyhedron::Vertex::Point_3> origin = boost::none) {
|
||||
// Checks whether the intersection is a polyhedron
|
||||
CGAL_assertion_msg(Convex_hull_3::internal::is_intersection_dim_3(begin, end), "halfspace_intersection_3: intersection not a polyhedron");
|
||||
|
||||
|
|
@ -252,20 +252,9 @@ namespace CGAL
|
|||
typedef Convex_hull_3::Convex_hull_traits_dual_3<K> Hull_traits_dual_3;
|
||||
typedef Polyhedron_3<Hull_traits_dual_3> Polyhedron_dual_3;
|
||||
typedef Convex_hull_3::internal::Build_primal_polyhedron<K, Polyhedron_dual_3, Polyhedron> Builder;
|
||||
typedef typename Polyhedron::Vertex::Point_3 Point_3;
|
||||
|
||||
if (origin) {
|
||||
Point_3 p_origin = boost::get(origin);
|
||||
Hull_traits_dual_3 dual_traits(p_origin);
|
||||
|
||||
Polyhedron_dual_3 dual_convex_hull;
|
||||
CGAL::convex_hull_3(begin, end, dual_convex_hull, dual_traits);
|
||||
Builder build_primal(dual_convex_hull, p_origin);
|
||||
P.delegate(build_primal);
|
||||
|
||||
// Posterior check if the origin is inside the computed polyhedron
|
||||
CGAL_assertion_msg(Convex_hull_3::internal::point_inside_convex_polyhedron(P, p_origin), "halfspace_intersection_3: origin not in the polyhedron");
|
||||
} else {
|
||||
// if a point inside is not provided find one using linear programming
|
||||
if (!origin) {
|
||||
// choose exact integral type
|
||||
#ifdef CGAL_USE_GMP
|
||||
typedef CGAL::Gmpq ET;
|
||||
|
|
@ -278,18 +267,18 @@ namespace CGAL
|
|||
CGAL_assertion_code(bool interior_point_found = )
|
||||
interior.find(begin, end);
|
||||
CGAL_assertion_msg(interior_point_found, "halfspace_intersection_3: problem when determing a point inside the intersection");
|
||||
Point_3 origin = interior.inside_point();
|
||||
|
||||
Hull_traits_dual_3 dual_traits(origin);
|
||||
|
||||
Polyhedron_dual_3 dual_convex_hull;
|
||||
CGAL::convex_hull_3(begin, end, dual_convex_hull, dual_traits);
|
||||
Builder build_primal(dual_convex_hull, origin);
|
||||
P.delegate(build_primal);
|
||||
|
||||
// Posterior check if the origin is inside the computed polyhedron
|
||||
CGAL_assertion_msg(Convex_hull_3::internal::point_inside_convex_polyhedron(P, origin), "halfspace_intersection_3: origin not in the polyhedron");
|
||||
origin = boost::make_optional(interior.inside_point());
|
||||
}
|
||||
|
||||
// compute the intersection of the half-space using the dual formulation
|
||||
Hull_traits_dual_3 dual_traits(*origin);
|
||||
Polyhedron_dual_3 dual_convex_hull;
|
||||
CGAL::convex_hull_3(begin, end, dual_convex_hull, dual_traits);
|
||||
Builder build_primal(dual_convex_hull, *origin);
|
||||
P.delegate(build_primal);
|
||||
|
||||
// Posterior check if the origin is inside the computed polyhedron
|
||||
CGAL_assertion_msg(Convex_hull_3::internal::point_inside_convex_polyhedron(P, *origin), "halfspace_intersection_3: origin not in the polyhedron");
|
||||
}
|
||||
|
||||
#ifndef CGAL_NO_DEPRECATED_CODE
|
||||
|
|
|
|||
Loading…
Reference in New Issue