CGAL错误:计算半空间交集时没有给定点无法编译(boost::none?)

3

我已经构建了Boost 1.58.0和CGAL 4.6,并在一个项目中使用这里提供的示例代码将它们链接得很好。这可以编译并运行得很完美:

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

然而,如果移除最后一个参数,或者"正确地"(即根据这里的规格)将其设置为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吗?
感谢您的帮助。
2个回答

2
CGAL确实存在一个bug。我已经将这个问题转发给负责该部分CGAL开发的开发人员。如果他们没有在StackOverflow上直接回答,我会编辑这个答案并向您提供补丁。
编辑:在Github上报告:https://github.com/CGAL/cgal/issues/75 (一旦有答案/补丁,我会在这里转发它。)

0

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

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

感谢您报告这个错误!


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接