更新 CGAL 程序以使用 AABB_face_graph_triangle_primitive
Updating CGAL program to use AABB_face_graph_triangle_primitive
我有一个使用 CGAL 4.5.2_0 库的 C++ 程序,使用 macports 安装。最近,我收到 compile-time 警告,提示 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();}
^
如果有人有从已弃用的 header 文件切换到新文件的经验,我将不胜感激您对我应该如何进行的任何建议。
我可以 post 粒子 class 的 header 文件似乎是问题所在,但它有 3282 行长,我不确定是哪一部分) 我应该 post.
为了回应评论,这里是用于在树中插入图元的代码:
// 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);
将语法更新为正确的形式修复了编译时错误。
我有一个使用 CGAL 4.5.2_0 库的 C++ 程序,使用 macports 安装。最近,我收到 compile-time 警告,提示 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();}
^
如果有人有从已弃用的 header 文件切换到新文件的经验,我将不胜感激您对我应该如何进行的任何建议。
我可以 post 粒子 class 的 header 文件似乎是问题所在,但它有 3282 行长,我不确定是哪一部分) 我应该 post.
为了回应评论,这里是用于在树中插入图元的代码:
// 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);
将语法更新为正确的形式修复了编译时错误。