CGAL error: computing the halfspace intersection without a given point cannot compile (boost::none?)

CGAL error: computing the halfspace intersection without a given point cannot compile (boost::none?)

我已经构建了 Boost 1.58.0 和 CGAL 4.6,并将它们很好地链接到一个项目中,并使用给出的示例代码 here。这编译并完美地工作:

#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;
}

但是,删除最后一个参数,或 "correctly"(即根据规范 here)将其设置为 boost::none 会产生以下编译错误:

||=== 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 ===|

这是怎么回事? Boost 是否更改了某些内容,使其无法使用 boost::none

感谢您的帮助。

CGAL确实有bug。我已将问题转发给负责 CGAL 该部分的 CGAL 开发人员。如果他们不直接在 Whosebug 中回答,我将编辑此答案以向您推荐补丁。

编辑: 在 Github 中报告:https://github.com/CGAL/cgal/issues/75

(有的话我会转发answer/patch)

实际上,我设法通过以下解决方法让它工作:

CGAL::halfspace_intersection_3(planes.begin(),
                                   planes.end(),
                                   poly,
                                   static_cast<boost::optional<Point> >(boost::none));

不过,感谢您转发错误!