0

I have a C++ program that uses the CGAL 4.5.2_0 library, installed using macports. Recently, I have been getting compile-time warnings that the CGAL/AABB_polyhedron_triangle_primitive.h header is deprecated and that I now should start using CGAL/AABB_face_graph_triangle_primitive.h, so I naively switched the header name and also added the CGAL/boost/graph/graph_traits_Polyhedron_3.h header file which now seems to be necessary to interface with the Boost Graph Library. I noticed also from examples in the CGAL documentation that one of my typedefs needed to be updated from

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

to

typedef CGAL::AABB_face_graph_triangle_primitive<Polyhedron> Primitive;

And so far, that is the extent of what I have done. But now I am getting two new errors at compile time:

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

If anyone has experience switching from the deprecated header file to the new one, I will be grateful for any advice you might have about how I should proceed.

I can post the header file for the Particle class that seems to be the problem, but it is 3282 lines long and I'm not sure which part(s) I should post.

In response to comment, here is the code that is used to insert primitives in the tree:

    // 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;
Jeff Bullard
  • 345
  • 1
  • 4
  • 14
  • Can you post the code you use for inserting primitives in the tree? You should use something like `Tree tree(faces(polyhedron).first, faces(polyhedron).second, polyhedron);` – sloriot May 06 '15 at 19:30
  • I added the code you requested. I notice that it looks a lot different than what you suggested. Has the syntax really changed that much? I will try your version and see what happens. – Jeff Bullard May 07 '15 at 13:47
  • Thank you! That did fix the problem. I also just found an example of this very thing in the CGAL documentation at http://doc.cgal.org/latest/AABB_tree/. Perhaps you could post your comment as an answer and then I will accept it? – Jeff Bullard May 07 '15 at 14:01
  • Can one of you write a proper answer for the question? Jeff could write a self-answer, or Sébastien (@sloriot) could write an answer, and then Jeff would close the question by accepting the answer. – lrineau May 08 '15 at 08:37

1 Answers1

1

The syntax for the Tree constructor is incorrect for the Polyhedron_3 in the code above. The correct syntax should be

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

Updating the syntax to the correct form fixes the compile-time errors.

Jeff Bullard
  • 345
  • 1
  • 4
  • 14