gpt4 book ai didi

c++ - 更新 CGAL 程序以使用 AABB_face_graph_triangle_primitive

转载 作者:行者123 更新时间:2023-11-28 06:16:59 26 4
gpt4 key购买 nike

我有一个使用 CGAL 4.5.2_0 库的 C++ 程序,使用 macports 安装。最近,我收到编译时警告,提示 CGAL/AABB_polyhedron_triangle_primitive.h header 已弃用,我现在应该开始使用 CGAL/AABB_face_graph_triangle_primitive.h,所以我天真地切换了 header 名称并添加了 CGAL/boost/graph/graph_traits_Polyhedron_3.h header 文件,现在看来这是与 Boost Graph Library 交互所必需的。我还从 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;

最佳答案

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

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

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

关于c++ - 更新 CGAL 程序以使用 AABB_face_graph_triangle_primitive,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30056750/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com