I've built Boost 1.58.0 and CGAL 4.6 and linked them nicely in a project with the example code given here. This compiles and works perfectly:
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Convex_hull_3/dual/halfspace_intersection_3.h>
#include <CGAL/point_generators_3.h>
#include <list>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef K::Plane_3 Plane;
typedef K::Point_3 Point;
typedef CGAL::Polyhedron_3<K> Polyhedron_3;
// compute the tangent plane of a point
template <typename K>
typename K::Plane_3 tangent_plane (typename K::Point_3 const& p) {
typename K::Vector_3 v(p.x(), p.y(), p.z());
v = v / sqrt(v.squared_length());
typename K::Plane_3 plane(v.x(), v.y(), v.z(), -(p - CGAL::ORIGIN) * v);
return plane;
}
int main (void) {
// number of generated planes
int N = 200;
// generates random planes on a sphere
std::list<Plane> planes;
CGAL::Random_points_on_sphere_3<Point> g;
for (int i = 0; i < N; i++) {
planes.push_back(tangent_plane<K>(*g++));
}
// define polyhedron to hold the intersection
Polyhedron_3 P;
// compute the intersection
// if a point inside the intersection is unknown, pass boost::none
// to automatically found one using linear programming
CGAL::halfspace_intersection_3(planes.begin(),
planes.end(),
P,
Point(0, 0, 0)); // PROBLEMATIC WHEN REMOVED
return 0;
}
However, removing the last argument, or "correctly" (that is, according to the specs here) setting it to boost::none
gives the following compile error:
||=== CGALtest, Debug ===|
e:\Users\Bombax\Cpp\Libraries\CGAL-4.6\include\CGAL\Convex_hull_3\dual\halfspace_intersection_3.h||In function 'void CGAL::halfspace_intersection_3(PlaneIterator, PlaneIterator, Polyhedron&) [with PlaneIterator = std::_List_iterator<CGAL::Plane_3<CGAL::Epick> >, Polyhedron = Polyhedron_3]':|
e:\Users\Bombax\Cpp\Tests\CGALtest\example.cpp|33|instantiated from here|
e:\Users\Bombax\Cpp\Libraries\CGAL-4.6\include\CGAL\Convex_hull_3\dual\halfspace_intersection_3.h|318|error: invalid initialization of reference of type 'const CGAL::Point_3<CGAL::Epick>&' from expression of type 'const boost::none_t'|
e:\Users\Bombax\Cpp\Libraries\CGAL-4.6\include\CGAL\Convex_hull_3\dual\halfspace_intersection_3.h|323|error: in passing argument 4 of 'void CGAL::halfspace_intersection_3(PlaneIterator, PlaneIterator, Polyhedron&, const typename Polyhedron::Vertex::Point_3&) [with PlaneIterator = std::_List_iterator<CGAL::Plane_3<CGAL::Epick> >, Polyhedron = CGAL::Polyhedron_3<CGAL::Epick, CGAL::Polyhedron_items_3, CGAL::HalfedgeDS_default, std::allocator<int> >]'|
e:\Users\Bombax\Cpp\Libraries\boost_1_58_0\boost\system\error_code.hpp|221|warning: 'boost::system::posix_category' defined but not used|
e:\Users\Bombax\Cpp\Libraries\boost_1_58_0\boost\system\error_code.hpp|222|warning: 'boost::system::errno_ecat' defined but not used|
e:\Users\Bombax\Cpp\Libraries\boost_1_58_0\boost\system\error_code.hpp|223|warning: 'boost::system::native_ecat' defined but not used|
||=== Build finished: 2 errors, 3 warnings ===|
What's going on here? Did Boost change something making it impossible to use boost::none
?
Thanks for your help.
Actually, I managed to get it working with the following workaround:
CGAL::halfspace_intersection_3(planes.begin(),
planes.end(),
poly,
static_cast<boost::optional<Point> >(boost::none));
Thanks for relaying the bug, though!