【问题标题】:Updating CGAL program to use AABB_face_graph_triangle_primitive更新 CGAL 程序以使用 AABB_face_graph_triangle_primitive
【发布时间】:2015-05-05 15:08:10
【问题描述】:

我有一个使用 CGAL 4.5.2_0 库的 C++ 程序,使用 macports 安装。最近,我收到了编译时警告说CGAL/AABB_polyhedron_triangle_primitive.h 标头已被弃用,我现在应该开始使用CGAL/AABB_face_graph_triangle_primitive.h,所以我天真地切换了标头名称并添加了CGAL/boost/graph/graph_traits_Polyhedron_3.h 标头文件,现在似乎是与 Boost 图形库交互所必需的。我还从 CGAL 文档中的示例中注意到,我的 typedefs 之一需要更新

typedef CGAL::AABB_polyhedron_triangle_primitive<K,Polyhedron> Primitive;

typedef CGAL::AABB_face_graph_triangle_primitive<Polyhedron> Primitive;

到目前为止,这就是我所做的事情的范围。但是现在我在编译时遇到了两个新错误:

In file included from ./Particle.h:44:
/opt/local/include/CGAL/AABB_tree.h:810:27: error: no matching conversion for functional-style cast from 'CGAL::internal::In_place_list_iterator<CGAL::HalfedgeDS_in_place_list_face<CGAL::I_Polyhedron_facet<My_facet<CGAL::HalfedgeDS_list_types<CGAL::Epick, CGAL::I_Polyhedron_derived_items_3<My_items>, std::__1::allocator<int> >, CGAL::Boolean_tag<true>, CGAL::Vector_3<CGAL::Epick> > > >, std::__1::allocator<CGAL::HalfedgeDS_in_place_list_face<CGAL::I_Polyhedron_facet<My_facet<CGAL::HalfedgeDS_list_types<CGAL::Epick, CGAL::I_Polyhedron_derived_items_3<My_items>, std::__1::allocator<int> >, CGAL::Boolean_tag<true>, CGAL::Vector_3<CGAL::Epick> > > > > >' to 'Primitive' (aka 'CGAL::AABB_face_graph_triangle_primitive<CGAL::Polyhedron_3<CGAL::Epick, My_items, HalfedgeDS_default, std::__1::allocator<int> >, CGAL::Default, CGAL::Boolean_tag<true>, CGAL::Boolean_tag<false> >')
                    m_primitives.push_back(Primitive(first));
In file included from ./Particle.h:45:
/opt/local/include/CGAL/AABB_traits.h:63:33: error: no matching member function for call to 'construct_shared_data'
m_primitive_data=Primitive::construct_shared_data();
                 ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
/opt/local/include/CGAL/AABB_tree.h:268:15: note: in instantiation of member function 'CGAL::internal::AABB_tree::AABB_traits_base<CGAL::AABB_face_graph_triangle_primitive<CGAL::Polyhedron_3<CGAL::Epick, My_items, HalfedgeDS_default, std::__1::allocator<int> >, CGAL::Default, CGAL::Boolean_tag<true>, CGAL::Boolean_tag<false> >, true>::set_shared_data' requested here
{m_traits.set_shared_data();}
          ^

如果有人有从已弃用的头文件切换到新头文件的经验,我将不胜感激您对我应该如何进行的任何建议。

我可以发布似乎有问题的 Particle 类的头文件,但它有 3282 行长,我不确定应该发布哪个部分。

作为对评论的回应,这里是用于在树中插入基元的代码:

    // The next chunk creates the 3D polyhedron, storing it in surface_poly

    Polyhedron surface_poly = getSurfacePolyhedronFromImage(fname,centroid,xBB,yBB,zBB);

    // First translate its centroid to the origin
    // CartesianVector is a typedef of CGAL's Vector_3

    const CartesianVector translation_vector(-centroid[0],-centroid[1],-centroid[2]);

    Aff_transformation_3 transl(CGAL::TRANSLATION, translation_vector);
    transform(surface_poly.points_begin(),surface_poly.points_end(),
              surface_poly.points_begin(),transl);

    // Now the centroid is the origin

    centroid.resize(3,0.0);
    CartesianPoint origin(0.0,0.0,0.0);

    // Construct the AABB tree for quick intersection queries

    cout << "Creating AABB tree from polyhedron" << endl;
    cout.flush();

    Tree tree(surface_poly.facets_begin(),surface_poly.facets_end());

    // Object intersection will hold the point of intersection with the surface

    boost::optional<Object_and_primitive_id> intersection;

【问题讨论】:

  • 您可以发布用于在树中插入基元的代码吗?你应该使用类似Tree tree(faces(polyhedron).first, faces(polyhedron).second, polyhedron);
  • 我添加了您要求的代码。我注意到它看起来与您建议的有很大不同。语法真的改变了那么多吗?我会试试你的版本,看看会发生什么。
  • 谢谢!那确实解决了问题。我还刚刚在doc.cgal.org/latest/AABB_tree 的 CGAL 文档中找到了一个例子。也许您可以发表您的评论作为答案,然后我会接受?
  • 你们谁能为这个问题写一个正确的答案? Jeff 可以自己写一个答案,或者 Sébastien (@sloriot) 可以写一个答案,然后 Jeff 会通过接受答案来结束问题。

标签: c++ boost cgal


【解决方案1】:

对于上面代码中的 Polyhedron_3,Tree 构造函数的语法不正确。正确的语法应该是

Tree tree(faces(surface_poly).first, faces(surface_poly).second, surface_poly);

将语法更新为正确的形式可修复编译时错误。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-15
    • 2023-02-14
    • 2014-07-19
    • 2016-11-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多