CGAL错误:计算没有给定点的半空间交集不能编译(boost :: none?)

时间:2015-05-07 18:23:09

标签: c++ boost cgal

我已经构建了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;
}

然而,删除最后一个参数,或者&#34;正确&#34; (也就是说,根据规范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

感谢您的帮助。

2 个答案:

答案 0 :(得分:2)

CGAL确实存在一个错误。我已将问题转发给负责CGAL部分的CGAL开发人员。如果他们没有直接在StackOverflow中回答,我将编辑这个答案,为你提供补丁。

修改 在Github报道:https://github.com/CGAL/cgal/issues/75

(如果有的话,我会在这里转发答案/补丁。)

答案 1 :(得分:0)

实际上,我设法让它使用以下解决方法:

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

感谢您转发该错误!