2015-05-05 105 views
0

我有一個C++程序,使用CGAL 4.5.2_0庫,使用macports安裝。最近,我得到編譯時警告,CGAL/AABB_polyhedron_triangle_primitive.h標題已過時,現在我應該開始使用CGAL/AABB_face_graph_triangle_primitive.h,所以我天真地切換標題名稱,並且還添加了現在看起來需要與Boost圖庫。我還注意到,從我的typedefs需要一個從更新CGAL程序使用AABB_face_graph_triangle_primitive

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

更新

typedef CGAL::AABB_face_graph_triangle_primitive<Polyhedron> Primitive; 

到目前爲止,這是我所做過的程度CGAL文檔中的例子。但現在我得到在編譯時兩個新的錯誤:

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; 
+0

你可以發佈你用於在樹中插入圖元的代碼嗎?你應該使用像樹樹(面(多面體),首先,面(多面體)。第二,多面體);' – sloriot

+0

我添加了你請求的代碼。我注意到它看起來與你建議的很不一樣。語法真的改變了多少?我會嘗試你的版本,看看會發生什麼。 –

+0

謝謝!這確實解決了這個問題。我還在http://doc.cgal.org/latest/AABB_tree/的CGAL文檔中找到了這樣一個例子。也許你可以發表你的評論作爲答案,然後我會接受它? –

回答

1

的樹構造函數的語法是在上面的代碼不正確的Polyhedron_3。正確的語法應該是

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

將語法更新到正確的形式可修復編譯時錯誤。