更新CGAL程序以使用aabb_face_graph_triangle_primive

Updating CGAL program to use AABB_face_graph_triangle_primitive

本文关键字:face graph triangle primive aabb CGAL 程序 更新      更新时间:2023-10-16

我有一个C 程序,该程序使用使用MacPorts安装的CGAL 4.5.2_0库。最近,我一直在汇编时间警告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;

to

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();}
          ^

如果有人有从弃用的标头文件转换为新的经验,我将感谢您对我应该如何进行的任何建议。

我可以发布似乎是问题的粒子类的标头文件,但是它的长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;

在上面的代码中,polyhedron_3的树构造器的语法是不正确的。正确的语法应为

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

将语法更新到正确的表单修复了编译时错误。